|
1 | 1 | // @ts-check |
2 | 2 |
|
3 | | -import * as path from "node:path"; |
4 | | - |
5 | 3 | /** |
6 | | - * For compatibility reasons, if the architecture is x64, omit it from the bin directory name. |
7 | | - * So we'll have "darwin", "linux" and "win32" for x64 arch, |
8 | | - * but "darwinarm64" and "linuxarm64" for arm64 arch. |
9 | | - * Also, we do not have Windows ARM binaries yet. But the x64 binaries do work on Windows 11 ARM. |
10 | | - * So omit the architecture for Windows, too. |
| 4 | + * @typedef {{ |
| 5 | + * platformDir: string, |
| 6 | + * bsc_exe: string, |
| 7 | + * ninja_exe: string, |
| 8 | + * rescript_exe: string, |
| 9 | + * rescript_tools_exe: string, |
| 10 | + * rescript_editor_analysis_exe: string, |
| 11 | + * rewatch_exe: string, |
| 12 | + * }} BinaryPaths |
11 | 13 | */ |
12 | | -export const platformName = |
13 | | - process.arch === "x64" || process.platform === "win32" |
14 | | - ? process.platform |
15 | | - : process.platform + process.arch; |
16 | | - |
17 | | -export const platformDir = path.resolve( |
18 | | - import.meta.dirname, |
19 | | - "..", |
20 | | - "..", |
21 | | - platformName, |
22 | | -); |
23 | | - |
24 | | -export const bsc_exe = path.join(platformDir, "bsc.exe"); |
25 | 14 |
|
26 | | -export const ninja_exe = path.join(platformDir, "ninja.exe"); |
| 15 | +const target = `${process.platform}-${process.arch}`; |
27 | 16 |
|
28 | | -export const rescript_exe = path.join(platformDir, "rescript.exe"); |
| 17 | +/** @type {BinaryPaths} */ |
| 18 | +let binPaths; |
| 19 | +try { |
| 20 | + binPaths = await import(`@rescript/${target}/paths`); |
| 21 | +} catch (err) { |
| 22 | + console.error(`Platform ${target} is not supported!`); |
| 23 | + throw err; |
| 24 | +} |
29 | 25 |
|
30 | | -export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); |
31 | | - |
32 | | -export const rescript_editor_analysis_exe = path.join( |
| 26 | +export const { |
33 | 27 | platformDir, |
34 | | - "rescript-editor-analysis.exe", |
35 | | -); |
36 | | - |
37 | | -export const rewatch_exe = path.join(platformDir, "rewatch.exe"); |
| 28 | + bsc_exe, |
| 29 | + ninja_exe, |
| 30 | + rescript_editor_analysis_exe, |
| 31 | + rescript_tools_exe, |
| 32 | + rescript_exe, |
| 33 | + rewatch_exe, |
| 34 | +} = binPaths; |
0 commit comments