|
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 | + * bsb_helper_exe: string, |
| 7 | + * bsc_exe: string, |
| 8 | + * ninja_exe: string, |
| 9 | + * rescript_exe: string, |
| 10 | + * rescript_tools_exe: string, |
| 11 | + * rescript_editor_analysis_exe: string, |
| 12 | + * rewatch_exe: string, |
| 13 | + * }} BinaryPaths |
11 | 14 | */ |
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 | 15 |
|
26 | | -export const ninja_exe = path.join(platformDir, "ninja.exe"); |
| 16 | +const target = `${process.platform}-${process.arch}`; |
27 | 17 |
|
28 | | -export const rescript_exe = path.join(platformDir, "rescript.exe"); |
| 18 | +/** @type {BinaryPaths} */ |
| 19 | +let binPaths; |
| 20 | +try { |
| 21 | + binPaths = await import(`@rescript/${target}/paths`); |
| 22 | +} catch (err) { |
| 23 | + console.error(`Platform ${target} is not supported!`); |
| 24 | + throw err; |
| 25 | +} |
29 | 26 |
|
30 | | -export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); |
31 | | - |
32 | | -export const rescript_editor_analysis_exe = path.join( |
| 27 | +export const { |
33 | 28 | platformDir, |
34 | | - "rescript-editor-analysis.exe", |
35 | | -); |
36 | | - |
37 | | -export const rewatch_exe = path.join(platformDir, "rewatch.exe"); |
| 29 | + bsb_helper_exe, |
| 30 | + bsc_exe, |
| 31 | + ninja_exe, |
| 32 | + rescript_editor_analysis_exe, |
| 33 | + rescript_tools_exe, |
| 34 | + rescript_exe, |
| 35 | + rewatch_exe, |
| 36 | +} = binPaths; |
0 commit comments