From 6451c4b39a818446099f2376e955200e482c4a33 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Tue, 15 Apr 2025 03:40:32 +0900 Subject: [PATCH 01/34] wip --- package.json | 2 +- packages/@rescript/linux-arm64/bin/paths.js | 20 +++++++++++ packages/@rescript/linux-arm64/package.json | 37 +++++++++++++++++++++ packages/@rescript/linux-x64/bin/paths.js | 20 +++++++++++ packages/@rescript/linux-x64/package.json | 28 ++++++++++++++++ yarn.lock | 12 +++++++ 6 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 packages/@rescript/linux-arm64/bin/paths.js create mode 100644 packages/@rescript/linux-arm64/package.json create mode 100644 packages/@rescript/linux-x64/bin/paths.js create mode 100644 packages/@rescript/linux-x64/package.json diff --git a/package.json b/package.json index 70fc33473e..b5bb4cbbe6 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "typescript": "5.8.2" }, "workspaces": [ - "packages/*", + "packages/**", "tests/dependencies/**", "tests/analysis_tests/**", "tests/gentype_tests/**", diff --git a/packages/@rescript/linux-arm64/bin/paths.js b/packages/@rescript/linux-arm64/bin/paths.js new file mode 100644 index 0000000000..21528b8692 --- /dev/null +++ b/packages/@rescript/linux-arm64/bin/paths.js @@ -0,0 +1,20 @@ +// @ts-check + +import * as path from "node:path"; + +export const platformDir = import.meta.dirname; + +export const bsc_exe = path.join(platformDir, "bsc.exe"); + +export const ninja_exe = path.join(platformDir, "ninja.exe"); + +export const rescript_exe = path.join(platformDir, "rescript.exe"); + +export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); + +export const rescript_editor_analysis_exe = path.join( + platformDir, + "rescript-editor-analysis.exe", +); + +export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/linux-arm64/package.json b/packages/@rescript/linux-arm64/package.json new file mode 100644 index 0000000000..f7e6f2822b --- /dev/null +++ b/packages/@rescript/linux-arm64/package.json @@ -0,0 +1,37 @@ +{ + "name": "@rescript/linux-arm64", + "version": "12.0.0-alpha.12", + "description": "ReScript toolchain", + "type": "module", + "keywords": [ + "ReScript", + "Compiler", + "Types", + "JavaScript", + "Language" + ], + "license": "SEE LICENSE IN LICENSE", + "homepage": "http://rescript-lang.org", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "linux" + ], + "cpu": [ + "arm64" + ], + "files": [ + "bin" + ], + "publishConfig": { + "access": "public" + }, + "exports": { + "./paths": "./bin/paths.js" + } +} diff --git a/packages/@rescript/linux-x64/bin/paths.js b/packages/@rescript/linux-x64/bin/paths.js new file mode 100644 index 0000000000..21528b8692 --- /dev/null +++ b/packages/@rescript/linux-x64/bin/paths.js @@ -0,0 +1,20 @@ +// @ts-check + +import * as path from "node:path"; + +export const platformDir = import.meta.dirname; + +export const bsc_exe = path.join(platformDir, "bsc.exe"); + +export const ninja_exe = path.join(platformDir, "ninja.exe"); + +export const rescript_exe = path.join(platformDir, "rescript.exe"); + +export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); + +export const rescript_editor_analysis_exe = path.join( + platformDir, + "rescript-editor-analysis.exe", +); + +export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/linux-x64/package.json b/packages/@rescript/linux-x64/package.json new file mode 100644 index 0000000000..19032c984a --- /dev/null +++ b/packages/@rescript/linux-x64/package.json @@ -0,0 +1,28 @@ +{ + "name": "@rescript/linux-x64", + "version": "12.0.0-alpha.12", + "description": "ReScript binaries for Linux x64", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "files": [ + "bin" + ], + "publishConfig": { + "access": "public" + }, + "exports": { + "./paths": "./bin/paths.js" + } +} diff --git a/yarn.lock b/yarn.lock index 5cbbbe4462..f0cea874bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -388,6 +388,18 @@ __metadata: languageName: node linkType: hard +"@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64": + version: 0.0.0-use.local + resolution: "@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64" + languageName: unknown + linkType: soft + +"@rescript/linux-x64@workspace:packages/@rescript/linux-x64": + version: 0.0.0-use.local + resolution: "@rescript/linux-x64@workspace:packages/@rescript/linux-x64" + languageName: unknown + linkType: soft + "@rescript/react@link:../../../dependencies/rescript-react::locator=%40tests%2Freanalyze-deadcode%40workspace%3Atests%2Fanalysis_tests%2Ftests-reanalyze%2Fdeadcode": version: 0.0.0-use.local resolution: "@rescript/react@link:../../../dependencies/rescript-react::locator=%40tests%2Freanalyze-deadcode%40workspace%3Atests%2Fanalysis_tests%2Ftests-reanalyze%2Fdeadcode" From 22e361d3aca7cfa15c639763d314e4606737e99b Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Tue, 15 Apr 2025 08:47:49 +0900 Subject: [PATCH 02/34] per-platform packages --- .github/workflows/get_artifact_dir_name.js | 2 +- .gitignore | 7 +- cli/common/bins.js | 57 +++++++------- lib_dev/paths.js | 17 ++++ package.json | 12 +-- .../@rescript/darwin-arm64/bin/bsb_helper.exe | 1 + packages/@rescript/darwin-arm64/bin/bsc.exe | 1 + packages/@rescript/darwin-arm64/bin/ninja.exe | 1 + packages/@rescript/darwin-arm64/bin/paths.js | 20 +++++ .../bin/rescript-editor-analysis.exe | 1 + .../darwin-arm64/bin/rescript-tools.exe | 1 + .../@rescript/darwin-arm64/bin/rescript.exe | 1 + .../@rescript/darwin-arm64/bin/rewatch.exe | 1 + packages/@rescript/darwin-arm64/package.json | 38 +++++++++ .../@rescript/darwin-x64/bin/bsb_helper.exe | 1 + packages/@rescript/darwin-x64/bin/bsc.exe | 1 + packages/@rescript/darwin-x64/bin/ninja.exe | 1 + packages/@rescript/darwin-x64/bin/paths.js | 20 +++++ .../bin/rescript-editor-analysis.exe | 1 + .../darwin-x64/bin/rescript-tools.exe | 1 + .../@rescript/darwin-x64/bin/rescript.exe | 1 + packages/@rescript/darwin-x64/bin/rewatch.exe | 1 + packages/@rescript/darwin-x64/package.json | 38 +++++++++ .../@rescript/linux-arm64/bin/bsb_helper.exe | 1 + packages/@rescript/linux-arm64/bin/bsc.exe | 1 + packages/@rescript/linux-arm64/bin/ninja.exe | 1 + .../bin/rescript-editor-analysis.exe | 1 + .../linux-arm64/bin/rescript-tools.exe | 1 + .../@rescript/linux-arm64/bin/rescript.exe | 1 + .../@rescript/linux-arm64/bin/rewatch.exe | 1 + packages/@rescript/linux-arm64/package.json | 27 +++---- .../@rescript/linux-x64/bin/bsb_helper.exe | 1 + packages/@rescript/linux-x64/bin/bsc.exe | 1 + packages/@rescript/linux-x64/bin/ninja.exe | 1 + .../bin/rescript-editor-analysis.exe | 1 + .../linux-x64/bin/rescript-tools.exe | 1 + packages/@rescript/linux-x64/bin/rescript.exe | 1 + packages/@rescript/linux-x64/bin/rewatch.exe | 1 + packages/@rescript/linux-x64/package.json | 18 ++++- .../@rescript/win32-x64/bin/bsb_helper.exe | 1 + packages/@rescript/win32-x64/bin/bsc.exe | 1 + packages/@rescript/win32-x64/bin/ninja.exe | 1 + packages/@rescript/win32-x64/bin/paths.js | 20 +++++ .../bin/rescript-editor-analysis.exe | 1 + .../win32-x64/bin/rescript-tools.exe | 1 + packages/@rescript/win32-x64/bin/rescript.exe | 1 + packages/@rescript/win32-x64/bin/rewatch.exe | 1 + packages/@rescript/win32-x64/package.json | 38 +++++++++ scripts/copyExes.js | 2 +- tsconfig.json | 1 + yarn.lock | 78 ++++++++++++++++++- 51 files changed, 374 insertions(+), 56 deletions(-) create mode 120000 packages/@rescript/darwin-arm64/bin/bsb_helper.exe create mode 120000 packages/@rescript/darwin-arm64/bin/bsc.exe create mode 120000 packages/@rescript/darwin-arm64/bin/ninja.exe create mode 100644 packages/@rescript/darwin-arm64/bin/paths.js create mode 120000 packages/@rescript/darwin-arm64/bin/rescript-editor-analysis.exe create mode 120000 packages/@rescript/darwin-arm64/bin/rescript-tools.exe create mode 120000 packages/@rescript/darwin-arm64/bin/rescript.exe create mode 120000 packages/@rescript/darwin-arm64/bin/rewatch.exe create mode 100644 packages/@rescript/darwin-arm64/package.json create mode 120000 packages/@rescript/darwin-x64/bin/bsb_helper.exe create mode 120000 packages/@rescript/darwin-x64/bin/bsc.exe create mode 120000 packages/@rescript/darwin-x64/bin/ninja.exe create mode 100644 packages/@rescript/darwin-x64/bin/paths.js create mode 120000 packages/@rescript/darwin-x64/bin/rescript-editor-analysis.exe create mode 120000 packages/@rescript/darwin-x64/bin/rescript-tools.exe create mode 120000 packages/@rescript/darwin-x64/bin/rescript.exe create mode 120000 packages/@rescript/darwin-x64/bin/rewatch.exe create mode 100644 packages/@rescript/darwin-x64/package.json create mode 120000 packages/@rescript/linux-arm64/bin/bsb_helper.exe create mode 120000 packages/@rescript/linux-arm64/bin/bsc.exe create mode 120000 packages/@rescript/linux-arm64/bin/ninja.exe create mode 120000 packages/@rescript/linux-arm64/bin/rescript-editor-analysis.exe create mode 120000 packages/@rescript/linux-arm64/bin/rescript-tools.exe create mode 120000 packages/@rescript/linux-arm64/bin/rescript.exe create mode 120000 packages/@rescript/linux-arm64/bin/rewatch.exe create mode 120000 packages/@rescript/linux-x64/bin/bsb_helper.exe create mode 120000 packages/@rescript/linux-x64/bin/bsc.exe create mode 120000 packages/@rescript/linux-x64/bin/ninja.exe create mode 120000 packages/@rescript/linux-x64/bin/rescript-editor-analysis.exe create mode 120000 packages/@rescript/linux-x64/bin/rescript-tools.exe create mode 120000 packages/@rescript/linux-x64/bin/rescript.exe create mode 120000 packages/@rescript/linux-x64/bin/rewatch.exe create mode 120000 packages/@rescript/win32-x64/bin/bsb_helper.exe create mode 120000 packages/@rescript/win32-x64/bin/bsc.exe create mode 120000 packages/@rescript/win32-x64/bin/ninja.exe create mode 100644 packages/@rescript/win32-x64/bin/paths.js create mode 120000 packages/@rescript/win32-x64/bin/rescript-editor-analysis.exe create mode 120000 packages/@rescript/win32-x64/bin/rescript-tools.exe create mode 120000 packages/@rescript/win32-x64/bin/rescript.exe create mode 120000 packages/@rescript/win32-x64/bin/rewatch.exe create mode 100644 packages/@rescript/win32-x64/package.json diff --git a/.github/workflows/get_artifact_dir_name.js b/.github/workflows/get_artifact_dir_name.js index 9ad465b6a4..80ec51e212 100644 --- a/.github/workflows/get_artifact_dir_name.js +++ b/.github/workflows/get_artifact_dir_name.js @@ -1,7 +1,7 @@ import * as fs from "node:fs"; import * as os from "node:os"; -import { platformName } from "#cli/bins"; +import { platformName } from "#dev/paths"; // Pass artifactDirName to subsequent GitHub actions fs.appendFileSync( diff --git a/.gitignore b/.gitignore index f672ecca61..5f8b2363cb 100644 --- a/.gitignore +++ b/.gitignore @@ -46,7 +46,6 @@ _build node_modules *.dump coverage -*.exe .ninja_log .bsdeps @@ -82,6 +81,12 @@ tests/tools_tests/lib tests/analysis_tests*/lib tests/analysis_tests/**/*.bs.js +/linux/*.exe +/linuxarm64/*.exe +/darwin/*.exe +/darwinarm64/*.exe +/win32/*.exe + .yarn/* !.yarn/patches !.yarn/plugins diff --git a/cli/common/bins.js b/cli/common/bins.js index 7472466062..a0f36dca66 100644 --- a/cli/common/bins.js +++ b/cli/common/bins.js @@ -1,37 +1,36 @@ // @ts-check -import * as path from "node:path"; - /** - * For compatibility reasons, if the architecture is x64, omit it from the bin directory name. - * So we'll have "darwin", "linux" and "win32" for x64 arch, - * but "darwinarm64" and "linuxarm64" for arm64 arch. - * Also, we do not have Windows ARM binaries yet. But the x64 binaries do work on Windows 11 ARM. - * So omit the architecture for Windows, too. + * @typedef {{ + * platformDir: string, + * bsb_helper_exe: string, + * bsc_exe: string, + * ninja_exe: string, + * rescript_exe: string, + * rescript_tools_exe: string, + * rescript_editor_analysis_exe: string, + * rewatch_exe: string, + * }} BinaryPaths */ -export const platformName = - process.arch === "x64" || process.platform === "win32" - ? process.platform - : process.platform + process.arch; - -export const platformDir = path.resolve( - import.meta.dirname, - "..", - "..", - platformName, -); - -export const bsc_exe = path.join(platformDir, "bsc.exe"); -export const ninja_exe = path.join(platformDir, "ninja.exe"); +const target = `${process.platform}-${process.arch}`; -export const rescript_exe = path.join(platformDir, "rescript.exe"); +/** @type {BinaryPaths} */ +let binPaths; +try { + binPaths = await import(`@rescript/${target}/paths`); +} catch (err) { + console.error(`Platform ${target} is not supported!`); + throw err; +} -export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); - -export const rescript_editor_analysis_exe = path.join( +export const { platformDir, - "rescript-editor-analysis.exe", -); - -export const rewatch_exe = path.join(platformDir, "rewatch.exe"); + bsb_helper_exe, + bsc_exe, + ninja_exe, + rescript_editor_analysis_exe, + rescript_tools_exe, + rescript_exe, + rewatch_exe, +} = binPaths; diff --git a/lib_dev/paths.js b/lib_dev/paths.js index 35da5c5593..e6cb44a980 100644 --- a/lib_dev/paths.js +++ b/lib_dev/paths.js @@ -7,6 +7,23 @@ import * as path from "node:path"; */ export const projectDir = path.resolve(import.meta.dirname, ".."); +/** + * For compatibility reasons, if the architecture is x64, omit it from the bin directory name. + * So we'll have "darwin", "linux" and "win32" for x64 arch, + * but "darwinarm64" and "linuxarm64" for arm64 arch. + * Also, we do not have Windows ARM binaries yet. But the x64 binaries do work on Windows 11 ARM. + * So omit the architecture for Windows, too. + */ +export const platformName = + process.arch === "x64" || process.platform === "win32" + ? process.platform + : process.platform + process.arch; + +/** + * path: `/` (e.g. linux, darwinarm64) + */ +export const platformDir = path.resolve(projectDir, platformName); + /** * path: `/compiler/` */ diff --git a/package.json b/package.json index b5bb4cbbe6..5a47315a3d 100644 --- a/package.json +++ b/package.json @@ -58,11 +58,6 @@ "CHANGELOG.md", "CREDITS.md", "ninja.COPYING", - "darwin", - "darwinarm64", - "linux", - "linuxarm64", - "win32", "docs/docson/build-schema.json", "lib", "cli" @@ -77,6 +72,13 @@ "#dev/*": "./lib_dev/*.js", "#lib/minisocket": "./lib/minisocket.js" }, + "optionalDependencies": { + "@rescript/darwin-arm64": "12.0.0-alpha.12", + "@rescript/darwin-x64": "12.0.0-alpha.12", + "@rescript/linux-arm64": "12.0.0-alpha.12", + "@rescript/linux-x64": "12.0.0-alpha.12", + "@rescript/win32-x64": "12.0.0-alpha.12" + }, "devDependencies": { "@biomejs/biome": "1.9.4", "@types/node": "^20.14.9", diff --git a/packages/@rescript/darwin-arm64/bin/bsb_helper.exe b/packages/@rescript/darwin-arm64/bin/bsb_helper.exe new file mode 120000 index 0000000000..544194436c --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin/bsb_helper.exe @@ -0,0 +1 @@ +../../../../darwinarm64/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/bsc.exe b/packages/@rescript/darwin-arm64/bin/bsc.exe new file mode 120000 index 0000000000..a9f64d85b2 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin/bsc.exe @@ -0,0 +1 @@ +../../../../darwinarm64/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/ninja.exe b/packages/@rescript/darwin-arm64/bin/ninja.exe new file mode 120000 index 0000000000..0c9bd19151 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin/ninja.exe @@ -0,0 +1 @@ +../../../../darwinarm64/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/paths.js b/packages/@rescript/darwin-arm64/bin/paths.js new file mode 100644 index 0000000000..21528b8692 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin/paths.js @@ -0,0 +1,20 @@ +// @ts-check + +import * as path from "node:path"; + +export const platformDir = import.meta.dirname; + +export const bsc_exe = path.join(platformDir, "bsc.exe"); + +export const ninja_exe = path.join(platformDir, "ninja.exe"); + +export const rescript_exe = path.join(platformDir, "rescript.exe"); + +export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); + +export const rescript_editor_analysis_exe = path.join( + platformDir, + "rescript-editor-analysis.exe", +); + +export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/darwin-arm64/bin/rescript-editor-analysis.exe b/packages/@rescript/darwin-arm64/bin/rescript-editor-analysis.exe new file mode 120000 index 0000000000..c57e413214 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin/rescript-editor-analysis.exe @@ -0,0 +1 @@ +../../../../darwinarm64/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/rescript-tools.exe b/packages/@rescript/darwin-arm64/bin/rescript-tools.exe new file mode 120000 index 0000000000..d77321ea88 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin/rescript-tools.exe @@ -0,0 +1 @@ +../../../../darwinarm64/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/rescript.exe b/packages/@rescript/darwin-arm64/bin/rescript.exe new file mode 120000 index 0000000000..88da2239af --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin/rescript.exe @@ -0,0 +1 @@ +../../../../darwinarm64/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/rewatch.exe b/packages/@rescript/darwin-arm64/bin/rewatch.exe new file mode 120000 index 0000000000..958f8e7285 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin/rewatch.exe @@ -0,0 +1 @@ +../../../../darwinarm64/rewatch.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/package.json b/packages/@rescript/darwin-arm64/package.json new file mode 100644 index 0000000000..ccb4dcaa96 --- /dev/null +++ b/packages/@rescript/darwin-arm64/package.json @@ -0,0 +1,38 @@ +{ + "name": "@rescript/darwin-arm64", + "version": "12.0.0-alpha.12", + "description": "ReScript binaries for MacOS ARM64", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "darwin" + ], + "cpu": [ + "arm64" + ], + "files": [ + "bin" + ], + "bin": { + "bsb_helper.exe": "./bin/bsb_helper.exe", + "bsc.exe": "./bin/bsc.exe", + "ninja.exe": "./bin/ninja.exe", + "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", + "rescript-tools.exe": "./bin/rescript-tools.exe", + "rescript.exe": "./bin/rescript.exe", + "rewatch.exe": "./bin/rewatch.exe" + }, + "exports": { + "./paths": "./bin/paths.js" + }, + "preferUnplugged": true +} diff --git a/packages/@rescript/darwin-x64/bin/bsb_helper.exe b/packages/@rescript/darwin-x64/bin/bsb_helper.exe new file mode 120000 index 0000000000..13acf7745f --- /dev/null +++ b/packages/@rescript/darwin-x64/bin/bsb_helper.exe @@ -0,0 +1 @@ +../../../../darwin/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/bsc.exe b/packages/@rescript/darwin-x64/bin/bsc.exe new file mode 120000 index 0000000000..e2923a916f --- /dev/null +++ b/packages/@rescript/darwin-x64/bin/bsc.exe @@ -0,0 +1 @@ +../../../../darwin/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/ninja.exe b/packages/@rescript/darwin-x64/bin/ninja.exe new file mode 120000 index 0000000000..a03a7c1339 --- /dev/null +++ b/packages/@rescript/darwin-x64/bin/ninja.exe @@ -0,0 +1 @@ +../../../../darwin/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/paths.js b/packages/@rescript/darwin-x64/bin/paths.js new file mode 100644 index 0000000000..21528b8692 --- /dev/null +++ b/packages/@rescript/darwin-x64/bin/paths.js @@ -0,0 +1,20 @@ +// @ts-check + +import * as path from "node:path"; + +export const platformDir = import.meta.dirname; + +export const bsc_exe = path.join(platformDir, "bsc.exe"); + +export const ninja_exe = path.join(platformDir, "ninja.exe"); + +export const rescript_exe = path.join(platformDir, "rescript.exe"); + +export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); + +export const rescript_editor_analysis_exe = path.join( + platformDir, + "rescript-editor-analysis.exe", +); + +export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/darwin-x64/bin/rescript-editor-analysis.exe b/packages/@rescript/darwin-x64/bin/rescript-editor-analysis.exe new file mode 120000 index 0000000000..c631958428 --- /dev/null +++ b/packages/@rescript/darwin-x64/bin/rescript-editor-analysis.exe @@ -0,0 +1 @@ +../../../../darwin/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/rescript-tools.exe b/packages/@rescript/darwin-x64/bin/rescript-tools.exe new file mode 120000 index 0000000000..e10a3ec47c --- /dev/null +++ b/packages/@rescript/darwin-x64/bin/rescript-tools.exe @@ -0,0 +1 @@ +../../../../darwin/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/rescript.exe b/packages/@rescript/darwin-x64/bin/rescript.exe new file mode 120000 index 0000000000..a7fc58903b --- /dev/null +++ b/packages/@rescript/darwin-x64/bin/rescript.exe @@ -0,0 +1 @@ +../../../../darwin/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/rewatch.exe b/packages/@rescript/darwin-x64/bin/rewatch.exe new file mode 120000 index 0000000000..f20bcb3918 --- /dev/null +++ b/packages/@rescript/darwin-x64/bin/rewatch.exe @@ -0,0 +1 @@ +../../../../darwin/rewatch.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/package.json b/packages/@rescript/darwin-x64/package.json new file mode 100644 index 0000000000..fc69f03a54 --- /dev/null +++ b/packages/@rescript/darwin-x64/package.json @@ -0,0 +1,38 @@ +{ + "name": "@rescript/darwin-x64", + "version": "12.0.0-alpha.12", + "description": "ReScript binaries for MacOS x86_64", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ], + "files": [ + "bin" + ], + "bin": { + "bsb_helper.exe": "./bin/bsb_helper.exe", + "bsc.exe": "./bin/bsc.exe", + "ninja.exe": "./bin/ninja.exe", + "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", + "rescript-tools.exe": "./bin/rescript-tools.exe", + "rescript.exe": "./bin/rescript.exe", + "rewatch.exe": "./bin/rewatch.exe" + }, + "exports": { + "./paths": "./bin/paths.js" + }, + "preferUnplugged": true +} diff --git a/packages/@rescript/linux-arm64/bin/bsb_helper.exe b/packages/@rescript/linux-arm64/bin/bsb_helper.exe new file mode 120000 index 0000000000..dae266770a --- /dev/null +++ b/packages/@rescript/linux-arm64/bin/bsb_helper.exe @@ -0,0 +1 @@ +../../../../linuxarm64/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/bsc.exe b/packages/@rescript/linux-arm64/bin/bsc.exe new file mode 120000 index 0000000000..3ffd1e867e --- /dev/null +++ b/packages/@rescript/linux-arm64/bin/bsc.exe @@ -0,0 +1 @@ +../../../../linuxarm64/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/ninja.exe b/packages/@rescript/linux-arm64/bin/ninja.exe new file mode 120000 index 0000000000..15780321c1 --- /dev/null +++ b/packages/@rescript/linux-arm64/bin/ninja.exe @@ -0,0 +1 @@ +../../../../linuxarm64/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/rescript-editor-analysis.exe b/packages/@rescript/linux-arm64/bin/rescript-editor-analysis.exe new file mode 120000 index 0000000000..5c94854538 --- /dev/null +++ b/packages/@rescript/linux-arm64/bin/rescript-editor-analysis.exe @@ -0,0 +1 @@ +../../../../linuxarm64/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/rescript-tools.exe b/packages/@rescript/linux-arm64/bin/rescript-tools.exe new file mode 120000 index 0000000000..3566050d8d --- /dev/null +++ b/packages/@rescript/linux-arm64/bin/rescript-tools.exe @@ -0,0 +1 @@ +../../../../linuxarm64/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/rescript.exe b/packages/@rescript/linux-arm64/bin/rescript.exe new file mode 120000 index 0000000000..9a6b86bf1c --- /dev/null +++ b/packages/@rescript/linux-arm64/bin/rescript.exe @@ -0,0 +1 @@ +../../../../linuxarm64/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/rewatch.exe b/packages/@rescript/linux-arm64/bin/rewatch.exe new file mode 120000 index 0000000000..ed5bbc1009 --- /dev/null +++ b/packages/@rescript/linux-arm64/bin/rewatch.exe @@ -0,0 +1 @@ +../../../../linuxarm64/rewatch.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/package.json b/packages/@rescript/linux-arm64/package.json index f7e6f2822b..37ddaedf27 100644 --- a/packages/@rescript/linux-arm64/package.json +++ b/packages/@rescript/linux-arm64/package.json @@ -1,21 +1,15 @@ { "name": "@rescript/linux-arm64", "version": "12.0.0-alpha.12", - "description": "ReScript toolchain", + "description": "ReScript binaries for Linux ARM64", "type": "module", - "keywords": [ - "ReScript", - "Compiler", - "Types", - "JavaScript", - "Language" - ], - "license": "SEE LICENSE IN LICENSE", - "homepage": "http://rescript-lang.org", "repository": { "type": "git", "url": "git+https://github.com/rescript-lang/rescript-compiler.git" }, + "publishConfig": { + "access": "public" + }, "engines": { "node": ">=20.11.0" }, @@ -28,10 +22,17 @@ "files": [ "bin" ], - "publishConfig": { - "access": "public" + "bin": { + "bsb_helper.exe": "./bin/bsb_helper.exe", + "bsc.exe": "./bin/bsc.exe", + "ninja.exe": "./bin/ninja.exe", + "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", + "rescript-tools.exe": "./bin/rescript-tools.exe", + "rescript.exe": "./bin/rescript.exe", + "rewatch.exe": "./bin/rewatch.exe" }, "exports": { "./paths": "./bin/paths.js" - } + }, + "preferUnplugged": true } diff --git a/packages/@rescript/linux-x64/bin/bsb_helper.exe b/packages/@rescript/linux-x64/bin/bsb_helper.exe new file mode 120000 index 0000000000..c7ede80d93 --- /dev/null +++ b/packages/@rescript/linux-x64/bin/bsb_helper.exe @@ -0,0 +1 @@ +../../../../linux/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/bsc.exe b/packages/@rescript/linux-x64/bin/bsc.exe new file mode 120000 index 0000000000..cfa8db2009 --- /dev/null +++ b/packages/@rescript/linux-x64/bin/bsc.exe @@ -0,0 +1 @@ +../../../../linux/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/ninja.exe b/packages/@rescript/linux-x64/bin/ninja.exe new file mode 120000 index 0000000000..dc0317d50a --- /dev/null +++ b/packages/@rescript/linux-x64/bin/ninja.exe @@ -0,0 +1 @@ +../../../../linux/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/rescript-editor-analysis.exe b/packages/@rescript/linux-x64/bin/rescript-editor-analysis.exe new file mode 120000 index 0000000000..d84c1cbf9f --- /dev/null +++ b/packages/@rescript/linux-x64/bin/rescript-editor-analysis.exe @@ -0,0 +1 @@ +../../../../linux/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/rescript-tools.exe b/packages/@rescript/linux-x64/bin/rescript-tools.exe new file mode 120000 index 0000000000..cc95a6383a --- /dev/null +++ b/packages/@rescript/linux-x64/bin/rescript-tools.exe @@ -0,0 +1 @@ +../../../../linux/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/rescript.exe b/packages/@rescript/linux-x64/bin/rescript.exe new file mode 120000 index 0000000000..dd45ba8b9b --- /dev/null +++ b/packages/@rescript/linux-x64/bin/rescript.exe @@ -0,0 +1 @@ +../../../../linux/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/rewatch.exe b/packages/@rescript/linux-x64/bin/rewatch.exe new file mode 120000 index 0000000000..07de5b26f3 --- /dev/null +++ b/packages/@rescript/linux-x64/bin/rewatch.exe @@ -0,0 +1 @@ +../../../../linux/rewatch.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/package.json b/packages/@rescript/linux-x64/package.json index 19032c984a..5181ea0817 100644 --- a/packages/@rescript/linux-x64/package.json +++ b/packages/@rescript/linux-x64/package.json @@ -1,12 +1,15 @@ { "name": "@rescript/linux-x64", "version": "12.0.0-alpha.12", - "description": "ReScript binaries for Linux x64", + "description": "ReScript binaries for Linux x86_64", "type": "module", "repository": { "type": "git", "url": "git+https://github.com/rescript-lang/rescript-compiler.git" }, + "publishConfig": { + "access": "public" + }, "engines": { "node": ">=20.11.0" }, @@ -19,10 +22,17 @@ "files": [ "bin" ], - "publishConfig": { - "access": "public" + "bin": { + "bsb_helper.exe": "./bin/bsb_helper.exe", + "bsc.exe": "./bin/bsc.exe", + "ninja.exe": "./bin/ninja.exe", + "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", + "rescript-tools.exe": "./bin/rescript-tools.exe", + "rescript.exe": "./bin/rescript.exe", + "rewatch.exe": "./bin/rewatch.exe" }, "exports": { "./paths": "./bin/paths.js" - } + }, + "preferUnplugged": true } diff --git a/packages/@rescript/win32-x64/bin/bsb_helper.exe b/packages/@rescript/win32-x64/bin/bsb_helper.exe new file mode 120000 index 0000000000..f6689c2499 --- /dev/null +++ b/packages/@rescript/win32-x64/bin/bsb_helper.exe @@ -0,0 +1 @@ +../../../../win32/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/bsc.exe b/packages/@rescript/win32-x64/bin/bsc.exe new file mode 120000 index 0000000000..b7c26a48f5 --- /dev/null +++ b/packages/@rescript/win32-x64/bin/bsc.exe @@ -0,0 +1 @@ +../../../../win32/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/ninja.exe b/packages/@rescript/win32-x64/bin/ninja.exe new file mode 120000 index 0000000000..142672ef14 --- /dev/null +++ b/packages/@rescript/win32-x64/bin/ninja.exe @@ -0,0 +1 @@ +../../../../win32/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/paths.js b/packages/@rescript/win32-x64/bin/paths.js new file mode 100644 index 0000000000..21528b8692 --- /dev/null +++ b/packages/@rescript/win32-x64/bin/paths.js @@ -0,0 +1,20 @@ +// @ts-check + +import * as path from "node:path"; + +export const platformDir = import.meta.dirname; + +export const bsc_exe = path.join(platformDir, "bsc.exe"); + +export const ninja_exe = path.join(platformDir, "ninja.exe"); + +export const rescript_exe = path.join(platformDir, "rescript.exe"); + +export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); + +export const rescript_editor_analysis_exe = path.join( + platformDir, + "rescript-editor-analysis.exe", +); + +export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/win32-x64/bin/rescript-editor-analysis.exe b/packages/@rescript/win32-x64/bin/rescript-editor-analysis.exe new file mode 120000 index 0000000000..e6b72e0276 --- /dev/null +++ b/packages/@rescript/win32-x64/bin/rescript-editor-analysis.exe @@ -0,0 +1 @@ +../../../../win32/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/rescript-tools.exe b/packages/@rescript/win32-x64/bin/rescript-tools.exe new file mode 120000 index 0000000000..ad556f4805 --- /dev/null +++ b/packages/@rescript/win32-x64/bin/rescript-tools.exe @@ -0,0 +1 @@ +../../../../win32/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/rescript.exe b/packages/@rescript/win32-x64/bin/rescript.exe new file mode 120000 index 0000000000..4854360bd6 --- /dev/null +++ b/packages/@rescript/win32-x64/bin/rescript.exe @@ -0,0 +1 @@ +../../../../win32/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/rewatch.exe b/packages/@rescript/win32-x64/bin/rewatch.exe new file mode 120000 index 0000000000..a4279c1084 --- /dev/null +++ b/packages/@rescript/win32-x64/bin/rewatch.exe @@ -0,0 +1 @@ +../../../../win32/rewatch.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/package.json b/packages/@rescript/win32-x64/package.json new file mode 100644 index 0000000000..d0de947fe1 --- /dev/null +++ b/packages/@rescript/win32-x64/package.json @@ -0,0 +1,38 @@ +{ + "name": "@rescript/win32-x64", + "version": "12.0.0-alpha.12", + "description": "ReScript binaries for Windows x86_64", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "files": [ + "bin" + ], + "bin": { + "bsb_helper.exe": "./bin/bsb_helper.exe", + "bsc.exe": "./bin/bsc.exe", + "ninja.exe": "./bin/ninja.exe", + "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", + "rescript-tools.exe": "./bin/rescript-tools.exe", + "rescript.exe": "./bin/rescript.exe", + "rewatch.exe": "./bin/rewatch.exe" + }, + "exports": { + "./paths": "./bin/paths.js" + }, + "preferUnplugged": true +} diff --git a/scripts/copyExes.js b/scripts/copyExes.js index e7c443fd19..08d81bea7b 100755 --- a/scripts/copyExes.js +++ b/scripts/copyExes.js @@ -7,7 +7,7 @@ import * as child_process from "node:child_process"; import * as fs from "node:fs"; import * as path from "node:path"; -import { platformDir } from "#cli/bins"; +import { platformDir } from "#dev/paths"; import { compilerBinDir, ninjaDir, rewatchDir } from "#dev/paths"; fs.mkdirSync(platformDir, { recursive: true }); diff --git a/tsconfig.json b/tsconfig.json index 3778657f66..a085cc4138 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "lib/*", "lib_dev/*", "scripts/*", + "packages/**", "tests/**/input.js", ".github/workflows/*.js", "package.json" diff --git a/yarn.lock b/yarn.lock index f0cea874bf..e49e90d9ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -388,15 +388,59 @@ __metadata: languageName: node linkType: hard -"@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64": +"@rescript/darwin-arm64@npm:12.0.0-alpha.12, @rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64": + version: 0.0.0-use.local + resolution: "@rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64" + bin: + bsb_helper.exe: ./bin/bsb_helper.exe + bsc.exe: ./bin/bsc.exe + ninja.exe: ./bin/ninja.exe + rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe + rescript-tools.exe: ./bin/rescript-tools.exe + rescript.exe: ./bin/rescript.exe + rewatch.exe: ./bin/rewatch.exe + languageName: unknown + linkType: soft + +"@rescript/darwin-x64@npm:12.0.0-alpha.12, @rescript/darwin-x64@workspace:packages/@rescript/darwin-x64": + version: 0.0.0-use.local + resolution: "@rescript/darwin-x64@workspace:packages/@rescript/darwin-x64" + bin: + bsb_helper.exe: ./bin/bsb_helper.exe + bsc.exe: ./bin/bsc.exe + ninja.exe: ./bin/ninja.exe + rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe + rescript-tools.exe: ./bin/rescript-tools.exe + rescript.exe: ./bin/rescript.exe + rewatch.exe: ./bin/rewatch.exe + languageName: unknown + linkType: soft + +"@rescript/linux-arm64@npm:12.0.0-alpha.12, @rescript/linux-arm64@workspace:packages/@rescript/linux-arm64": version: 0.0.0-use.local resolution: "@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64" + bin: + bsb_helper.exe: ./bin/bsb_helper.exe + bsc.exe: ./bin/bsc.exe + ninja.exe: ./bin/ninja.exe + rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe + rescript-tools.exe: ./bin/rescript-tools.exe + rescript.exe: ./bin/rescript.exe + rewatch.exe: ./bin/rewatch.exe languageName: unknown linkType: soft -"@rescript/linux-x64@workspace:packages/@rescript/linux-x64": +"@rescript/linux-x64@npm:12.0.0-alpha.12, @rescript/linux-x64@workspace:packages/@rescript/linux-x64": version: 0.0.0-use.local resolution: "@rescript/linux-x64@workspace:packages/@rescript/linux-x64" + bin: + bsb_helper.exe: ./bin/bsb_helper.exe + bsc.exe: ./bin/bsc.exe + ninja.exe: ./bin/ninja.exe + rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe + rescript-tools.exe: ./bin/rescript-tools.exe + rescript.exe: ./bin/rescript.exe + rewatch.exe: ./bin/rewatch.exe languageName: unknown linkType: soft @@ -440,6 +484,20 @@ __metadata: languageName: unknown linkType: soft +"@rescript/win32-x64@npm:12.0.0-alpha.12, @rescript/win32-x64@workspace:packages/@rescript/win32-x64": + version: 0.0.0-use.local + resolution: "@rescript/win32-x64@workspace:packages/@rescript/win32-x64" + bin: + bsb_helper.exe: ./bin/bsb_helper.exe + bsc.exe: ./bin/bsc.exe + ninja.exe: ./bin/ninja.exe + rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe + rescript-tools.exe: ./bin/rescript-tools.exe + rescript.exe: ./bin/rescript.exe + rewatch.exe: ./bin/rewatch.exe + languageName: unknown + linkType: soft + "@rollup/plugin-node-resolve@npm:^16.0.0": version: 16.0.1 resolution: "@rollup/plugin-node-resolve@npm:16.0.1" @@ -2457,12 +2515,28 @@ __metadata: resolution: "rescript@workspace:." dependencies: "@biomejs/biome": "npm:1.9.4" + "@rescript/darwin-arm64": "npm:12.0.0-alpha.12" + "@rescript/darwin-x64": "npm:12.0.0-alpha.12" + "@rescript/linux-arm64": "npm:12.0.0-alpha.12" + "@rescript/linux-x64": "npm:12.0.0-alpha.12" + "@rescript/win32-x64": "npm:12.0.0-alpha.12" "@types/node": "npm:^20.14.9" "@types/semver": "npm:^7.5.8" mocha: "npm:10.8.2" nyc: "npm:15.0.0" semver: "npm:7.6.2" typescript: "npm:5.8.2" + dependenciesMeta: + "@rescript/darwin-arm64": + optional: true + "@rescript/darwin-x64": + optional: true + "@rescript/linux-arm64": + optional: true + "@rescript/linux-x64": + optional: true + "@rescript/win32-x64": + optional: true bin: bsc: cli/bsc.js bstracing: cli/bstracing.js From dda6eae846e69ed250561efc550d4b7d73144323 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Tue, 15 Apr 2025 09:14:21 +0900 Subject: [PATCH 03/34] fix gentype makefile --- tests/gentype_tests/typescript-react-example/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/gentype_tests/typescript-react-example/Makefile b/tests/gentype_tests/typescript-react-example/Makefile index 5062da0431..a38ce95510 100644 --- a/tests/gentype_tests/typescript-react-example/Makefile +++ b/tests/gentype_tests/typescript-react-example/Makefile @@ -1,9 +1,9 @@ SHELL = /bin/bash test: - npm run check - npm run build - npm run typecheck + yarn check + yarn build + yarn typecheck @git diff --quiet src/ \ || { echo; echo "Please review the Gentype outputs too!"; echo; false; } \ || exit 1 From 3458e98b28ca0e3b1819cc7ae9b2a825592eba36 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 04:17:38 +0900 Subject: [PATCH 04/34] change binary package exports --- cli/common/bins.js | 37 +++++++++++--------- package.json | 3 +- packages/@rescript/darwin-arm64/bin.js | 17 +++++++++ packages/@rescript/darwin-arm64/bin/paths.js | 20 ----------- packages/@rescript/darwin-arm64/package.json | 7 ++-- packages/@rescript/darwin-x64/bin.js | 17 +++++++++ packages/@rescript/darwin-x64/bin/paths.js | 20 ----------- packages/@rescript/darwin-x64/package.json | 7 ++-- packages/@rescript/linux-arm64/bin.js | 17 +++++++++ packages/@rescript/linux-arm64/bin/paths.js | 20 ----------- packages/@rescript/linux-arm64/package.json | 7 ++-- packages/@rescript/linux-x64/bin.js | 17 +++++++++ packages/@rescript/linux-x64/bin/paths.js | 20 ----------- packages/@rescript/linux-x64/package.json | 7 ++-- packages/@rescript/win32-x64/bin.js | 17 +++++++++ packages/@rescript/win32-x64/bin/paths.js | 20 ----------- packages/@rescript/win32-x64/package.json | 7 ++-- 17 files changed, 123 insertions(+), 137 deletions(-) create mode 100644 packages/@rescript/darwin-arm64/bin.js delete mode 100644 packages/@rescript/darwin-arm64/bin/paths.js create mode 100644 packages/@rescript/darwin-x64/bin.js delete mode 100644 packages/@rescript/darwin-x64/bin/paths.js create mode 100644 packages/@rescript/linux-arm64/bin.js delete mode 100644 packages/@rescript/linux-arm64/bin/paths.js create mode 100644 packages/@rescript/linux-x64/bin.js delete mode 100644 packages/@rescript/linux-x64/bin/paths.js create mode 100644 packages/@rescript/win32-x64/bin.js delete mode 100644 packages/@rescript/win32-x64/bin/paths.js diff --git a/cli/common/bins.js b/cli/common/bins.js index a0f36dca66..3a36d5b168 100644 --- a/cli/common/bins.js +++ b/cli/common/bins.js @@ -2,7 +2,11 @@ /** * @typedef {{ - * platformDir: string, + * binDir: string, + * binPaths: BinaryPaths, + * }} BinaryModuleExports + * + * @typedef {{ * bsb_helper_exe: string, * bsc_exe: string, * ninja_exe: string, @@ -15,22 +19,23 @@ const target = `${process.platform}-${process.arch}`; -/** @type {BinaryPaths} */ -let binPaths; +/** @type {BinaryModuleExports} */ +let mod; try { - binPaths = await import(`@rescript/${target}/paths`); -} catch (err) { - console.error(`Platform ${target} is not supported!`); - throw err; + mod = await import(`@rescript/${target}`); +} catch { + throw new Error(`Platform ${target} is not supported!`); } export const { - platformDir, - bsb_helper_exe, - bsc_exe, - ninja_exe, - rescript_editor_analysis_exe, - rescript_tools_exe, - rescript_exe, - rewatch_exe, -} = binPaths; + binDir: platformDir, + binPaths: { + bsb_helper_exe, + bsc_exe, + ninja_exe, + rescript_editor_analysis_exe, + rescript_tools_exe, + rescript_exe, + rewatch_exe, + }, +} = mod; diff --git a/package.json b/package.json index 5a47315a3d..1674bf9729 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "CREDITS.md", "ninja.COPYING", "docs/docson/build-schema.json", - "lib", + "lib/js/*.js", + "lib/es6/*.js", "cli" ], "exports": { diff --git a/packages/@rescript/darwin-arm64/bin.js b/packages/@rescript/darwin-arm64/bin.js new file mode 100644 index 0000000000..14665a6945 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin.js @@ -0,0 +1,17 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/darwin-arm64/bin/paths.js b/packages/@rescript/darwin-arm64/bin/paths.js deleted file mode 100644 index 21528b8692..0000000000 --- a/packages/@rescript/darwin-arm64/bin/paths.js +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-check - -import * as path from "node:path"; - -export const platformDir = import.meta.dirname; - -export const bsc_exe = path.join(platformDir, "bsc.exe"); - -export const ninja_exe = path.join(platformDir, "ninja.exe"); - -export const rescript_exe = path.join(platformDir, "rescript.exe"); - -export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); - -export const rescript_editor_analysis_exe = path.join( - platformDir, - "rescript-editor-analysis.exe", -); - -export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/darwin-arm64/package.json b/packages/@rescript/darwin-arm64/package.json index ccb4dcaa96..721d14162e 100644 --- a/packages/@rescript/darwin-arm64/package.json +++ b/packages/@rescript/darwin-arm64/package.json @@ -20,7 +20,8 @@ "arm64" ], "files": [ - "bin" + "bin.js", + "bin/" ], "bin": { "bsb_helper.exe": "./bin/bsb_helper.exe", @@ -31,8 +32,6 @@ "rescript.exe": "./bin/rescript.exe", "rewatch.exe": "./bin/rewatch.exe" }, - "exports": { - "./paths": "./bin/paths.js" - }, + "exports": "./bin.js", "preferUnplugged": true } diff --git a/packages/@rescript/darwin-x64/bin.js b/packages/@rescript/darwin-x64/bin.js new file mode 100644 index 0000000000..14665a6945 --- /dev/null +++ b/packages/@rescript/darwin-x64/bin.js @@ -0,0 +1,17 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/darwin-x64/bin/paths.js b/packages/@rescript/darwin-x64/bin/paths.js deleted file mode 100644 index 21528b8692..0000000000 --- a/packages/@rescript/darwin-x64/bin/paths.js +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-check - -import * as path from "node:path"; - -export const platformDir = import.meta.dirname; - -export const bsc_exe = path.join(platformDir, "bsc.exe"); - -export const ninja_exe = path.join(platformDir, "ninja.exe"); - -export const rescript_exe = path.join(platformDir, "rescript.exe"); - -export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); - -export const rescript_editor_analysis_exe = path.join( - platformDir, - "rescript-editor-analysis.exe", -); - -export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/darwin-x64/package.json b/packages/@rescript/darwin-x64/package.json index fc69f03a54..bf2482a334 100644 --- a/packages/@rescript/darwin-x64/package.json +++ b/packages/@rescript/darwin-x64/package.json @@ -20,7 +20,8 @@ "x64" ], "files": [ - "bin" + "bin.js", + "bin/" ], "bin": { "bsb_helper.exe": "./bin/bsb_helper.exe", @@ -31,8 +32,6 @@ "rescript.exe": "./bin/rescript.exe", "rewatch.exe": "./bin/rewatch.exe" }, - "exports": { - "./paths": "./bin/paths.js" - }, + "exports": "./bin.js", "preferUnplugged": true } diff --git a/packages/@rescript/linux-arm64/bin.js b/packages/@rescript/linux-arm64/bin.js new file mode 100644 index 0000000000..14665a6945 --- /dev/null +++ b/packages/@rescript/linux-arm64/bin.js @@ -0,0 +1,17 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/linux-arm64/bin/paths.js b/packages/@rescript/linux-arm64/bin/paths.js deleted file mode 100644 index 21528b8692..0000000000 --- a/packages/@rescript/linux-arm64/bin/paths.js +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-check - -import * as path from "node:path"; - -export const platformDir = import.meta.dirname; - -export const bsc_exe = path.join(platformDir, "bsc.exe"); - -export const ninja_exe = path.join(platformDir, "ninja.exe"); - -export const rescript_exe = path.join(platformDir, "rescript.exe"); - -export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); - -export const rescript_editor_analysis_exe = path.join( - platformDir, - "rescript-editor-analysis.exe", -); - -export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/linux-arm64/package.json b/packages/@rescript/linux-arm64/package.json index 37ddaedf27..72a844b48e 100644 --- a/packages/@rescript/linux-arm64/package.json +++ b/packages/@rescript/linux-arm64/package.json @@ -20,7 +20,8 @@ "arm64" ], "files": [ - "bin" + "bin.js", + "bin/" ], "bin": { "bsb_helper.exe": "./bin/bsb_helper.exe", @@ -31,8 +32,6 @@ "rescript.exe": "./bin/rescript.exe", "rewatch.exe": "./bin/rewatch.exe" }, - "exports": { - "./paths": "./bin/paths.js" - }, + "exports": "./bin.js", "preferUnplugged": true } diff --git a/packages/@rescript/linux-x64/bin.js b/packages/@rescript/linux-x64/bin.js new file mode 100644 index 0000000000..14665a6945 --- /dev/null +++ b/packages/@rescript/linux-x64/bin.js @@ -0,0 +1,17 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/linux-x64/bin/paths.js b/packages/@rescript/linux-x64/bin/paths.js deleted file mode 100644 index 21528b8692..0000000000 --- a/packages/@rescript/linux-x64/bin/paths.js +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-check - -import * as path from "node:path"; - -export const platformDir = import.meta.dirname; - -export const bsc_exe = path.join(platformDir, "bsc.exe"); - -export const ninja_exe = path.join(platformDir, "ninja.exe"); - -export const rescript_exe = path.join(platformDir, "rescript.exe"); - -export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); - -export const rescript_editor_analysis_exe = path.join( - platformDir, - "rescript-editor-analysis.exe", -); - -export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/linux-x64/package.json b/packages/@rescript/linux-x64/package.json index 5181ea0817..0c6ac1c90b 100644 --- a/packages/@rescript/linux-x64/package.json +++ b/packages/@rescript/linux-x64/package.json @@ -20,7 +20,8 @@ "x64" ], "files": [ - "bin" + "bin.js", + "bin/" ], "bin": { "bsb_helper.exe": "./bin/bsb_helper.exe", @@ -31,8 +32,6 @@ "rescript.exe": "./bin/rescript.exe", "rewatch.exe": "./bin/rewatch.exe" }, - "exports": { - "./paths": "./bin/paths.js" - }, + "exports": "./bin.js", "preferUnplugged": true } diff --git a/packages/@rescript/win32-x64/bin.js b/packages/@rescript/win32-x64/bin.js new file mode 100644 index 0000000000..14665a6945 --- /dev/null +++ b/packages/@rescript/win32-x64/bin.js @@ -0,0 +1,17 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/win32-x64/bin/paths.js b/packages/@rescript/win32-x64/bin/paths.js deleted file mode 100644 index 21528b8692..0000000000 --- a/packages/@rescript/win32-x64/bin/paths.js +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-check - -import * as path from "node:path"; - -export const platformDir = import.meta.dirname; - -export const bsc_exe = path.join(platformDir, "bsc.exe"); - -export const ninja_exe = path.join(platformDir, "ninja.exe"); - -export const rescript_exe = path.join(platformDir, "rescript.exe"); - -export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); - -export const rescript_editor_analysis_exe = path.join( - platformDir, - "rescript-editor-analysis.exe", -); - -export const rewatch_exe = path.join(platformDir, "rewatch.exe"); diff --git a/packages/@rescript/win32-x64/package.json b/packages/@rescript/win32-x64/package.json index d0de947fe1..5148531286 100644 --- a/packages/@rescript/win32-x64/package.json +++ b/packages/@rescript/win32-x64/package.json @@ -20,7 +20,8 @@ "x64" ], "files": [ - "bin" + "bin.js", + "bin/" ], "bin": { "bsb_helper.exe": "./bin/bsb_helper.exe", @@ -31,8 +32,6 @@ "rescript.exe": "./bin/rescript.exe", "rewatch.exe": "./bin/rewatch.exe" }, - "exports": { - "./paths": "./bin/paths.js" - }, + "exports": "./bin.js", "preferUnplugged": true } From 4762a8c5a42af2935a4be6f19b19cc33ee0748ab Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 04:26:12 +0900 Subject: [PATCH 05/34] use yarn pack --- lib/.npmignore | 5 -- lib_dev/paths.js | 9 +++ package.json | 5 +- packages/artifacts.txt | 37 +----------- scripts/npmPack.js | 131 +++++++++++++++++++---------------------- tools/CHANGELOG.md | 86 --------------------------- 6 files changed, 74 insertions(+), 199 deletions(-) delete mode 100644 lib/.npmignore delete mode 100644 tools/CHANGELOG.md diff --git a/lib/.npmignore b/lib/.npmignore deleted file mode 100644 index e5a0bac212..0000000000 --- a/lib/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -*.o -*.log -*.ninja -.ninja_log -bs/.project-files-cache \ No newline at end of file diff --git a/lib_dev/paths.js b/lib_dev/paths.js index e6cb44a980..bea6951252 100644 --- a/lib_dev/paths.js +++ b/lib_dev/paths.js @@ -83,6 +83,15 @@ export const compilerVersionFile = path.resolve( "bs_version.ml", ); +/** + * path: `/packages/artifacts.txt` + */ +export const artifactListFile = path.resolve( + projectDir, + "packages", + "artifacts.txt", +); + /** * path: `/_build/install/default/bin/` */ diff --git a/package.json b/package.json index 1674bf9729..7b8c1f5a3a 100644 --- a/package.json +++ b/package.json @@ -56,11 +56,12 @@ }, "files": [ "CHANGELOG.md", + "COPYING", + "COPYING.LESSER", "CREDITS.md", "ninja.COPYING", "docs/docson/build-schema.json", - "lib/js/*.js", - "lib/es6/*.js", + "lib", "cli" ], "exports": { diff --git a/packages/artifacts.txt b/packages/artifacts.txt index adfa893f3b..0f2acf1aee 100644 --- a/packages/artifacts.txt +++ b/packages/artifacts.txt @@ -14,20 +14,6 @@ cli/rescript.js cli/rescript/dump.js cli/rescript/format.js cli/rewatch.js -darwin/bsb_helper.exe -darwin/bsc.exe -darwin/ninja.exe -darwin/rescript-editor-analysis.exe -darwin/rescript-tools.exe -darwin/rescript.exe -darwin/rewatch.exe -darwinarm64/bsb_helper.exe -darwinarm64/bsc.exe -darwinarm64/ninja.exe -darwinarm64/rescript-editor-analysis.exe -darwinarm64/rescript-tools.exe -darwinarm64/rescript.exe -darwinarm64/rewatch.exe docs/docson/build-schema.json lib/es6/Belt.js lib/es6/Belt_Array.js @@ -1227,26 +1213,5 @@ lib/ocaml/Stdlib_WeakSet.cmi lib/ocaml/Stdlib_WeakSet.cmj lib/ocaml/Stdlib_WeakSet.cmt lib/ocaml/Stdlib_WeakSet.res -linux/bsb_helper.exe -linux/bsc.exe -linux/ninja.exe -linux/rescript-editor-analysis.exe -linux/rescript-tools.exe -linux/rescript.exe -linux/rewatch.exe -linuxarm64/bsb_helper.exe -linuxarm64/bsc.exe -linuxarm64/ninja.exe -linuxarm64/rescript-editor-analysis.exe -linuxarm64/rescript-tools.exe -linuxarm64/rescript.exe -linuxarm64/rewatch.exe -ninja.COPYING +ninja/COPYING package.json -win32/bsb_helper.exe -win32/bsc.exe -win32/ninja.exe -win32/rescript-editor-analysis.exe -win32/rescript-tools.exe -win32/rescript.exe -win32/rewatch.exe \ No newline at end of file diff --git a/scripts/npmPack.js b/scripts/npmPack.js index 5d620bdddc..0e9c35fd2e 100755 --- a/scripts/npmPack.js +++ b/scripts/npmPack.js @@ -2,89 +2,80 @@ // @ts-check -// NOTE: -// We cannot use `yarn pack` since we need to set our OCaml binaries executable. -// Yarn (Berry) only allow `bin` to be executable, wouldn't preserve permission bits. - -// This performs `npm pack` and retrieves the list of artifact files from the output. +// This performs `yarn pack` and retrieves the list of artifact files from the output. // -// In local dev, invoke it with `-updateArtifactList` to perform a dry run of `npm pack` +// In local dev, invoke it with `-updateArtifactList` to perform a dry run of `yarn pack` // and recreate `packages/artifacts.txt`. -// The exes for all platforms will then be included in the list, even if not present locally. // -// In CI, the scripts is invoked without options. It then performs `npm pack` for real, +// In CI, the scripts is invoked without options. It then performs `yarn pack` for real, // recreates the artifact list and verifies that it has no changes compared to the committed state. -/** - * @typedef {{ - * path: string, - * size: number, - * mode: number, - * }} PackOutputFile - * - * @typedef {{ - * files: PackOutputFile[], - * entryCount: number, - * bundled: unknown[], - * }} PackOutputEntry - * - * @typedef {[PackOutputEntry]} PackOutput +import { spawn, execSync } from "node:child_process"; +import fs from "node:fs"; +import { parseArgs } from "node:util"; +import { artifactListFile } from "#dev/paths"; + +/** + * @typedef {( + * | { "base": string } + * | { "location": string } + * | { "output": string } + * )} YarnPackOutputLine */ -import { execSync, spawnSync } from "node:child_process"; -import fs from "node:fs"; -import path from "node:path"; -import { projectDir } from "#dev/paths"; +const { values } = parseArgs({ + args: process.argv.slice(2), + options: { + updateArtifactList: { + type: "boolean", + short: "u", + }, + }, +}); -const mode = process.argv.includes("-updateArtifactList") +const mode = values.updateArtifactList ? "updateArtifactList" : "package"; -const fileListPath = path.join(projectDir, "packages", "artifacts.txt"); - -const output = spawnSync( - `npm pack --json${mode === "updateArtifactList" ? " --dry-run" : ""}`, - { - cwd: projectDir, - encoding: "utf8", - shell: true, - }, -).stdout; - -/** @type {PackOutput} */ -const parsedOutput = JSON.parse(output); -let filePaths = parsedOutput[0].files.map(file => file.path); - -if (mode === "updateArtifactList") { - filePaths = Array.from(new Set(filePaths.concat(getFilesAddedByCI()))); +const child = spawn( + "yarn", + [ + "workspace", + "rescript", + "pack", + "--json", + mode === "updateArtifactList" ? "--dry-run" : "", + ].filter(Boolean), +); +const exitCode = new Promise((resolve, reject) => { + child.once("error", reject); + child.once("close", code => resolve(code)); +}); + +fs.unlinkSync(artifactListFile); + +for await (const chunk of child.stdout.setEncoding("utf8")) { + const lines = /** @type {string} */ (chunk).trim().split(/\s/); + for (const line of lines) { + /** @type {YarnPackOutputLine} */ + const json = JSON.parse(line); + if ("location" in json) { + // Workaround for false positive reports + // See https://github.com/yarnpkg/berry/issues/6766 + if (json.location.startsWith("_build")) { + continue; + } + fs.appendFileSync( + artifactListFile, + json.location + "\n", + "utf8", + ); + } + } } -filePaths.sort(); -fs.writeFileSync(fileListPath, filePaths.join("\n")); +await exitCode; if (mode === "package") { - execSync(`git diff --exit-code ${fileListPath}`, { stdio: "inherit" }); -} - -function getFilesAddedByCI() { - const platforms = ["darwin", "darwinarm64", "linux", "linuxarm64", "win32"]; - const exes = [ - "bsb_helper.exe", - "bsc.exe", - "ninja.exe", - "rescript.exe", - "rescript-editor-analysis.exe", - "rescript-tools.exe", - "rewatch.exe", - ]; - - const files = ["ninja.COPYING"]; - - for (const platform of platforms) { - for (const exe of exes) { - files.push(`${platform}/${exe}`); - } - } - - return files; + execSync(`git diff --exit-code ${artifactListFile}`, { stdio: "inherit" }); } diff --git a/tools/CHANGELOG.md b/tools/CHANGELOG.md deleted file mode 100644 index 401adf5f6a..0000000000 --- a/tools/CHANGELOG.md +++ /dev/null @@ -1,86 +0,0 @@ -# Changelog - -> **Tags:** -> -> - :boom: [Breaking Change] -> - :eyeglasses: [Spec Compliance] -> - :rocket: [New Feature] -> - :bug: [Bug Fix] -> - :memo: [Documentation] -> - :house: [Internal] -> - :nail_care: [Polish] - -## master - -## 0.6.4 - -#### :rocket: New Feature - -- Add `moduletypeid` field for explicitly annotated module type. https://github.com/rescript-lang/rescript-vscode/pull/1019 - -### :bug: Bug Fix - -- Print module structure with signature to module path. https://github.com/rescript-lang/rescript-vscode/pull/1018 - -## 0.6.3 - -#### :bug: Bug Fix - -- Make sure Linux binaries are statically linked. - -#### :nail_care: Polish - -- Reverse order of extracted embeds, so they're in the correct order. - -## 0.6.2 - -#### :rocket: New Feature - -- Ship Linux ARM64 binaries. - -## 0.6.1 - -#### :rocket: New Feature - -- Expose `getBinaryPath` JS function that you can import to get the binary to call for the current platform. - -## 0.6.0 - -#### :rocket: New Feature - -- _internal_ Add experimental command for extracting (string) contents from extension points. - -## 0.5.0 - -#### :rocket: New Feature - -- Add `source` property to type, value, module and module alias. https://github.com/rescript-lang/rescript-vscode/pull/900. - -#### :bug: Bug Fix - -- Print docstrings for nested submodules. https://github.com/rescript-lang/rescript-vscode/pull/897 -- Print `deprecated` field for module. https://github.com/rescript-lang/rescript-vscode/pull/897 - -## 0.4.0 - -#### :bug: Bug Fix - -- Support inline record fields in constructors. https://github.com/rescript-lang/rescript-vscode/pull/889 -- Fix docstrings for module alias. Get internal docstrings of module file. https://github.com/rescript-lang/rescript-vscode/pull/878 -- Fix extracted docs of types include escaped linebreaks in signature. https://github.com/rescript-lang/rescript-vscode/pull/891 - -## 0.3.0 - -#### :rocket: New Feature - -- Expose more `decode` functions. https://github.com/rescript-lang/rescript-vscode/pull/866 - -#### :house: [Internal] - -- Add env var `FROM_COMPILER` to extract docstrings from compiler repo. https://github.com/rescript-lang/rescript-vscode/pull/868 - -#### :bug: Bug Fix - -- Fix tagged variant for `Module` and add attr to interface files. https://github.com/rescript-lang/rescript-vscode/pull/866 -- Fix `rescript-tools --version` command. https://github.com/rescript-lang/rescript-vscode/pull/873 -- Fix output truncate when run `rescript-tools doc path/to/file.res` in a separate process. https://github.com/rescript-lang/rescript-vscode/pull/868 From 25571d73c410e11a4cbc388b5efad1a0e050efa7 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 05:37:28 +0900 Subject: [PATCH 06/34] upload platform artifacts --- .github/workflows/ci.yml | 59 +++++++++++-------- .../workflows}/moveArtifacts.sh | 30 +++++----- .github/workflows/prepare_package_upload.js | 29 ++++++++- .gitignore | 3 + 4 files changed, 79 insertions(+), 42 deletions(-) rename {scripts => .github/workflows}/moveArtifacts.sh (51%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8a0d4f3e0..ee20afb526 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -438,7 +438,7 @@ jobs: - build-compiler - build-rewatch - runs-on: ubuntu-24.04 + runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -447,29 +447,21 @@ jobs: - name: Use Node.js uses: actions/setup-node@v4 with: - cache: yarn node-version-file: .nvmrc - - name: NPM install - run: yarn install - - name: Download artifacts uses: actions/download-artifact@v4 with: pattern: "@(binaries-*|rewatch-*|lib-ocaml)" - - name: Move artifacts - run: ./scripts/moveArtifacts.sh + - name: Move artifacts into packages + run: .github/workflows/moveArtifacts.sh - - name: npm pack (rescript) + check artifact list + - name: Check artifact list run: node ./scripts/npmPack.js - - name: Copy JS files to stdlib package - run: mkdir -p packages/std/lib && cp -R lib/es6 lib/js packages/std/lib - - - name: npm pack (@rescript/std) - run: npm pack - working-directory: packages/std + - name: yarn pack @rescript/* subpackages + run: yarn workspaces foreach -W --no-private --exclude rescript pack - name: Prepare package upload # For pull requests, pass the correct commit SHA explicitly as GITHUB_SHA points to the wrong commit. @@ -482,6 +474,11 @@ jobs: path: | rescript-${{ env.rescript_version }}.tgz rescript-std-${{ env.rescript_version }}.tgz + rescript-linux-x64-${{ env.rescript_version }}.tgz + rescript-linux-arm64-${{ env.rescript_version }}.tgz + rescript-darwin-x64-${{ env.rescript_version }}.tgz + rescript-darwin-arm64-${{ env.rescript_version }}.tgz + rescript-win32-x64-${{ env.rescript_version }}.tgz outputs: rescript_version: ${{ env.rescript_version }} @@ -491,15 +488,19 @@ jobs: strategy: fail-fast: false matrix: - os: [ - macos-13, # x64 - macos-14, # ARM - ubuntu-24.04, - ubuntu-24.04-arm, - windows-latest, - ] + include: + - os: macos-13 # x64 + target: darwin-x64 + - os: macos-14 # ARM + target: darwin-arm64 + - os: ubuntu-24.04 + target: linux-x64 + - os: ubuntu-24.04-arm + target: linux-arm64 + - os: windows-latest + target: win32-x64 - runs-on: ${{matrix.os}} + runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -532,7 +533,8 @@ jobs: - name: Install ReScript package run: | npm i --ignore-scripts --no-audit \ - rescript-${{ needs.package.outputs.rescript_version }}.tgz + rescript-${{ needs.package.outputs.rescript_version }}.tgz \ + rescript-${{ matrix.target }}-${{ env.rescript_version }}.tgz shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} @@ -546,7 +548,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-24.04 + runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -568,8 +570,13 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} run: | - npm publish rescript-${{ needs.package.outputs.rescript_version }}.tgz --tag ci - npm publish rescript-std-${{ needs.package.outputs.rescript_version }}.tgz --tag ci + npm publish --tag ci rescript-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-std-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-linux-x64-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-linux-arm64-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-darwin-x64-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-darwin-arm64-{{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-win32-x64-${{ needs.package.outputs.rescript_version }}.tgz - name: Update Website Playground env: diff --git a/scripts/moveArtifacts.sh b/.github/workflows/moveArtifacts.sh similarity index 51% rename from scripts/moveArtifacts.sh rename to .github/workflows/moveArtifacts.sh index 54de7aaf76..a3bb4bf895 100755 --- a/scripts/moveArtifacts.sh +++ b/.github/workflows/moveArtifacts.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash + set -e check_statically_linked() { @@ -24,18 +25,19 @@ check_statically_linked() { fi } -chmod +x binaries-*/*.exe rewatch-*/*.exe - -mkdir darwin darwinarm64 linux linuxarm64 win32 - -mv binaries-darwin/* rewatch-darwin/* darwin -mv binaries-darwinarm64/* rewatch-darwinarm64/* darwinarm64 -mv binaries-linux/* rewatch-linux/* linux -mv binaries-linuxarm64/* rewatch-linuxarm64/* linuxarm64 -mv binaries-win32/* rewatch-win32/* win32 - +# rescript mv lib-ocaml lib/ocaml -mv ninja/COPYING ninja.COPYING -check_statically_linked "linux" -check_statically_linked "linuxarm64" +# @rescript/{target} +chmod +x binaries-*/*.exe rewatch-*/*.exe +mv -f binaries-darwin/* rewatch-darwin/* packages/@rescript/darwin-x64/bin +mv -f binaries-darwinarm64/* rewatch-darwinarm64/* packages/@rescript/darwin-arm64/bin +mv -f binaries-linux/* rewatch-linux/* packages/@rescript/linux-x64/bin +mv -f binaries-linuxarm64/* rewatch-linuxarm64/* packages/@rescript/linux-arm64/bin +mv -f binaries-win32/* rewatch-win32/* packages/@rescript/win32-x64/bin +check_statically_linked "packages/@rescript/linux-x64/bin" +check_statically_linked "packages/@rescript/linux-arm64/bin" + +# @rescript/std +mkdir -p packages/std/lib +cp -R lib/es6 lib/js packages/std/lib diff --git a/.github/workflows/prepare_package_upload.js b/.github/workflows/prepare_package_upload.js index 95caa889b0..45b7aa7a9d 100644 --- a/.github/workflows/prepare_package_upload.js +++ b/.github/workflows/prepare_package_upload.js @@ -10,15 +10,40 @@ const { version } = packageSpec; const commitHash = process.argv[2] || process.env.GITHUB_SHA; const commitHashShort = commitHash.substring(0, 7); +// rescript fs.renameSync( - `rescript-${version}.tgz`, + "package.tgz", `rescript-${version}-${commitHashShort}.tgz`, ); + +// @rescript/std fs.renameSync( - `packages/std/rescript-std-${version}.tgz`, + "packages/@rescript/std/package.tgz", `rescript-std-${version}-${commitHashShort}.tgz`, ); +// @rescript/{target} +fs.renameSync( + "packages/@rescript/linux-x64/package.tgz", + `rescript-linux-x64-${version}-${commitHashShort}.tgz`, +); +fs.renameSync( + "packages/@rescript/linux-arm64/package.tgz", + `rescript-linux-arm64-${version}-${commitHashShort}.tgz`, +); +fs.renameSync( + "packages/@rescript/darwin-x64/package.tgz", + `rescript-darwin-x64-${version}-${commitHashShort}.tgz`, +); +fs.renameSync( + "packages/@rescript/darwin-arm64/package.tgz", + `rescript-darwin-arm64-${version}-${commitHashShort}.tgz`, +); +fs.renameSync( + "packages/@rescript/win32-x64/package.tgz", + `rescript-win32-x64-${version}-${commitHashShort}.tgz`, +); + // Pass information to subsequent GitHub actions fs.appendFileSync( process.env.GITHUB_ENV, diff --git a/.gitignore b/.gitignore index 5f8b2363cb..dd35e63326 100644 --- a/.gitignore +++ b/.gitignore @@ -95,3 +95,6 @@ tests/analysis_tests/**/*.bs.js !.yarn/versions *.tsbuildinfo + +# package tarballs +package.tgz From dc2288b00c8f814a9afcf9f52b11d768a8c6c74f Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 05:39:18 +0900 Subject: [PATCH 07/34] fix format --- .github/workflows/prepare_package_upload.js | 7 ++----- cli/bstracing.js | 18 +++++++++--------- scripts/npmPack.js | 18 +++++++----------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/.github/workflows/prepare_package_upload.js b/.github/workflows/prepare_package_upload.js index 45b7aa7a9d..a2d59d4341 100644 --- a/.github/workflows/prepare_package_upload.js +++ b/.github/workflows/prepare_package_upload.js @@ -2,7 +2,7 @@ import * as fs from "node:fs"; import * as os from "node:os"; const packageSpec = JSON.parse( - fs.readFileSync(new URL("../../package.json", import.meta.url), "utf-8") + fs.readFileSync(new URL("../../package.json", import.meta.url), "utf-8"), ); const { version } = packageSpec; @@ -11,10 +11,7 @@ const commitHash = process.argv[2] || process.env.GITHUB_SHA; const commitHashShort = commitHash.substring(0, 7); // rescript -fs.renameSync( - "package.tgz", - `rescript-${version}-${commitHashShort}.tgz`, -); +fs.renameSync("package.tgz", `rescript-${version}-${commitHashShort}.tgz`); // @rescript/std fs.renameSync( diff --git a/cli/bstracing.js b/cli/bstracing.js index ad45f72c11..7eb661dbce 100755 --- a/cli/bstracing.js +++ b/cli/bstracing.js @@ -3,8 +3,8 @@ // @ts-check import * as fs from "node:fs"; -import * as readline from "node:readline"; import * as path from "node:path"; +import * as readline from "node:readline"; /** * @@ -14,10 +14,10 @@ import * as path from "node:path"; */ function processEntry(file, lineCb, finish) { const input = fs.createReadStream(file); - input.on("error", (error) => { + input.on("error", error => { console.error(error.message); console.error( - "make sure you are running after bsb building and in the top directory" + "make sure you are running after bsb building and in the top directory", ); process.exit(2); }); @@ -156,7 +156,7 @@ function category(target, obj) { } else { getColorName(obj, "cmj"); } - obj.name = target.targets.map((x) => path.parse(x).base).join(","); + obj.name = target.targets.map(x => path.parse(x).base).join(","); return obj; } /** @@ -173,7 +173,7 @@ function readIntervals(file, showAll, outputFile) { let offset = 0; processEntry( file, - (line) => { + line => { const lineTrim = line.trim(); if (lineTrim.startsWith("#")) { return; @@ -195,7 +195,7 @@ function readIntervals(file, showAll, outputFile) { setDefault( targets, cmdHash, - new Interval(Number(start) + offset, Number(end) + offset) + new Interval(Number(start) + offset, Number(end) + offset), ).targets.push(name); }, () => { @@ -213,12 +213,12 @@ function readIntervals(file, showAll, outputFile) { ts: target.start * 1000, tid: threads.alloc(target), args: {}, - }) + }), ); } console.log(` ${outputFile} is produced, loade it via chrome://tracing/`); fs.writeFileSync(outputFile, JSON.stringify(jsonArray), "utf8"); - } + }, ); } const logName = ".ninja_log"; @@ -240,7 +240,7 @@ function tryLocation(ps) { } } console.error( - "no .ninja_log found in specified paths, make sure you set bstracing to the proper directory" + "no .ninja_log found in specified paths, make sure you set bstracing to the proper directory", ); process.exit(2); } diff --git a/scripts/npmPack.js b/scripts/npmPack.js index 0e9c35fd2e..40d2821293 100755 --- a/scripts/npmPack.js +++ b/scripts/npmPack.js @@ -10,12 +10,12 @@ // In CI, the scripts is invoked without options. It then performs `yarn pack` for real, // recreates the artifact list and verifies that it has no changes compared to the committed state. -import { spawn, execSync } from "node:child_process"; +import { execSync, spawn } from "node:child_process"; import fs from "node:fs"; import { parseArgs } from "node:util"; import { artifactListFile } from "#dev/paths"; -/** +/** * @typedef {( * | { "base": string } * | { "location": string } @@ -33,9 +33,7 @@ const { values } = parseArgs({ }, }); -const mode = values.updateArtifactList - ? "updateArtifactList" - : "package"; +const mode = values.updateArtifactList ? "updateArtifactList" : "package"; const child = spawn( "yarn", @@ -55,7 +53,9 @@ const exitCode = new Promise((resolve, reject) => { fs.unlinkSync(artifactListFile); for await (const chunk of child.stdout.setEncoding("utf8")) { - const lines = /** @type {string} */ (chunk).trim().split(/\s/); + const lines = /** @type {string} */ (chunk) + .trim() + .split(/\s/); for (const line of lines) { /** @type {YarnPackOutputLine} */ const json = JSON.parse(line); @@ -65,11 +65,7 @@ for await (const chunk of child.stdout.setEncoding("utf8")) { if (json.location.startsWith("_build")) { continue; } - fs.appendFileSync( - artifactListFile, - json.location + "\n", - "utf8", - ); + fs.appendFileSync(artifactListFile, json.location + "\n", "utf8"); } } } From 5f1886d2b297a6f808570561b9f29a39aee9450b Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 05:57:12 +0900 Subject: [PATCH 08/34] fix flag --- Makefile | 2 +- scripts/npmPack.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 33c0293568..668141a7a9 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ lib: ./scripts/prebuilt.js artifacts: lib - ./scripts/npmPack.js -updateArtifactList + ./scripts/npmPack.js --updateArtifactList # Builds the core playground bundle (without the relevant cmijs files for the runtime) playground: diff --git a/scripts/npmPack.js b/scripts/npmPack.js index 40d2821293..41a4b100c0 100755 --- a/scripts/npmPack.js +++ b/scripts/npmPack.js @@ -4,7 +4,7 @@ // This performs `yarn pack` and retrieves the list of artifact files from the output. // -// In local dev, invoke it with `-updateArtifactList` to perform a dry run of `yarn pack` +// In local dev, invoke it with `--updateArtifactList` to perform a dry run of `yarn pack` // and recreate `packages/artifacts.txt`. // // In CI, the scripts is invoked without options. It then performs `yarn pack` for real, From 7f6526da013d3f86ad7096acb131a01aa06cb08d Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 06:24:07 +0900 Subject: [PATCH 09/34] suppress warnings from biome --- biome.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biome.json b/biome.json index aef80be170..836dc7c18c 100644 --- a/biome.json +++ b/biome.json @@ -65,12 +65,12 @@ "lib/es6/**", "lib/js/**", "ninja/**", - "packages/**", "playground/**", "*.bs.js", "*.res.js", "*.res.mjs", "*.gen.ts*", + "*.exe", "package.json" ] } From 8c4d743983ac19b5ae006e01222a25f5d4aae30a Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 06:36:30 +0900 Subject: [PATCH 10/34] expose bsb_helper path --- lib_dev/process.js | 21 +++++++++++++-------- packages/@rescript/darwin-arm64/bin.js | 1 + packages/@rescript/darwin-x64/bin.js | 1 + packages/@rescript/linux-arm64/bin.js | 1 + packages/@rescript/linux-x64/bin.js | 1 + packages/@rescript/win32-x64/bin.js | 1 + 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib_dev/process.js b/lib_dev/process.js index 444d28019a..651f97c1d9 100644 --- a/lib_dev/process.js +++ b/lib_dev/process.js @@ -1,4 +1,5 @@ import * as child_process from "node:child_process"; +import * as fs from "node:fs/promises"; import * as path from "node:path"; import { bsc_exe, rescript_exe } from "#cli/bins"; @@ -168,8 +169,9 @@ export function setup(cwd = process.cwd()) { * @param {ExecOptions} [options] * @return {Promise} */ - bsc(args = [], options = {}) { - return exec(bsc_exe, args, options); + async bsc(args = [], options = {}) { + const realPath = await fs.realpath(bsc_exe); + return exec(realPath, args, options); }, /** @@ -179,8 +181,9 @@ export function setup(cwd = process.cwd()) { * @param {ExecOptions} [options] * @return {Promise} */ - execBuild(args = [], options = {}) { - return exec(rescript_exe, ["build", ...args], options); + async execBuild(args = [], options = {}) { + const realPath = await fs.realpath(rescript_exe); + return exec(realPath, ["build", ...args], options); }, /** @@ -190,8 +193,9 @@ export function setup(cwd = process.cwd()) { * @param {ExecOptions} [options] * @return {Promise} */ - execClean(args = [], options = {}) { - return exec(rescript_exe, ["clean", ...args], options); + async execClean(args = [], options = {}) { + const realPath = await fs.realpath(rescript_exe); + return exec(realPath, ["clean", ...args], options); }, /** @@ -203,8 +207,9 @@ export function setup(cwd = process.cwd()) { * @param {ExecOptions} [options] * @return {Promise} */ - execBin(bin, args = [], options = {}) { - return exec(bin, args, options); + async execBin(bin, args = [], options = {}) { + const realPath = await fs.realpath(bin); + return exec(realPath, args, options); }, }; } diff --git a/packages/@rescript/darwin-arm64/bin.js b/packages/@rescript/darwin-arm64/bin.js index 14665a6945..0bae072013 100644 --- a/packages/@rescript/darwin-arm64/bin.js +++ b/packages/@rescript/darwin-arm64/bin.js @@ -5,6 +5,7 @@ import * as path from "node:path"; export const binDir = path.join(import.meta.dirname, "bin"); export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), bsc_exe: path.join(binDir, "bsc.exe"), ninja_exe: path.join(binDir, "ninja.exe"), rescript_exe: path.join(binDir, "rescript.exe"), diff --git a/packages/@rescript/darwin-x64/bin.js b/packages/@rescript/darwin-x64/bin.js index 14665a6945..0bae072013 100644 --- a/packages/@rescript/darwin-x64/bin.js +++ b/packages/@rescript/darwin-x64/bin.js @@ -5,6 +5,7 @@ import * as path from "node:path"; export const binDir = path.join(import.meta.dirname, "bin"); export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), bsc_exe: path.join(binDir, "bsc.exe"), ninja_exe: path.join(binDir, "ninja.exe"), rescript_exe: path.join(binDir, "rescript.exe"), diff --git a/packages/@rescript/linux-arm64/bin.js b/packages/@rescript/linux-arm64/bin.js index 14665a6945..0bae072013 100644 --- a/packages/@rescript/linux-arm64/bin.js +++ b/packages/@rescript/linux-arm64/bin.js @@ -5,6 +5,7 @@ import * as path from "node:path"; export const binDir = path.join(import.meta.dirname, "bin"); export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), bsc_exe: path.join(binDir, "bsc.exe"), ninja_exe: path.join(binDir, "ninja.exe"), rescript_exe: path.join(binDir, "rescript.exe"), diff --git a/packages/@rescript/linux-x64/bin.js b/packages/@rescript/linux-x64/bin.js index 14665a6945..0bae072013 100644 --- a/packages/@rescript/linux-x64/bin.js +++ b/packages/@rescript/linux-x64/bin.js @@ -5,6 +5,7 @@ import * as path from "node:path"; export const binDir = path.join(import.meta.dirname, "bin"); export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), bsc_exe: path.join(binDir, "bsc.exe"), ninja_exe: path.join(binDir, "ninja.exe"), rescript_exe: path.join(binDir, "rescript.exe"), diff --git a/packages/@rescript/win32-x64/bin.js b/packages/@rescript/win32-x64/bin.js index 14665a6945..0bae072013 100644 --- a/packages/@rescript/win32-x64/bin.js +++ b/packages/@rescript/win32-x64/bin.js @@ -5,6 +5,7 @@ import * as path from "node:path"; export const binDir = path.join(import.meta.dirname, "bin"); export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), bsc_exe: path.join(binDir, "bsc.exe"), ninja_exe: path.join(binDir, "ninja.exe"), rescript_exe: path.join(binDir, "rescript.exe"), From 821d4189b6782d682ce6baebfa1d56d0ebcc7aa1 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 07:25:26 +0900 Subject: [PATCH 11/34] compute realpath of binaries as needed --- cli/common/bins.js | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/cli/common/bins.js b/cli/common/bins.js index 3a36d5b168..5975a59322 100644 --- a/cli/common/bins.js +++ b/cli/common/bins.js @@ -1,5 +1,7 @@ // @ts-check +import * as fs from "node:fs"; + /** * @typedef {{ * binDir: string, @@ -27,15 +29,29 @@ try { throw new Error(`Platform ${target} is not supported!`); } +const binPaths = mod.binPaths; +// Compiler use symbolic links in the development process +if (fs.lstatSync(binPaths.rescript_exe).isSymbolicLink()) { + for (const [key, binPath] of Object.entries(binPaths)) { + try { + binPaths[/** @type {keyof BinaryPaths} */ (key)] = + fs.realpathSync(binPath); + } catch { + // Cannot populate the realpath of a binary, some tests may fails. + // + // But we don't report error here, + // so pass even some binaries are not built yet. + } + } +} + +export const platformDir = mod.binDir; export const { - binDir: platformDir, - binPaths: { - bsb_helper_exe, - bsc_exe, - ninja_exe, - rescript_editor_analysis_exe, - rescript_tools_exe, - rescript_exe, - rewatch_exe, - }, -} = mod; + bsb_helper_exe, + bsc_exe, + ninja_exe, + rescript_editor_analysis_exe, + rescript_tools_exe, + rescript_exe, + rewatch_exe, +} = binPaths; From 38bfc2db79d0955df063097317925ce78fc6e746 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 07:50:32 +0900 Subject: [PATCH 12/34] reduce lstats in tests --- lib_dev/process.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib_dev/process.js b/lib_dev/process.js index 651f97c1d9..c2d506b08b 100644 --- a/lib_dev/process.js +++ b/lib_dev/process.js @@ -169,9 +169,8 @@ export function setup(cwd = process.cwd()) { * @param {ExecOptions} [options] * @return {Promise} */ - async bsc(args = [], options = {}) { - const realPath = await fs.realpath(bsc_exe); - return exec(realPath, args, options); + bsc(args = [], options = {}) { + return exec(bsc_exe, args, options); }, /** @@ -181,9 +180,8 @@ export function setup(cwd = process.cwd()) { * @param {ExecOptions} [options] * @return {Promise} */ - async execBuild(args = [], options = {}) { - const realPath = await fs.realpath(rescript_exe); - return exec(realPath, ["build", ...args], options); + execBuild(args = [], options = {}) { + return exec(rescript_exe, ["build", ...args], options); }, /** @@ -193,9 +191,8 @@ export function setup(cwd = process.cwd()) { * @param {ExecOptions} [options] * @return {Promise} */ - async execClean(args = [], options = {}) { - const realPath = await fs.realpath(rescript_exe); - return exec(realPath, ["clean", ...args], options); + execClean(args = [], options = {}) { + return exec(rescript_exe, ["clean", ...args], options); }, /** From f2028c0f7b19b16d619354fab70ba4c85d73a203 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 07:56:20 +0900 Subject: [PATCH 13/34] exclude unintended path from packages --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b8c1f5a3a..3590d235e0 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,8 @@ "typescript": "5.8.2" }, "workspaces": [ - "packages/**", + "packages/*", + "packages/@rescript/*", "tests/dependencies/**", "tests/analysis_tests/**", "tests/gentype_tests/**", From 73435ef754619cbd5f8a615d268a49f5a0db4c9a Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 08:03:47 +0900 Subject: [PATCH 14/34] fix package script --- .github/workflows/prepare_package_upload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prepare_package_upload.js b/.github/workflows/prepare_package_upload.js index a2d59d4341..bf4f567b62 100644 --- a/.github/workflows/prepare_package_upload.js +++ b/.github/workflows/prepare_package_upload.js @@ -15,7 +15,7 @@ fs.renameSync("package.tgz", `rescript-${version}-${commitHashShort}.tgz`); // @rescript/std fs.renameSync( - "packages/@rescript/std/package.tgz", + "packages/std/package.tgz", `rescript-std-${version}-${commitHashShort}.tgz`, ); From 51d815a246916985315a286ba09af865f7e11a8d Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 08:11:48 +0900 Subject: [PATCH 15/34] fix installation test --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee20afb526..41e30f84a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -489,9 +489,9 @@ jobs: fail-fast: false matrix: include: - - os: macos-13 # x64 + - os: macos-13 target: darwin-x64 - - os: macos-14 # ARM + - os: macos-14 target: darwin-arm64 - os: ubuntu-24.04 target: linux-x64 @@ -534,7 +534,7 @@ jobs: run: | npm i --ignore-scripts --no-audit \ rescript-${{ needs.package.outputs.rescript_version }}.tgz \ - rescript-${{ matrix.target }}-${{ env.rescript_version }}.tgz + rescript-${{ matrix.target }}-${{ needs.package.outputs.rescript_version }}.tgz shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} From 27c6e67de65443cb2750c0fa211c22d413ddfe71 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 08:23:46 +0900 Subject: [PATCH 16/34] add typescript declarations --- biome.json | 1 + cli/common/bins.js | 16 ++-------------- packages/@rescript/darwin-arm64/bin.d.ts | 13 +++++++++++++ packages/@rescript/darwin-arm64/package.json | 1 + packages/@rescript/darwin-x64/bin.d.ts | 13 +++++++++++++ packages/@rescript/darwin-x64/package.json | 1 + packages/@rescript/linux-arm64/bin.d.ts | 13 +++++++++++++ packages/@rescript/linux-arm64/package.json | 1 + packages/@rescript/linux-x64/bin.d.ts | 13 +++++++++++++ packages/@rescript/linux-x64/package.json | 1 + packages/@rescript/win32-x64/bin.d.ts | 13 +++++++++++++ packages/@rescript/win32-x64/package.json | 1 + 12 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 packages/@rescript/darwin-arm64/bin.d.ts create mode 100644 packages/@rescript/darwin-x64/bin.d.ts create mode 100644 packages/@rescript/linux-arm64/bin.d.ts create mode 100644 packages/@rescript/linux-x64/bin.d.ts create mode 100644 packages/@rescript/win32-x64/bin.d.ts diff --git a/biome.json b/biome.json index 836dc7c18c..190824e65b 100644 --- a/biome.json +++ b/biome.json @@ -70,6 +70,7 @@ "*.res.js", "*.res.mjs", "*.gen.ts*", + "*.d.ts", "*.exe", "package.json" ] diff --git a/cli/common/bins.js b/cli/common/bins.js index 5975a59322..1351fb4e05 100644 --- a/cli/common/bins.js +++ b/cli/common/bins.js @@ -3,20 +3,8 @@ import * as fs from "node:fs"; /** - * @typedef {{ - * binDir: string, - * binPaths: BinaryPaths, - * }} BinaryModuleExports - * - * @typedef {{ - * bsb_helper_exe: string, - * bsc_exe: string, - * ninja_exe: string, - * rescript_exe: string, - * rescript_tools_exe: string, - * rescript_editor_analysis_exe: string, - * rewatch_exe: string, - * }} BinaryPaths + * @import {BinaryPaths} from "@rescript/linux-x64" + * @typedef {import("@rescript/linux-x64")} BinaryModuleExports */ const target = `${process.platform}-${process.arch}`; diff --git a/packages/@rescript/darwin-arm64/bin.d.ts b/packages/@rescript/darwin-arm64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/darwin-arm64/package.json b/packages/@rescript/darwin-arm64/package.json index 721d14162e..f5c2d71059 100644 --- a/packages/@rescript/darwin-arm64/package.json +++ b/packages/@rescript/darwin-arm64/package.json @@ -21,6 +21,7 @@ ], "files": [ "bin.js", + "bin.d.ts", "bin/" ], "bin": { diff --git a/packages/@rescript/darwin-x64/bin.d.ts b/packages/@rescript/darwin-x64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/darwin-x64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/darwin-x64/package.json b/packages/@rescript/darwin-x64/package.json index bf2482a334..41a4dc269f 100644 --- a/packages/@rescript/darwin-x64/package.json +++ b/packages/@rescript/darwin-x64/package.json @@ -21,6 +21,7 @@ ], "files": [ "bin.js", + "bin.d.ts", "bin/" ], "bin": { diff --git a/packages/@rescript/linux-arm64/bin.d.ts b/packages/@rescript/linux-arm64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/linux-arm64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/linux-arm64/package.json b/packages/@rescript/linux-arm64/package.json index 72a844b48e..3271739cd1 100644 --- a/packages/@rescript/linux-arm64/package.json +++ b/packages/@rescript/linux-arm64/package.json @@ -21,6 +21,7 @@ ], "files": [ "bin.js", + "bin.d.ts", "bin/" ], "bin": { diff --git a/packages/@rescript/linux-x64/bin.d.ts b/packages/@rescript/linux-x64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/linux-x64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/linux-x64/package.json b/packages/@rescript/linux-x64/package.json index 0c6ac1c90b..79b157d1e9 100644 --- a/packages/@rescript/linux-x64/package.json +++ b/packages/@rescript/linux-x64/package.json @@ -21,6 +21,7 @@ ], "files": [ "bin.js", + "bin.d.ts", "bin/" ], "bin": { diff --git a/packages/@rescript/win32-x64/bin.d.ts b/packages/@rescript/win32-x64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/win32-x64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/win32-x64/package.json b/packages/@rescript/win32-x64/package.json index 5148531286..5a309e8b82 100644 --- a/packages/@rescript/win32-x64/package.json +++ b/packages/@rescript/win32-x64/package.json @@ -21,6 +21,7 @@ ], "files": [ "bin.js", + "bin.d.ts", "bin/" ], "bin": { From 44f132aa441f10677596f9b6a42ac6eea5972f3f Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 09:07:44 +0900 Subject: [PATCH 17/34] tmp: search stdlib --- compiler/bsc/rescript_compiler_main.ml | 6 +----- compiler/ext/config.ml | 11 +++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/compiler/bsc/rescript_compiler_main.ml b/compiler/bsc/rescript_compiler_main.ml index 84c0a3f898..a5950f198e 100644 --- a/compiler/bsc/rescript_compiler_main.ml +++ b/compiler/bsc/rescript_compiler_main.ml @@ -185,11 +185,7 @@ let define_variable s = | _ -> Bsc_args.bad_arg ("illegal definition: " ^ s) let print_standard_library () = - let ( // ) = Filename.concat in - let standard_library = - Filename.dirname Sys.executable_name - // Filename.parent_dir_name // "lib" // "ocaml" - in + let standard_library = Config.standard_library in print_string standard_library; print_newline (); exit 0 diff --git a/compiler/ext/config.ml b/compiler/ext/config.ml index 4f75158c25..21bb9ef12a 100644 --- a/compiler/ext/config.ml +++ b/compiler/ext/config.ml @@ -2,8 +2,15 @@ let version = "4.06.1+BS" let standard_library = let ( // ) = Filename.concat in - Filename.dirname Sys.executable_name - // Filename.parent_dir_name // "lib" // "ocaml" + let exe_path = Sys.executable_name in + if Ext_string.contain_substring exe_path "@rescript" then + (* node_modules/@rescirpt/{platform}/bins *) + Filename.dirname exe_path // Filename.parent_dir_name + // Filename.parent_dir_name // Filename.parent_dir_name // "rescript" + // "lib" // "ocaml" + else + (* node_modules/rescirpt/{platform} *) + Filename.dirname exe_path // Filename.parent_dir_name // "lib" // "ocaml" let standard_library_default = standard_library From 8b1468da4eb3695d53614fa9623f69c7ec008ad9 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 09:43:55 +0900 Subject: [PATCH 18/34] sync versions --- package.json | 10 +++--- packages/@rescript/darwin-arm64/package.json | 2 +- packages/@rescript/darwin-x64/package.json | 2 +- packages/@rescript/linux-arm64/package.json | 2 +- packages/@rescript/linux-x64/package.json | 2 +- packages/@rescript/win32-x64/package.json | 2 +- scripts/setVersion.js | 34 ++++++++++++++++---- yarn.lock | 20 ++++++------ 8 files changed, 48 insertions(+), 26 deletions(-) mode change 100644 => 100755 scripts/setVersion.js diff --git a/package.json b/package.json index 3590d235e0..821d6e6161 100644 --- a/package.json +++ b/package.json @@ -75,11 +75,11 @@ "#lib/minisocket": "./lib/minisocket.js" }, "optionalDependencies": { - "@rescript/darwin-arm64": "12.0.0-alpha.12", - "@rescript/darwin-x64": "12.0.0-alpha.12", - "@rescript/linux-arm64": "12.0.0-alpha.12", - "@rescript/linux-x64": "12.0.0-alpha.12", - "@rescript/win32-x64": "12.0.0-alpha.12" + "@rescript/darwin-arm64": "12.0.0-alpha.13", + "@rescript/darwin-x64": "12.0.0-alpha.13", + "@rescript/linux-arm64": "12.0.0-alpha.13", + "@rescript/linux-x64": "12.0.0-alpha.13", + "@rescript/win32-x64": "12.0.0-alpha.13" }, "devDependencies": { "@biomejs/biome": "1.9.4", diff --git a/packages/@rescript/darwin-arm64/package.json b/packages/@rescript/darwin-arm64/package.json index f5c2d71059..6dca1b9e58 100644 --- a/packages/@rescript/darwin-arm64/package.json +++ b/packages/@rescript/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/darwin-arm64", - "version": "12.0.0-alpha.12", + "version": "12.0.0-alpha.13", "description": "ReScript binaries for MacOS ARM64", "type": "module", "repository": { diff --git a/packages/@rescript/darwin-x64/package.json b/packages/@rescript/darwin-x64/package.json index 41a4dc269f..6d1af569da 100644 --- a/packages/@rescript/darwin-x64/package.json +++ b/packages/@rescript/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/darwin-x64", - "version": "12.0.0-alpha.12", + "version": "12.0.0-alpha.13", "description": "ReScript binaries for MacOS x86_64", "type": "module", "repository": { diff --git a/packages/@rescript/linux-arm64/package.json b/packages/@rescript/linux-arm64/package.json index 3271739cd1..943488930b 100644 --- a/packages/@rescript/linux-arm64/package.json +++ b/packages/@rescript/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/linux-arm64", - "version": "12.0.0-alpha.12", + "version": "12.0.0-alpha.13", "description": "ReScript binaries for Linux ARM64", "type": "module", "repository": { diff --git a/packages/@rescript/linux-x64/package.json b/packages/@rescript/linux-x64/package.json index 79b157d1e9..c1fe47a2f9 100644 --- a/packages/@rescript/linux-x64/package.json +++ b/packages/@rescript/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/linux-x64", - "version": "12.0.0-alpha.12", + "version": "12.0.0-alpha.13", "description": "ReScript binaries for Linux x86_64", "type": "module", "repository": { diff --git a/packages/@rescript/win32-x64/package.json b/packages/@rescript/win32-x64/package.json index 5a309e8b82..504c2e8e78 100644 --- a/packages/@rescript/win32-x64/package.json +++ b/packages/@rescript/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/win32-x64", - "version": "12.0.0-alpha.12", + "version": "12.0.0-alpha.13", "description": "ReScript binaries for Windows x86_64", "type": "module", "repository": { diff --git a/scripts/setVersion.js b/scripts/setVersion.js old mode 100644 new mode 100755 index 794807d626..2504197a2e --- a/scripts/setVersion.js +++ b/scripts/setVersion.js @@ -2,6 +2,8 @@ // @ts-check +// TODO: Use Yarn's constraints instead. + import fs from "node:fs"; const packageSpec = JSON.parse( @@ -9,13 +11,33 @@ const packageSpec = JSON.parse( ); const { name, version } = packageSpec; -const stdlibPackageSpec = JSON.parse( - fs.readFileSync("./packages/std/package.json", "utf8"), -); -stdlibPackageSpec.version = version; +/** + * @param {string} specPath + * @param {string} version + */ +function setVersion(specPath, version) { + const spec = JSON.parse(fs.readFileSync(specPath, "utf8")); + spec.version = version; + fs.writeFileSync(specPath, JSON.stringify(spec, null, 2) + "\n", "utf8"); +} + +setVersion("./packages/std/package.json", version); +setVersion("./packages/@rescript/linux-x64/package.json", version); +setVersion("./packages/@rescript/linux-arm64/package.json", version); +setVersion("./packages/@rescript/darwin-x64/package.json", version); +setVersion("./packages/@rescript/darwin-arm64/package.json", version); +setVersion("./packages/@rescript/win32-x64/package.json", version); + +packageSpec.optionalDependencies["@rescript/linux-x64"] = version; +packageSpec.optionalDependencies["@rescript/linux-arm64"] = version; +packageSpec.optionalDependencies["@rescript/darwin-x64"] = version; +packageSpec.optionalDependencies["@rescript/darwin-arm64"] = version; +packageSpec.optionalDependencies["@rescript/win32-x64"] = version; + fs.writeFileSync( - "./packages/std/package.json", - JSON.stringify(stdlibPackageSpec, null, 2), + "./package.json", + JSON.stringify(packageSpec, null, 2) + "\n", + "utf8", ); fs.writeFileSync( diff --git a/yarn.lock b/yarn.lock index e49e90d9ca..ab4bfc3acd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -388,7 +388,7 @@ __metadata: languageName: node linkType: hard -"@rescript/darwin-arm64@npm:12.0.0-alpha.12, @rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64": +"@rescript/darwin-arm64@npm:12.0.0-alpha.13, @rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64": version: 0.0.0-use.local resolution: "@rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64" bin: @@ -402,7 +402,7 @@ __metadata: languageName: unknown linkType: soft -"@rescript/darwin-x64@npm:12.0.0-alpha.12, @rescript/darwin-x64@workspace:packages/@rescript/darwin-x64": +"@rescript/darwin-x64@npm:12.0.0-alpha.13, @rescript/darwin-x64@workspace:packages/@rescript/darwin-x64": version: 0.0.0-use.local resolution: "@rescript/darwin-x64@workspace:packages/@rescript/darwin-x64" bin: @@ -416,7 +416,7 @@ __metadata: languageName: unknown linkType: soft -"@rescript/linux-arm64@npm:12.0.0-alpha.12, @rescript/linux-arm64@workspace:packages/@rescript/linux-arm64": +"@rescript/linux-arm64@npm:12.0.0-alpha.13, @rescript/linux-arm64@workspace:packages/@rescript/linux-arm64": version: 0.0.0-use.local resolution: "@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64" bin: @@ -430,7 +430,7 @@ __metadata: languageName: unknown linkType: soft -"@rescript/linux-x64@npm:12.0.0-alpha.12, @rescript/linux-x64@workspace:packages/@rescript/linux-x64": +"@rescript/linux-x64@npm:12.0.0-alpha.13, @rescript/linux-x64@workspace:packages/@rescript/linux-x64": version: 0.0.0-use.local resolution: "@rescript/linux-x64@workspace:packages/@rescript/linux-x64" bin: @@ -484,7 +484,7 @@ __metadata: languageName: unknown linkType: soft -"@rescript/win32-x64@npm:12.0.0-alpha.12, @rescript/win32-x64@workspace:packages/@rescript/win32-x64": +"@rescript/win32-x64@npm:12.0.0-alpha.13, @rescript/win32-x64@workspace:packages/@rescript/win32-x64": version: 0.0.0-use.local resolution: "@rescript/win32-x64@workspace:packages/@rescript/win32-x64" bin: @@ -2515,11 +2515,11 @@ __metadata: resolution: "rescript@workspace:." dependencies: "@biomejs/biome": "npm:1.9.4" - "@rescript/darwin-arm64": "npm:12.0.0-alpha.12" - "@rescript/darwin-x64": "npm:12.0.0-alpha.12" - "@rescript/linux-arm64": "npm:12.0.0-alpha.12" - "@rescript/linux-x64": "npm:12.0.0-alpha.12" - "@rescript/win32-x64": "npm:12.0.0-alpha.12" + "@rescript/darwin-arm64": "npm:12.0.0-alpha.13" + "@rescript/darwin-x64": "npm:12.0.0-alpha.13" + "@rescript/linux-arm64": "npm:12.0.0-alpha.13" + "@rescript/linux-x64": "npm:12.0.0-alpha.13" + "@rescript/win32-x64": "npm:12.0.0-alpha.13" "@types/node": "npm:^20.14.9" "@types/semver": "npm:^7.5.8" mocha: "npm:10.8.2" From 1dd4706e8dd43a0411515259c16f5000b861e1cb Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 10:52:48 +0900 Subject: [PATCH 19/34] gotcha --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41e30f84a2..306dcb6b9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -456,6 +456,7 @@ jobs: - name: Move artifacts into packages run: .github/workflows/moveArtifacts.sh + shell: bash - name: Check artifact list run: node ./scripts/npmPack.js From e76f9563db3a78cb64e3a590d2afc733416e6a48 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 10:54:37 +0900 Subject: [PATCH 20/34] a bit safer --- compiler/ext/config.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ext/config.ml b/compiler/ext/config.ml index 21bb9ef12a..f0c733b80a 100644 --- a/compiler/ext/config.ml +++ b/compiler/ext/config.ml @@ -3,7 +3,7 @@ let version = "4.06.1+BS" let standard_library = let ( // ) = Filename.concat in let exe_path = Sys.executable_name in - if Ext_string.contain_substring exe_path "@rescript" then + if Ext_string.contain_substring exe_path "node_modules/@rescript" then (* node_modules/@rescirpt/{platform}/bins *) Filename.dirname exe_path // Filename.parent_dir_name // Filename.parent_dir_name // Filename.parent_dir_name // "rescript" From 3e628f2e195c07fa024f02fb130b0c418e6f25be Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 11:06:38 +0900 Subject: [PATCH 21/34] it shound't be symlinks --- .github/workflows/moveArtifacts.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/moveArtifacts.sh b/.github/workflows/moveArtifacts.sh index a3bb4bf895..26186bc3b4 100755 --- a/.github/workflows/moveArtifacts.sh +++ b/.github/workflows/moveArtifacts.sh @@ -25,16 +25,22 @@ check_statically_linked() { fi } +clean_dir() { + local dir="$1" + rm -rf "$dir" && mkdir -p "$dir" + echo -n "$dir" +} + # rescript mv lib-ocaml lib/ocaml # @rescript/{target} chmod +x binaries-*/*.exe rewatch-*/*.exe -mv -f binaries-darwin/* rewatch-darwin/* packages/@rescript/darwin-x64/bin -mv -f binaries-darwinarm64/* rewatch-darwinarm64/* packages/@rescript/darwin-arm64/bin -mv -f binaries-linux/* rewatch-linux/* packages/@rescript/linux-x64/bin -mv -f binaries-linuxarm64/* rewatch-linuxarm64/* packages/@rescript/linux-arm64/bin -mv -f binaries-win32/* rewatch-win32/* packages/@rescript/win32-x64/bin +mv -f binaries-darwin/* rewatch-darwin/* "$(clean_dir "packages/@rescript/darwin-x64/bin")" +mv -f binaries-darwinarm64/* rewatch-darwinarm64/* "$(clean_dir "packages/@rescript/darwin-arm64/bin")" +mv -f binaries-linux/* rewatch-linux/* "$(clean_dir "packages/@rescript/linux-x64/bin")" +mv -f binaries-linuxarm64/* rewatch-linuxarm64/* "$(clean_dir "packages/@rescript/linux-arm64/bin")" +mv -f binaries-win32/* rewatch-win32/* "$(clean_dir "packages/@rescript/win32-x64/bin")" check_statically_linked "packages/@rescript/linux-x64/bin" check_statically_linked "packages/@rescript/linux-arm64/bin" From 934fe83837e59ff4dce2fcc10a2ce613873126c9 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 11:21:21 +0900 Subject: [PATCH 22/34] Overlapped bin entries is not compatibile with the mult-arch config E.g. https://yarnpkg.com/configuration/yarnrc#supportedArchitectures --- packages/@rescript/darwin-arm64/package.json | 9 --------- packages/@rescript/darwin-x64/package.json | 9 --------- packages/@rescript/linux-arm64/package.json | 9 --------- packages/@rescript/linux-x64/package.json | 9 --------- packages/@rescript/win32-x64/package.json | 9 --------- 5 files changed, 45 deletions(-) diff --git a/packages/@rescript/darwin-arm64/package.json b/packages/@rescript/darwin-arm64/package.json index 6dca1b9e58..8efb53f95e 100644 --- a/packages/@rescript/darwin-arm64/package.json +++ b/packages/@rescript/darwin-arm64/package.json @@ -24,15 +24,6 @@ "bin.d.ts", "bin/" ], - "bin": { - "bsb_helper.exe": "./bin/bsb_helper.exe", - "bsc.exe": "./bin/bsc.exe", - "ninja.exe": "./bin/ninja.exe", - "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", - "rescript-tools.exe": "./bin/rescript-tools.exe", - "rescript.exe": "./bin/rescript.exe", - "rewatch.exe": "./bin/rewatch.exe" - }, "exports": "./bin.js", "preferUnplugged": true } diff --git a/packages/@rescript/darwin-x64/package.json b/packages/@rescript/darwin-x64/package.json index 6d1af569da..d691d5a9af 100644 --- a/packages/@rescript/darwin-x64/package.json +++ b/packages/@rescript/darwin-x64/package.json @@ -24,15 +24,6 @@ "bin.d.ts", "bin/" ], - "bin": { - "bsb_helper.exe": "./bin/bsb_helper.exe", - "bsc.exe": "./bin/bsc.exe", - "ninja.exe": "./bin/ninja.exe", - "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", - "rescript-tools.exe": "./bin/rescript-tools.exe", - "rescript.exe": "./bin/rescript.exe", - "rewatch.exe": "./bin/rewatch.exe" - }, "exports": "./bin.js", "preferUnplugged": true } diff --git a/packages/@rescript/linux-arm64/package.json b/packages/@rescript/linux-arm64/package.json index 943488930b..84a921d1e7 100644 --- a/packages/@rescript/linux-arm64/package.json +++ b/packages/@rescript/linux-arm64/package.json @@ -24,15 +24,6 @@ "bin.d.ts", "bin/" ], - "bin": { - "bsb_helper.exe": "./bin/bsb_helper.exe", - "bsc.exe": "./bin/bsc.exe", - "ninja.exe": "./bin/ninja.exe", - "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", - "rescript-tools.exe": "./bin/rescript-tools.exe", - "rescript.exe": "./bin/rescript.exe", - "rewatch.exe": "./bin/rewatch.exe" - }, "exports": "./bin.js", "preferUnplugged": true } diff --git a/packages/@rescript/linux-x64/package.json b/packages/@rescript/linux-x64/package.json index c1fe47a2f9..774eb4281b 100644 --- a/packages/@rescript/linux-x64/package.json +++ b/packages/@rescript/linux-x64/package.json @@ -24,15 +24,6 @@ "bin.d.ts", "bin/" ], - "bin": { - "bsb_helper.exe": "./bin/bsb_helper.exe", - "bsc.exe": "./bin/bsc.exe", - "ninja.exe": "./bin/ninja.exe", - "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", - "rescript-tools.exe": "./bin/rescript-tools.exe", - "rescript.exe": "./bin/rescript.exe", - "rewatch.exe": "./bin/rewatch.exe" - }, "exports": "./bin.js", "preferUnplugged": true } diff --git a/packages/@rescript/win32-x64/package.json b/packages/@rescript/win32-x64/package.json index 504c2e8e78..83154921c2 100644 --- a/packages/@rescript/win32-x64/package.json +++ b/packages/@rescript/win32-x64/package.json @@ -24,15 +24,6 @@ "bin.d.ts", "bin/" ], - "bin": { - "bsb_helper.exe": "./bin/bsb_helper.exe", - "bsc.exe": "./bin/bsc.exe", - "ninja.exe": "./bin/ninja.exe", - "rescript-editor-analysis.exe": "./bin/rescript-editor-analysis.exe", - "rescript-tools.exe": "./bin/rescript-tools.exe", - "rescript.exe": "./bin/rescript.exe", - "rewatch.exe": "./bin/rewatch.exe" - }, "exports": "./bin.js", "preferUnplugged": true } From cdae7dc04f24cb9ec3ad38891ddd8b6af513ea3d Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 11:46:50 +0900 Subject: [PATCH 23/34] workaround for executable permission --- packages/@rescript/darwin-arm64/package.json | 5 +++- .../@rescript/darwin-arm64/scripts/repack.sh | 24 +++++++++++++++++++ packages/@rescript/darwin-x64/package.json | 5 +++- .../@rescript/darwin-x64/scripts/repack.sh | 24 +++++++++++++++++++ packages/@rescript/linux-arm64/package.json | 5 +++- .../@rescript/linux-arm64/scripts/repack.sh | 24 +++++++++++++++++++ packages/@rescript/linux-x64/package.json | 5 +++- .../@rescript/linux-x64/scripts/repack.sh | 24 +++++++++++++++++++ packages/@rescript/win32-x64/package.json | 5 +++- .../@rescript/win32-x64/scripts/repack.sh | 24 +++++++++++++++++++ 10 files changed, 140 insertions(+), 5 deletions(-) create mode 100755 packages/@rescript/darwin-arm64/scripts/repack.sh create mode 100755 packages/@rescript/darwin-x64/scripts/repack.sh create mode 100755 packages/@rescript/linux-arm64/scripts/repack.sh create mode 100755 packages/@rescript/linux-x64/scripts/repack.sh create mode 100755 packages/@rescript/win32-x64/scripts/repack.sh diff --git a/packages/@rescript/darwin-arm64/package.json b/packages/@rescript/darwin-arm64/package.json index 8efb53f95e..b3b73026f5 100644 --- a/packages/@rescript/darwin-arm64/package.json +++ b/packages/@rescript/darwin-arm64/package.json @@ -25,5 +25,8 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true + "preferUnplugged": true, + "scripts": { + "postpack": "./scripts/repack.sh package.tgz" + } } diff --git a/packages/@rescript/darwin-arm64/scripts/repack.sh b/packages/@rescript/darwin-arm64/scripts/repack.sh new file mode 100755 index 0000000000..9da0fee510 --- /dev/null +++ b/packages/@rescript/darwin-arm64/scripts/repack.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Yarn doens't preserve executable permission bits of files as design decision. +# +# Workaround: + +set -e + +PACKAGE_TGZ="$1" + +if [[ -z "$PACKAGE_TGZ" ]]; then + echo "Usage: $0 path/to/package.tgz" + exit 1 +fi + +TMP_DIR="$(mktemp -d)" + +tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" + +chmod +x "$TMP_DIR/package/bin/"* + +tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package + +echo "Repacked successfully" diff --git a/packages/@rescript/darwin-x64/package.json b/packages/@rescript/darwin-x64/package.json index d691d5a9af..a1933bd2d6 100644 --- a/packages/@rescript/darwin-x64/package.json +++ b/packages/@rescript/darwin-x64/package.json @@ -25,5 +25,8 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true + "preferUnplugged": true, + "scripts": { + "postpack": "./scripts/repack.sh package.tgz" + } } diff --git a/packages/@rescript/darwin-x64/scripts/repack.sh b/packages/@rescript/darwin-x64/scripts/repack.sh new file mode 100755 index 0000000000..9da0fee510 --- /dev/null +++ b/packages/@rescript/darwin-x64/scripts/repack.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Yarn doens't preserve executable permission bits of files as design decision. +# +# Workaround: + +set -e + +PACKAGE_TGZ="$1" + +if [[ -z "$PACKAGE_TGZ" ]]; then + echo "Usage: $0 path/to/package.tgz" + exit 1 +fi + +TMP_DIR="$(mktemp -d)" + +tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" + +chmod +x "$TMP_DIR/package/bin/"* + +tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package + +echo "Repacked successfully" diff --git a/packages/@rescript/linux-arm64/package.json b/packages/@rescript/linux-arm64/package.json index 84a921d1e7..093d0305a5 100644 --- a/packages/@rescript/linux-arm64/package.json +++ b/packages/@rescript/linux-arm64/package.json @@ -25,5 +25,8 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true + "preferUnplugged": true, + "scripts": { + "postpack": "./scripts/repack.sh package.tgz" + } } diff --git a/packages/@rescript/linux-arm64/scripts/repack.sh b/packages/@rescript/linux-arm64/scripts/repack.sh new file mode 100755 index 0000000000..9da0fee510 --- /dev/null +++ b/packages/@rescript/linux-arm64/scripts/repack.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Yarn doens't preserve executable permission bits of files as design decision. +# +# Workaround: + +set -e + +PACKAGE_TGZ="$1" + +if [[ -z "$PACKAGE_TGZ" ]]; then + echo "Usage: $0 path/to/package.tgz" + exit 1 +fi + +TMP_DIR="$(mktemp -d)" + +tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" + +chmod +x "$TMP_DIR/package/bin/"* + +tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package + +echo "Repacked successfully" diff --git a/packages/@rescript/linux-x64/package.json b/packages/@rescript/linux-x64/package.json index 774eb4281b..a996418c2a 100644 --- a/packages/@rescript/linux-x64/package.json +++ b/packages/@rescript/linux-x64/package.json @@ -25,5 +25,8 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true + "preferUnplugged": true, + "scripts": { + "postpack": "./scripts/repack.sh package.tgz" + } } diff --git a/packages/@rescript/linux-x64/scripts/repack.sh b/packages/@rescript/linux-x64/scripts/repack.sh new file mode 100755 index 0000000000..9da0fee510 --- /dev/null +++ b/packages/@rescript/linux-x64/scripts/repack.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Yarn doens't preserve executable permission bits of files as design decision. +# +# Workaround: + +set -e + +PACKAGE_TGZ="$1" + +if [[ -z "$PACKAGE_TGZ" ]]; then + echo "Usage: $0 path/to/package.tgz" + exit 1 +fi + +TMP_DIR="$(mktemp -d)" + +tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" + +chmod +x "$TMP_DIR/package/bin/"* + +tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package + +echo "Repacked successfully" diff --git a/packages/@rescript/win32-x64/package.json b/packages/@rescript/win32-x64/package.json index 83154921c2..fb0cfe1cf5 100644 --- a/packages/@rescript/win32-x64/package.json +++ b/packages/@rescript/win32-x64/package.json @@ -25,5 +25,8 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true + "preferUnplugged": true, + "scripts": { + "postpack": "./scripts/repack.sh package.tgz" + } } diff --git a/packages/@rescript/win32-x64/scripts/repack.sh b/packages/@rescript/win32-x64/scripts/repack.sh new file mode 100755 index 0000000000..9da0fee510 --- /dev/null +++ b/packages/@rescript/win32-x64/scripts/repack.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Yarn doens't preserve executable permission bits of files as design decision. +# +# Workaround: + +set -e + +PACKAGE_TGZ="$1" + +if [[ -z "$PACKAGE_TGZ" ]]; then + echo "Usage: $0 path/to/package.tgz" + exit 1 +fi + +TMP_DIR="$(mktemp -d)" + +tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" + +chmod +x "$TMP_DIR/package/bin/"* + +tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package + +echo "Repacked successfully" From fc41236e2040080c8317f3dbc12b8229a23678a3 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 11:54:41 +0900 Subject: [PATCH 24/34] actually not needed read the manual: https://yarnpkg.com/configuration/manifest#publishConfig.executableFiles --- packages/@rescript/darwin-arm64/package.json | 16 +++++++++---- .../@rescript/darwin-arm64/scripts/repack.sh | 24 ------------------- packages/@rescript/darwin-x64/package.json | 16 +++++++++---- .../@rescript/darwin-x64/scripts/repack.sh | 24 ------------------- packages/@rescript/linux-arm64/package.json | 16 +++++++++---- .../@rescript/linux-arm64/scripts/repack.sh | 24 ------------------- packages/@rescript/linux-x64/package.json | 16 +++++++++---- .../@rescript/linux-x64/scripts/repack.sh | 24 ------------------- packages/@rescript/win32-x64/package.json | 16 +++++++++---- .../@rescript/win32-x64/scripts/repack.sh | 24 ------------------- 10 files changed, 55 insertions(+), 145 deletions(-) delete mode 100755 packages/@rescript/darwin-arm64/scripts/repack.sh delete mode 100755 packages/@rescript/darwin-x64/scripts/repack.sh delete mode 100755 packages/@rescript/linux-arm64/scripts/repack.sh delete mode 100755 packages/@rescript/linux-x64/scripts/repack.sh delete mode 100755 packages/@rescript/win32-x64/scripts/repack.sh diff --git a/packages/@rescript/darwin-arm64/package.json b/packages/@rescript/darwin-arm64/package.json index b3b73026f5..ffb1d924ea 100644 --- a/packages/@rescript/darwin-arm64/package.json +++ b/packages/@rescript/darwin-arm64/package.json @@ -8,7 +8,16 @@ "url": "git+https://github.com/rescript-lang/rescript-compiler.git" }, "publishConfig": { - "access": "public" + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] }, "engines": { "node": ">=20.11.0" @@ -25,8 +34,5 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true, - "scripts": { - "postpack": "./scripts/repack.sh package.tgz" - } + "preferUnplugged": true } diff --git a/packages/@rescript/darwin-arm64/scripts/repack.sh b/packages/@rescript/darwin-arm64/scripts/repack.sh deleted file mode 100755 index 9da0fee510..0000000000 --- a/packages/@rescript/darwin-arm64/scripts/repack.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# Yarn doens't preserve executable permission bits of files as design decision. -# -# Workaround: - -set -e - -PACKAGE_TGZ="$1" - -if [[ -z "$PACKAGE_TGZ" ]]; then - echo "Usage: $0 path/to/package.tgz" - exit 1 -fi - -TMP_DIR="$(mktemp -d)" - -tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" - -chmod +x "$TMP_DIR/package/bin/"* - -tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package - -echo "Repacked successfully" diff --git a/packages/@rescript/darwin-x64/package.json b/packages/@rescript/darwin-x64/package.json index a1933bd2d6..a1d75808cd 100644 --- a/packages/@rescript/darwin-x64/package.json +++ b/packages/@rescript/darwin-x64/package.json @@ -8,7 +8,16 @@ "url": "git+https://github.com/rescript-lang/rescript-compiler.git" }, "publishConfig": { - "access": "public" + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] }, "engines": { "node": ">=20.11.0" @@ -25,8 +34,5 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true, - "scripts": { - "postpack": "./scripts/repack.sh package.tgz" - } + "preferUnplugged": true } diff --git a/packages/@rescript/darwin-x64/scripts/repack.sh b/packages/@rescript/darwin-x64/scripts/repack.sh deleted file mode 100755 index 9da0fee510..0000000000 --- a/packages/@rescript/darwin-x64/scripts/repack.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# Yarn doens't preserve executable permission bits of files as design decision. -# -# Workaround: - -set -e - -PACKAGE_TGZ="$1" - -if [[ -z "$PACKAGE_TGZ" ]]; then - echo "Usage: $0 path/to/package.tgz" - exit 1 -fi - -TMP_DIR="$(mktemp -d)" - -tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" - -chmod +x "$TMP_DIR/package/bin/"* - -tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package - -echo "Repacked successfully" diff --git a/packages/@rescript/linux-arm64/package.json b/packages/@rescript/linux-arm64/package.json index 093d0305a5..56015370ae 100644 --- a/packages/@rescript/linux-arm64/package.json +++ b/packages/@rescript/linux-arm64/package.json @@ -8,7 +8,16 @@ "url": "git+https://github.com/rescript-lang/rescript-compiler.git" }, "publishConfig": { - "access": "public" + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] }, "engines": { "node": ">=20.11.0" @@ -25,8 +34,5 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true, - "scripts": { - "postpack": "./scripts/repack.sh package.tgz" - } + "preferUnplugged": true } diff --git a/packages/@rescript/linux-arm64/scripts/repack.sh b/packages/@rescript/linux-arm64/scripts/repack.sh deleted file mode 100755 index 9da0fee510..0000000000 --- a/packages/@rescript/linux-arm64/scripts/repack.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# Yarn doens't preserve executable permission bits of files as design decision. -# -# Workaround: - -set -e - -PACKAGE_TGZ="$1" - -if [[ -z "$PACKAGE_TGZ" ]]; then - echo "Usage: $0 path/to/package.tgz" - exit 1 -fi - -TMP_DIR="$(mktemp -d)" - -tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" - -chmod +x "$TMP_DIR/package/bin/"* - -tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package - -echo "Repacked successfully" diff --git a/packages/@rescript/linux-x64/package.json b/packages/@rescript/linux-x64/package.json index a996418c2a..8b2aa70429 100644 --- a/packages/@rescript/linux-x64/package.json +++ b/packages/@rescript/linux-x64/package.json @@ -8,7 +8,16 @@ "url": "git+https://github.com/rescript-lang/rescript-compiler.git" }, "publishConfig": { - "access": "public" + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] }, "engines": { "node": ">=20.11.0" @@ -25,8 +34,5 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true, - "scripts": { - "postpack": "./scripts/repack.sh package.tgz" - } + "preferUnplugged": true } diff --git a/packages/@rescript/linux-x64/scripts/repack.sh b/packages/@rescript/linux-x64/scripts/repack.sh deleted file mode 100755 index 9da0fee510..0000000000 --- a/packages/@rescript/linux-x64/scripts/repack.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# Yarn doens't preserve executable permission bits of files as design decision. -# -# Workaround: - -set -e - -PACKAGE_TGZ="$1" - -if [[ -z "$PACKAGE_TGZ" ]]; then - echo "Usage: $0 path/to/package.tgz" - exit 1 -fi - -TMP_DIR="$(mktemp -d)" - -tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" - -chmod +x "$TMP_DIR/package/bin/"* - -tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package - -echo "Repacked successfully" diff --git a/packages/@rescript/win32-x64/package.json b/packages/@rescript/win32-x64/package.json index fb0cfe1cf5..1e689ca110 100644 --- a/packages/@rescript/win32-x64/package.json +++ b/packages/@rescript/win32-x64/package.json @@ -8,7 +8,16 @@ "url": "git+https://github.com/rescript-lang/rescript-compiler.git" }, "publishConfig": { - "access": "public" + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] }, "engines": { "node": ">=20.11.0" @@ -25,8 +34,5 @@ "bin/" ], "exports": "./bin.js", - "preferUnplugged": true, - "scripts": { - "postpack": "./scripts/repack.sh package.tgz" - } + "preferUnplugged": true } diff --git a/packages/@rescript/win32-x64/scripts/repack.sh b/packages/@rescript/win32-x64/scripts/repack.sh deleted file mode 100755 index 9da0fee510..0000000000 --- a/packages/@rescript/win32-x64/scripts/repack.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# Yarn doens't preserve executable permission bits of files as design decision. -# -# Workaround: - -set -e - -PACKAGE_TGZ="$1" - -if [[ -z "$PACKAGE_TGZ" ]]; then - echo "Usage: $0 path/to/package.tgz" - exit 1 -fi - -TMP_DIR="$(mktemp -d)" - -tar -xzf "$PACKAGE_TGZ" -C "$TMP_DIR" - -chmod +x "$TMP_DIR/package/bin/"* - -tar -czf "$PACKAGE_TGZ" -C "$TMP_DIR" package - -echo "Repacked successfully" From 367d89999d5e2c93dc9a1040c2bd51ab2d9afb91 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 11:57:16 +0900 Subject: [PATCH 25/34] update lockfile --- yarn.lock | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/yarn.lock b/yarn.lock index ab4bfc3acd..c61d56bdf3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -391,56 +391,24 @@ __metadata: "@rescript/darwin-arm64@npm:12.0.0-alpha.13, @rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64": version: 0.0.0-use.local resolution: "@rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64" - bin: - bsb_helper.exe: ./bin/bsb_helper.exe - bsc.exe: ./bin/bsc.exe - ninja.exe: ./bin/ninja.exe - rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe - rescript-tools.exe: ./bin/rescript-tools.exe - rescript.exe: ./bin/rescript.exe - rewatch.exe: ./bin/rewatch.exe languageName: unknown linkType: soft "@rescript/darwin-x64@npm:12.0.0-alpha.13, @rescript/darwin-x64@workspace:packages/@rescript/darwin-x64": version: 0.0.0-use.local resolution: "@rescript/darwin-x64@workspace:packages/@rescript/darwin-x64" - bin: - bsb_helper.exe: ./bin/bsb_helper.exe - bsc.exe: ./bin/bsc.exe - ninja.exe: ./bin/ninja.exe - rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe - rescript-tools.exe: ./bin/rescript-tools.exe - rescript.exe: ./bin/rescript.exe - rewatch.exe: ./bin/rewatch.exe languageName: unknown linkType: soft "@rescript/linux-arm64@npm:12.0.0-alpha.13, @rescript/linux-arm64@workspace:packages/@rescript/linux-arm64": version: 0.0.0-use.local resolution: "@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64" - bin: - bsb_helper.exe: ./bin/bsb_helper.exe - bsc.exe: ./bin/bsc.exe - ninja.exe: ./bin/ninja.exe - rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe - rescript-tools.exe: ./bin/rescript-tools.exe - rescript.exe: ./bin/rescript.exe - rewatch.exe: ./bin/rewatch.exe languageName: unknown linkType: soft "@rescript/linux-x64@npm:12.0.0-alpha.13, @rescript/linux-x64@workspace:packages/@rescript/linux-x64": version: 0.0.0-use.local resolution: "@rescript/linux-x64@workspace:packages/@rescript/linux-x64" - bin: - bsb_helper.exe: ./bin/bsb_helper.exe - bsc.exe: ./bin/bsc.exe - ninja.exe: ./bin/ninja.exe - rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe - rescript-tools.exe: ./bin/rescript-tools.exe - rescript.exe: ./bin/rescript.exe - rewatch.exe: ./bin/rewatch.exe languageName: unknown linkType: soft @@ -487,14 +455,6 @@ __metadata: "@rescript/win32-x64@npm:12.0.0-alpha.13, @rescript/win32-x64@workspace:packages/@rescript/win32-x64": version: 0.0.0-use.local resolution: "@rescript/win32-x64@workspace:packages/@rescript/win32-x64" - bin: - bsb_helper.exe: ./bin/bsb_helper.exe - bsc.exe: ./bin/bsc.exe - ninja.exe: ./bin/ninja.exe - rescript-editor-analysis.exe: ./bin/rescript-editor-analysis.exe - rescript-tools.exe: ./bin/rescript-tools.exe - rescript.exe: ./bin/rescript.exe - rewatch.exe: ./bin/rewatch.exe languageName: unknown linkType: soft From d9e52591f30b0b4b15180e219fafcfe71a7caece Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 17 Apr 2025 12:06:59 +0900 Subject: [PATCH 26/34] handle path correctly --- compiler/ext/config.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ext/config.ml b/compiler/ext/config.ml index f0c733b80a..b6d9a9777f 100644 --- a/compiler/ext/config.ml +++ b/compiler/ext/config.ml @@ -3,7 +3,7 @@ let version = "4.06.1+BS" let standard_library = let ( // ) = Filename.concat in let exe_path = Sys.executable_name in - if Ext_string.contain_substring exe_path "node_modules/@rescript" then + if Ext_string.contain_substring exe_path ("node_modules" // "@rescript") then (* node_modules/@rescirpt/{platform}/bins *) Filename.dirname exe_path // Filename.parent_dir_name // Filename.parent_dir_name // Filename.parent_dir_name // "rescript" From e915fa0c7830d3228d64897ba90093a4d027a3ba Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Fri, 25 Apr 2025 01:20:06 +0900 Subject: [PATCH 27/34] remove symlinks --- .gitignore | 1 + cli/common/bins.js | 39 ++++++------------- lib_dev/paths.js | 17 -------- packages/@rescript/darwin-arm64/bin/.gitkeep | 0 .../@rescript/darwin-arm64/bin/bsb_helper.exe | 1 - packages/@rescript/darwin-arm64/bin/bsc.exe | 1 - packages/@rescript/darwin-arm64/bin/ninja.exe | 1 - .../bin/rescript-editor-analysis.exe | 1 - .../darwin-arm64/bin/rescript-tools.exe | 1 - .../@rescript/darwin-arm64/bin/rescript.exe | 1 - .../@rescript/darwin-arm64/bin/rewatch.exe | 1 - packages/@rescript/darwin-x64/bin/.gitkeep | 0 .../@rescript/darwin-x64/bin/bsb_helper.exe | 1 - packages/@rescript/darwin-x64/bin/bsc.exe | 1 - packages/@rescript/darwin-x64/bin/ninja.exe | 1 - .../bin/rescript-editor-analysis.exe | 1 - .../darwin-x64/bin/rescript-tools.exe | 1 - .../@rescript/darwin-x64/bin/rescript.exe | 1 - packages/@rescript/darwin-x64/bin/rewatch.exe | 1 - packages/@rescript/linux-arm64/bin/.gitkeep | 0 .../@rescript/linux-arm64/bin/bsb_helper.exe | 1 - packages/@rescript/linux-arm64/bin/bsc.exe | 1 - packages/@rescript/linux-arm64/bin/ninja.exe | 1 - .../bin/rescript-editor-analysis.exe | 1 - .../linux-arm64/bin/rescript-tools.exe | 1 - .../@rescript/linux-arm64/bin/rescript.exe | 1 - .../@rescript/linux-arm64/bin/rewatch.exe | 1 - packages/@rescript/linux-x64/bin/.gitkeep | 0 .../@rescript/linux-x64/bin/bsb_helper.exe | 1 - packages/@rescript/linux-x64/bin/bsc.exe | 1 - packages/@rescript/linux-x64/bin/ninja.exe | 1 - .../bin/rescript-editor-analysis.exe | 1 - .../linux-x64/bin/rescript-tools.exe | 1 - packages/@rescript/linux-x64/bin/rescript.exe | 1 - packages/@rescript/linux-x64/bin/rewatch.exe | 1 - packages/@rescript/win32-x64/bin/.gitkeep | 0 .../@rescript/win32-x64/bin/bsb_helper.exe | 1 - packages/@rescript/win32-x64/bin/bsc.exe | 1 - packages/@rescript/win32-x64/bin/ninja.exe | 1 - .../bin/rescript-editor-analysis.exe | 1 - .../win32-x64/bin/rescript-tools.exe | 1 - packages/@rescript/win32-x64/bin/rescript.exe | 1 - packages/@rescript/win32-x64/bin/rewatch.exe | 1 - scripts/copyExes.js | 6 +-- 44 files changed, 14 insertions(+), 84 deletions(-) create mode 100644 packages/@rescript/darwin-arm64/bin/.gitkeep delete mode 120000 packages/@rescript/darwin-arm64/bin/bsb_helper.exe delete mode 120000 packages/@rescript/darwin-arm64/bin/bsc.exe delete mode 120000 packages/@rescript/darwin-arm64/bin/ninja.exe delete mode 120000 packages/@rescript/darwin-arm64/bin/rescript-editor-analysis.exe delete mode 120000 packages/@rescript/darwin-arm64/bin/rescript-tools.exe delete mode 120000 packages/@rescript/darwin-arm64/bin/rescript.exe delete mode 120000 packages/@rescript/darwin-arm64/bin/rewatch.exe create mode 100644 packages/@rescript/darwin-x64/bin/.gitkeep delete mode 120000 packages/@rescript/darwin-x64/bin/bsb_helper.exe delete mode 120000 packages/@rescript/darwin-x64/bin/bsc.exe delete mode 120000 packages/@rescript/darwin-x64/bin/ninja.exe delete mode 120000 packages/@rescript/darwin-x64/bin/rescript-editor-analysis.exe delete mode 120000 packages/@rescript/darwin-x64/bin/rescript-tools.exe delete mode 120000 packages/@rescript/darwin-x64/bin/rescript.exe delete mode 120000 packages/@rescript/darwin-x64/bin/rewatch.exe create mode 100644 packages/@rescript/linux-arm64/bin/.gitkeep delete mode 120000 packages/@rescript/linux-arm64/bin/bsb_helper.exe delete mode 120000 packages/@rescript/linux-arm64/bin/bsc.exe delete mode 120000 packages/@rescript/linux-arm64/bin/ninja.exe delete mode 120000 packages/@rescript/linux-arm64/bin/rescript-editor-analysis.exe delete mode 120000 packages/@rescript/linux-arm64/bin/rescript-tools.exe delete mode 120000 packages/@rescript/linux-arm64/bin/rescript.exe delete mode 120000 packages/@rescript/linux-arm64/bin/rewatch.exe create mode 100644 packages/@rescript/linux-x64/bin/.gitkeep delete mode 120000 packages/@rescript/linux-x64/bin/bsb_helper.exe delete mode 120000 packages/@rescript/linux-x64/bin/bsc.exe delete mode 120000 packages/@rescript/linux-x64/bin/ninja.exe delete mode 120000 packages/@rescript/linux-x64/bin/rescript-editor-analysis.exe delete mode 120000 packages/@rescript/linux-x64/bin/rescript-tools.exe delete mode 120000 packages/@rescript/linux-x64/bin/rescript.exe delete mode 120000 packages/@rescript/linux-x64/bin/rewatch.exe create mode 100644 packages/@rescript/win32-x64/bin/.gitkeep delete mode 120000 packages/@rescript/win32-x64/bin/bsb_helper.exe delete mode 120000 packages/@rescript/win32-x64/bin/bsc.exe delete mode 120000 packages/@rescript/win32-x64/bin/ninja.exe delete mode 120000 packages/@rescript/win32-x64/bin/rescript-editor-analysis.exe delete mode 120000 packages/@rescript/win32-x64/bin/rescript-tools.exe delete mode 120000 packages/@rescript/win32-x64/bin/rescript.exe delete mode 120000 packages/@rescript/win32-x64/bin/rewatch.exe diff --git a/.gitignore b/.gitignore index dd35e63326..ec3c47063c 100644 --- a/.gitignore +++ b/.gitignore @@ -98,3 +98,4 @@ tests/analysis_tests/**/*.bs.js # package tarballs package.tgz +*.exe diff --git a/cli/common/bins.js b/cli/common/bins.js index 1351fb4e05..91a699771e 100644 --- a/cli/common/bins.js +++ b/cli/common/bins.js @@ -1,9 +1,6 @@ // @ts-check -import * as fs from "node:fs"; - /** - * @import {BinaryPaths} from "@rescript/linux-x64" * @typedef {import("@rescript/linux-x64")} BinaryModuleExports */ @@ -17,29 +14,15 @@ try { throw new Error(`Platform ${target} is not supported!`); } -const binPaths = mod.binPaths; -// Compiler use symbolic links in the development process -if (fs.lstatSync(binPaths.rescript_exe).isSymbolicLink()) { - for (const [key, binPath] of Object.entries(binPaths)) { - try { - binPaths[/** @type {keyof BinaryPaths} */ (key)] = - fs.realpathSync(binPath); - } catch { - // Cannot populate the realpath of a binary, some tests may fails. - // - // But we don't report error here, - // so pass even some binaries are not built yet. - } - } -} - -export const platformDir = mod.binDir; export const { - bsb_helper_exe, - bsc_exe, - ninja_exe, - rescript_editor_analysis_exe, - rescript_tools_exe, - rescript_exe, - rewatch_exe, -} = binPaths; + binDir, + binPaths: { + bsb_helper_exe, + bsc_exe, + ninja_exe, + rescript_editor_analysis_exe, + rescript_tools_exe, + rescript_exe, + rewatch_exe, + }, +} = mod; diff --git a/lib_dev/paths.js b/lib_dev/paths.js index bea6951252..563b922d64 100644 --- a/lib_dev/paths.js +++ b/lib_dev/paths.js @@ -7,23 +7,6 @@ import * as path from "node:path"; */ export const projectDir = path.resolve(import.meta.dirname, ".."); -/** - * For compatibility reasons, if the architecture is x64, omit it from the bin directory name. - * So we'll have "darwin", "linux" and "win32" for x64 arch, - * but "darwinarm64" and "linuxarm64" for arm64 arch. - * Also, we do not have Windows ARM binaries yet. But the x64 binaries do work on Windows 11 ARM. - * So omit the architecture for Windows, too. - */ -export const platformName = - process.arch === "x64" || process.platform === "win32" - ? process.platform - : process.platform + process.arch; - -/** - * path: `/` (e.g. linux, darwinarm64) - */ -export const platformDir = path.resolve(projectDir, platformName); - /** * path: `/compiler/` */ diff --git a/packages/@rescript/darwin-arm64/bin/.gitkeep b/packages/@rescript/darwin-arm64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/darwin-arm64/bin/bsb_helper.exe b/packages/@rescript/darwin-arm64/bin/bsb_helper.exe deleted file mode 120000 index 544194436c..0000000000 --- a/packages/@rescript/darwin-arm64/bin/bsb_helper.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwinarm64/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/bsc.exe b/packages/@rescript/darwin-arm64/bin/bsc.exe deleted file mode 120000 index a9f64d85b2..0000000000 --- a/packages/@rescript/darwin-arm64/bin/bsc.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwinarm64/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/ninja.exe b/packages/@rescript/darwin-arm64/bin/ninja.exe deleted file mode 120000 index 0c9bd19151..0000000000 --- a/packages/@rescript/darwin-arm64/bin/ninja.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwinarm64/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/rescript-editor-analysis.exe b/packages/@rescript/darwin-arm64/bin/rescript-editor-analysis.exe deleted file mode 120000 index c57e413214..0000000000 --- a/packages/@rescript/darwin-arm64/bin/rescript-editor-analysis.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwinarm64/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/rescript-tools.exe b/packages/@rescript/darwin-arm64/bin/rescript-tools.exe deleted file mode 120000 index d77321ea88..0000000000 --- a/packages/@rescript/darwin-arm64/bin/rescript-tools.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwinarm64/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/rescript.exe b/packages/@rescript/darwin-arm64/bin/rescript.exe deleted file mode 120000 index 88da2239af..0000000000 --- a/packages/@rescript/darwin-arm64/bin/rescript.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwinarm64/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-arm64/bin/rewatch.exe b/packages/@rescript/darwin-arm64/bin/rewatch.exe deleted file mode 120000 index 958f8e7285..0000000000 --- a/packages/@rescript/darwin-arm64/bin/rewatch.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwinarm64/rewatch.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/.gitkeep b/packages/@rescript/darwin-x64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/darwin-x64/bin/bsb_helper.exe b/packages/@rescript/darwin-x64/bin/bsb_helper.exe deleted file mode 120000 index 13acf7745f..0000000000 --- a/packages/@rescript/darwin-x64/bin/bsb_helper.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwin/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/bsc.exe b/packages/@rescript/darwin-x64/bin/bsc.exe deleted file mode 120000 index e2923a916f..0000000000 --- a/packages/@rescript/darwin-x64/bin/bsc.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwin/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/ninja.exe b/packages/@rescript/darwin-x64/bin/ninja.exe deleted file mode 120000 index a03a7c1339..0000000000 --- a/packages/@rescript/darwin-x64/bin/ninja.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwin/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/rescript-editor-analysis.exe b/packages/@rescript/darwin-x64/bin/rescript-editor-analysis.exe deleted file mode 120000 index c631958428..0000000000 --- a/packages/@rescript/darwin-x64/bin/rescript-editor-analysis.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwin/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/rescript-tools.exe b/packages/@rescript/darwin-x64/bin/rescript-tools.exe deleted file mode 120000 index e10a3ec47c..0000000000 --- a/packages/@rescript/darwin-x64/bin/rescript-tools.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwin/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/rescript.exe b/packages/@rescript/darwin-x64/bin/rescript.exe deleted file mode 120000 index a7fc58903b..0000000000 --- a/packages/@rescript/darwin-x64/bin/rescript.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwin/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/darwin-x64/bin/rewatch.exe b/packages/@rescript/darwin-x64/bin/rewatch.exe deleted file mode 120000 index f20bcb3918..0000000000 --- a/packages/@rescript/darwin-x64/bin/rewatch.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../darwin/rewatch.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/.gitkeep b/packages/@rescript/linux-arm64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/linux-arm64/bin/bsb_helper.exe b/packages/@rescript/linux-arm64/bin/bsb_helper.exe deleted file mode 120000 index dae266770a..0000000000 --- a/packages/@rescript/linux-arm64/bin/bsb_helper.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linuxarm64/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/bsc.exe b/packages/@rescript/linux-arm64/bin/bsc.exe deleted file mode 120000 index 3ffd1e867e..0000000000 --- a/packages/@rescript/linux-arm64/bin/bsc.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linuxarm64/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/ninja.exe b/packages/@rescript/linux-arm64/bin/ninja.exe deleted file mode 120000 index 15780321c1..0000000000 --- a/packages/@rescript/linux-arm64/bin/ninja.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linuxarm64/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/rescript-editor-analysis.exe b/packages/@rescript/linux-arm64/bin/rescript-editor-analysis.exe deleted file mode 120000 index 5c94854538..0000000000 --- a/packages/@rescript/linux-arm64/bin/rescript-editor-analysis.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linuxarm64/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/rescript-tools.exe b/packages/@rescript/linux-arm64/bin/rescript-tools.exe deleted file mode 120000 index 3566050d8d..0000000000 --- a/packages/@rescript/linux-arm64/bin/rescript-tools.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linuxarm64/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/rescript.exe b/packages/@rescript/linux-arm64/bin/rescript.exe deleted file mode 120000 index 9a6b86bf1c..0000000000 --- a/packages/@rescript/linux-arm64/bin/rescript.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linuxarm64/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/linux-arm64/bin/rewatch.exe b/packages/@rescript/linux-arm64/bin/rewatch.exe deleted file mode 120000 index ed5bbc1009..0000000000 --- a/packages/@rescript/linux-arm64/bin/rewatch.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linuxarm64/rewatch.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/.gitkeep b/packages/@rescript/linux-x64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/linux-x64/bin/bsb_helper.exe b/packages/@rescript/linux-x64/bin/bsb_helper.exe deleted file mode 120000 index c7ede80d93..0000000000 --- a/packages/@rescript/linux-x64/bin/bsb_helper.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linux/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/bsc.exe b/packages/@rescript/linux-x64/bin/bsc.exe deleted file mode 120000 index cfa8db2009..0000000000 --- a/packages/@rescript/linux-x64/bin/bsc.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linux/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/ninja.exe b/packages/@rescript/linux-x64/bin/ninja.exe deleted file mode 120000 index dc0317d50a..0000000000 --- a/packages/@rescript/linux-x64/bin/ninja.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linux/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/rescript-editor-analysis.exe b/packages/@rescript/linux-x64/bin/rescript-editor-analysis.exe deleted file mode 120000 index d84c1cbf9f..0000000000 --- a/packages/@rescript/linux-x64/bin/rescript-editor-analysis.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linux/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/rescript-tools.exe b/packages/@rescript/linux-x64/bin/rescript-tools.exe deleted file mode 120000 index cc95a6383a..0000000000 --- a/packages/@rescript/linux-x64/bin/rescript-tools.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linux/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/rescript.exe b/packages/@rescript/linux-x64/bin/rescript.exe deleted file mode 120000 index dd45ba8b9b..0000000000 --- a/packages/@rescript/linux-x64/bin/rescript.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linux/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/linux-x64/bin/rewatch.exe b/packages/@rescript/linux-x64/bin/rewatch.exe deleted file mode 120000 index 07de5b26f3..0000000000 --- a/packages/@rescript/linux-x64/bin/rewatch.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../linux/rewatch.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/.gitkeep b/packages/@rescript/win32-x64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/win32-x64/bin/bsb_helper.exe b/packages/@rescript/win32-x64/bin/bsb_helper.exe deleted file mode 120000 index f6689c2499..0000000000 --- a/packages/@rescript/win32-x64/bin/bsb_helper.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../win32/bsb_helper.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/bsc.exe b/packages/@rescript/win32-x64/bin/bsc.exe deleted file mode 120000 index b7c26a48f5..0000000000 --- a/packages/@rescript/win32-x64/bin/bsc.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../win32/bsc.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/ninja.exe b/packages/@rescript/win32-x64/bin/ninja.exe deleted file mode 120000 index 142672ef14..0000000000 --- a/packages/@rescript/win32-x64/bin/ninja.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../win32/ninja.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/rescript-editor-analysis.exe b/packages/@rescript/win32-x64/bin/rescript-editor-analysis.exe deleted file mode 120000 index e6b72e0276..0000000000 --- a/packages/@rescript/win32-x64/bin/rescript-editor-analysis.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../win32/rescript-editor-analysis.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/rescript-tools.exe b/packages/@rescript/win32-x64/bin/rescript-tools.exe deleted file mode 120000 index ad556f4805..0000000000 --- a/packages/@rescript/win32-x64/bin/rescript-tools.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../win32/rescript-tools.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/rescript.exe b/packages/@rescript/win32-x64/bin/rescript.exe deleted file mode 120000 index 4854360bd6..0000000000 --- a/packages/@rescript/win32-x64/bin/rescript.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../win32/rescript.exe \ No newline at end of file diff --git a/packages/@rescript/win32-x64/bin/rewatch.exe b/packages/@rescript/win32-x64/bin/rewatch.exe deleted file mode 120000 index a4279c1084..0000000000 --- a/packages/@rescript/win32-x64/bin/rewatch.exe +++ /dev/null @@ -1 +0,0 @@ -../../../../win32/rewatch.exe \ No newline at end of file diff --git a/scripts/copyExes.js b/scripts/copyExes.js index 08d81bea7b..731034f625 100755 --- a/scripts/copyExes.js +++ b/scripts/copyExes.js @@ -7,11 +7,9 @@ import * as child_process from "node:child_process"; import * as fs from "node:fs"; import * as path from "node:path"; -import { platformDir } from "#dev/paths"; +import { binDir } from "#cli/bins"; import { compilerBinDir, ninjaDir, rewatchDir } from "#dev/paths"; -fs.mkdirSync(platformDir, { recursive: true }); - /** * @param {string} dir * @param {string} exe @@ -19,7 +17,7 @@ fs.mkdirSync(platformDir, { recursive: true }); function copyExe(dir, exe) { const ext = process.platform === "win32" ? ".exe" : ""; const src = path.join(dir, exe + ext); - const dest = path.join(platformDir, `${exe}.exe`); + const dest = path.join(binDir, `${exe}.exe`); // For some reason, the copy operation fails in Windows CI if the file already exists. if (process.platform === "win32" && fs.existsSync(dest)) { From ddd18af6c781907a01668aafebd06f375c470a2c Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Fri, 25 Apr 2025 01:53:06 +0900 Subject: [PATCH 28/34] fix --- .github/workflows/ci.yml | 54 +++++++++++---------- .github/workflows/get_artifact_dir_name.js | 10 ---- .github/workflows/moveArtifacts.sh | 16 ++----- Makefile | 6 +-- compiler/ext/config.ml | 13 +++-- scripts/copyExes.js | 55 +++++++++++++++------- 6 files changed, 87 insertions(+), 67 deletions(-) delete mode 100644 .github/workflows/get_artifact_dir_name.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 306dcb6b9c..a4beafce16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,14 +27,19 @@ jobs: include: - os: macos-13 # x64 rust-target: x86_64-apple-darwin + node-target: darwin-x64 - os: macos-14 # ARM rust-target: aarch64-apple-darwin + node-target: darwin-arm64 - os: ubuntu-24.04 # x64 rust-target: x86_64-unknown-linux-musl + node-target: linux-x64 - os: ubuntu-24.04-arm # ARM rust-target: aarch64-unknown-linux-musl + node-target: linux-arm64 - os: windows-latest rust-target: x86_64-pc-windows-gnu + node-target: win32-x64 runs-on: ${{matrix.os}} @@ -66,25 +71,24 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: stable - targets: ${{matrix.rust-target}} + targets: ${{ matrix.rust-target }} - name: Build rewatch if: steps.build-cache.outputs.cache-hit != 'true' - run: cargo build --manifest-path rewatch/Cargo.toml --target ${{matrix.rust-target}} --release - - - name: Copy rewatch exe to platform bin dir run: | - cp rewatch/target/${{matrix.rust-target}}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch - node ./scripts/copyExes.js -rewatch + cargo build --manifest-path rewatch/Cargo.toml --target ${{ matrix.rust-target }} --release - - name: Get artifact dir name - run: node .github/workflows/get_artifact_dir_name.js + - name: Copy rewatch binary + run: | + cp rewatch/target/${{ matrix.rust-target }}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch.exe + shell: bash - name: "Upload artifact: rewatch binary" uses: actions/upload-artifact@v4 with: - name: rewatch-${{env.artifact_dir_name}} - path: ${{ env.artifact_dir_name }} + name: rewatch-${{ matrix.node-target }} + path: rewatch.exe + if-no-files-found: error build-compiler: strategy: @@ -95,21 +99,26 @@ jobs: ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static upload_binaries: true upload_libs: true + node-target: linux-x64 - os: ubuntu-24.04-arm # ARM ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static upload_binaries: true # Build the playground compiler and run the benchmarks on the fastest runner build_playground: true benchmarks: true + node-target: linux-arm64 - os: macos-13 # x64 ocaml_compiler: 5.3.0 upload_binaries: true + node-target: darwin-x64 - os: macos-14 # ARM ocaml_compiler: 5.3.0 upload_binaries: true + node-target: darwin-arm64 - os: windows-latest ocaml_compiler: 5.3.0 upload_binaries: true + node-target: win32-x64 # Verify that the compiler still builds with older OCaml versions - os: ubuntu-24.04 @@ -144,9 +153,6 @@ jobs: cache: yarn node-version-file: .nvmrc - - name: Get artifact dir name - run: node .github/workflows/get_artifact_dir_name.js - - name: Install dependencies (Linux) if: runner.os == 'Linux' uses: awalsh128/cache-apt-pkgs-action@v1.4.3 @@ -303,13 +309,13 @@ jobs: run: yarn install - name: Copy compiler exes to platform bin dir - run: node ./scripts/copyExes.js -compiler + run: node scripts/copyExes.js --compiler - name: Restore ninja build cache id: ninja-build-cache uses: actions/cache@v4 with: - path: ${{ env.artifact_dir_name }}/ninja.exe + path: packages/@rescript/${{ matrix.node-target }}/bin/ninja.exe key: ninja-build-v1-${{ matrix.os }}-${{ hashFiles('ninja/src/**') }} - name: Setup Python for ninja build @@ -336,7 +342,7 @@ jobs: - name: Copy ninja exe to platform bin dir if: steps.ninja-build-cache.outputs.cache-hit != 'true' - run: node ./scripts/copyExes.js -ninja + run: node scripts/copyExes.js --ninja - name: "Syntax: Run roundtrip tests" if: ${{ runner.os != 'Windows' }} @@ -423,8 +429,8 @@ jobs: if: matrix.upload_binaries uses: actions/upload-artifact@v4 with: - name: binaries-${{ env.artifact_dir_name }} - path: ${{ env.artifact_dir_name }} + name: binaries-${{ matrix.node-target }} + path: packages/@rescript/${{ matrix.node-target }}/bin - name: "Upload artifacts: lib/ocaml" if: matrix.upload_libs @@ -491,15 +497,15 @@ jobs: matrix: include: - os: macos-13 - target: darwin-x64 + node-target: darwin-x64 - os: macos-14 - target: darwin-arm64 + node-target: darwin-arm64 - os: ubuntu-24.04 - target: linux-x64 + node-target: linux-x64 - os: ubuntu-24.04-arm - target: linux-arm64 + node-target: linux-arm64 - os: windows-latest - target: win32-x64 + node-target: win32-x64 runs-on: ${{ matrix.os }} @@ -535,7 +541,7 @@ jobs: run: | npm i --ignore-scripts --no-audit \ rescript-${{ needs.package.outputs.rescript_version }}.tgz \ - rescript-${{ matrix.target }}-${{ needs.package.outputs.rescript_version }}.tgz + rescript-${{ matrix.node-target }}-${{ needs.package.outputs.rescript_version }}.tgz shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} diff --git a/.github/workflows/get_artifact_dir_name.js b/.github/workflows/get_artifact_dir_name.js deleted file mode 100644 index 80ec51e212..0000000000 --- a/.github/workflows/get_artifact_dir_name.js +++ /dev/null @@ -1,10 +0,0 @@ -import * as fs from "node:fs"; -import * as os from "node:os"; - -import { platformName } from "#dev/paths"; - -// Pass artifactDirName to subsequent GitHub actions -fs.appendFileSync( - process.env.GITHUB_ENV, - `artifact_dir_name=${platformName}${os.EOL}`, -); diff --git a/.github/workflows/moveArtifacts.sh b/.github/workflows/moveArtifacts.sh index 26186bc3b4..4d29ca4a3b 100755 --- a/.github/workflows/moveArtifacts.sh +++ b/.github/workflows/moveArtifacts.sh @@ -25,22 +25,16 @@ check_statically_linked() { fi } -clean_dir() { - local dir="$1" - rm -rf "$dir" && mkdir -p "$dir" - echo -n "$dir" -} - # rescript mv lib-ocaml lib/ocaml # @rescript/{target} chmod +x binaries-*/*.exe rewatch-*/*.exe -mv -f binaries-darwin/* rewatch-darwin/* "$(clean_dir "packages/@rescript/darwin-x64/bin")" -mv -f binaries-darwinarm64/* rewatch-darwinarm64/* "$(clean_dir "packages/@rescript/darwin-arm64/bin")" -mv -f binaries-linux/* rewatch-linux/* "$(clean_dir "packages/@rescript/linux-x64/bin")" -mv -f binaries-linuxarm64/* rewatch-linuxarm64/* "$(clean_dir "packages/@rescript/linux-arm64/bin")" -mv -f binaries-win32/* rewatch-win32/* "$(clean_dir "packages/@rescript/win32-x64/bin")" +mv -f binaries-darwin-x64/* rewatch-darwin-x64/* "packages/@rescript/darwin-x64/bin" +mv -f binaries-darwin-arm64/* rewatch-darwin-arm64/* "packages/@rescript/darwin-arm64/bin" +mv -f binaries-linux-x64/* rewatch-linux-x64/* "packages/@rescript/linux-x64/bin" +mv -f binaries-linux-arm64/* rewatch-linux-arm64/* "packages/@rescript/linux-arm64/bin" +mv -f binaries-win32-x64/* rewatch-win32-x64/* "packages/@rescript/win32-x64/bin" check_statically_linked "packages/@rescript/linux-x64/bin" check_statically_linked "packages/@rescript/linux-arm64/bin" diff --git a/Makefile b/Makefile index 668141a7a9..1763a77eb9 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ DUNE_BIN_DIR = ./_build/install/default/bin build: ninja rewatch dune build - ./scripts/copyExes.js -compiler + ./scripts/copyExes.js --compiler watch: dune build -w @@ -18,11 +18,11 @@ dce: rewatch: cargo build --manifest-path rewatch/Cargo.toml cp rewatch/target/debug/rewatch rewatch - ./scripts/copyExes.js -rewatch + ./scripts/copyExes.js --rewatch ninja/ninja: ./scripts/buildNinjaBinary.js - ./scripts/copyExes.js -ninja + ./scripts/copyExes.js --ninja ninja: ninja/ninja diff --git a/compiler/ext/config.ml b/compiler/ext/config.ml index b6d9a9777f..61edbcfde7 100644 --- a/compiler/ext/config.ml +++ b/compiler/ext/config.ml @@ -1,16 +1,23 @@ let version = "4.06.1+BS" +(* FIXME: Unreliable resolution *) let standard_library = let ( // ) = Filename.concat in let exe_path = Sys.executable_name in if Ext_string.contain_substring exe_path ("node_modules" // "@rescript") then - (* node_modules/@rescirpt/{platform}/bins *) + (* node_modules/@rescript/{platform}/bin *) Filename.dirname exe_path // Filename.parent_dir_name // Filename.parent_dir_name // Filename.parent_dir_name // "rescript" // "lib" // "ocaml" - else - (* node_modules/rescirpt/{platform} *) + else if Ext_string.contain_substring exe_path ("node_modules" // "rescript") + then + (* node_modules/rescript/{platform} *) Filename.dirname exe_path // Filename.parent_dir_name // "lib" // "ocaml" + else + (* git repo: rescript/packages/@rescript/{platform}/bin *) + Filename.dirname exe_path // Filename.parent_dir_name + // Filename.parent_dir_name // Filename.parent_dir_name + // Filename.parent_dir_name // "lib" // "ocaml" let standard_library_default = standard_library diff --git a/scripts/copyExes.js b/scripts/copyExes.js index 731034f625..3e54761753 100755 --- a/scripts/copyExes.js +++ b/scripts/copyExes.js @@ -7,9 +7,48 @@ import * as child_process from "node:child_process"; import * as fs from "node:fs"; import * as path from "node:path"; +import { parseArgs } from "node:util"; import { binDir } from "#cli/bins"; import { compilerBinDir, ninjaDir, rewatchDir } from "#dev/paths"; +const args = parseArgs({ + args: process.argv.slice(2), + options: { + all: { + type: "boolean", + }, + compiler: { + type: "boolean", + }, + ninja: { + type: "boolean", + }, + rewatch: { + type: "boolean", + }, + }, +}); + +const shouldCopyCompiler = args.values.all || args.values.compiler; +const shouldCopyNinja = args.values.all || args.values.ninja; +const shouldCopyRewatch = args.values.all || args.values.rewatch; + +if (shouldCopyCompiler) { + copyExe(compilerBinDir, "rescript"); + copyExe(compilerBinDir, "rescript-editor-analysis"); + copyExe(compilerBinDir, "rescript-tools"); + copyExe(compilerBinDir, "bsc"); + copyExe(compilerBinDir, "bsb_helper"); +} + +if (shouldCopyNinja) { + copyExe(ninjaDir, "ninja"); +} + +if (shouldCopyRewatch) { + copyExe(rewatchDir, "rewatch"); +} + /** * @param {string} dir * @param {string} exe @@ -39,19 +78,3 @@ function copyExe(dir, exe) { fs.chmodSync(dest, mode); } } - -if (process.argv.includes("-all") || process.argv.includes("-compiler")) { - copyExe(compilerBinDir, "rescript"); - copyExe(compilerBinDir, "rescript-editor-analysis"); - copyExe(compilerBinDir, "rescript-tools"); - copyExe(compilerBinDir, "bsc"); - copyExe(compilerBinDir, "bsb_helper"); -} - -if (process.argv.includes("-all") || process.argv.includes("-ninja")) { - copyExe(ninjaDir, "ninja"); -} - -if (process.argv.includes("-all") || process.argv.includes("-rewatch")) { - copyExe(rewatchDir, "rewatch"); -} From a6fdc014aa4384f891536dce2709bb78b3f27240 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Fri, 25 Apr 2025 05:37:50 +0900 Subject: [PATCH 29/34] use workspace protocol, less burden --- package.json | 10 +++++----- scripts/setVersion.js | 12 ------------ yarn.lock | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 821d6e6161..ba4759e9f3 100644 --- a/package.json +++ b/package.json @@ -75,11 +75,11 @@ "#lib/minisocket": "./lib/minisocket.js" }, "optionalDependencies": { - "@rescript/darwin-arm64": "12.0.0-alpha.13", - "@rescript/darwin-x64": "12.0.0-alpha.13", - "@rescript/linux-arm64": "12.0.0-alpha.13", - "@rescript/linux-x64": "12.0.0-alpha.13", - "@rescript/win32-x64": "12.0.0-alpha.13" + "@rescript/darwin-arm64": "workspace:packages/@rescript/darwin-arm64", + "@rescript/darwin-x64": "workspace:packages/@rescript/darwin-x64", + "@rescript/linux-arm64": "workspace:packages/@rescript/linux-arm64", + "@rescript/linux-x64": "workspace:packages/@rescript/linux-x64", + "@rescript/win32-x64": "workspace:packages/@rescript/win32-x64" }, "devDependencies": { "@biomejs/biome": "1.9.4", diff --git a/scripts/setVersion.js b/scripts/setVersion.js index 2504197a2e..e983657cdf 100755 --- a/scripts/setVersion.js +++ b/scripts/setVersion.js @@ -28,18 +28,6 @@ setVersion("./packages/@rescript/darwin-x64/package.json", version); setVersion("./packages/@rescript/darwin-arm64/package.json", version); setVersion("./packages/@rescript/win32-x64/package.json", version); -packageSpec.optionalDependencies["@rescript/linux-x64"] = version; -packageSpec.optionalDependencies["@rescript/linux-arm64"] = version; -packageSpec.optionalDependencies["@rescript/darwin-x64"] = version; -packageSpec.optionalDependencies["@rescript/darwin-arm64"] = version; -packageSpec.optionalDependencies["@rescript/win32-x64"] = version; - -fs.writeFileSync( - "./package.json", - JSON.stringify(packageSpec, null, 2) + "\n", - "utf8", -); - fs.writeFileSync( "./compiler/common/bs_version.ml", `(* Copyright (C) 2015-2016 Bloomberg Finance L.P. diff --git a/yarn.lock b/yarn.lock index c61d56bdf3..de112f2ba7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -388,25 +388,25 @@ __metadata: languageName: node linkType: hard -"@rescript/darwin-arm64@npm:12.0.0-alpha.13, @rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64": +"@rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64": version: 0.0.0-use.local resolution: "@rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64" languageName: unknown linkType: soft -"@rescript/darwin-x64@npm:12.0.0-alpha.13, @rescript/darwin-x64@workspace:packages/@rescript/darwin-x64": +"@rescript/darwin-x64@workspace:packages/@rescript/darwin-x64": version: 0.0.0-use.local resolution: "@rescript/darwin-x64@workspace:packages/@rescript/darwin-x64" languageName: unknown linkType: soft -"@rescript/linux-arm64@npm:12.0.0-alpha.13, @rescript/linux-arm64@workspace:packages/@rescript/linux-arm64": +"@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64": version: 0.0.0-use.local resolution: "@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64" languageName: unknown linkType: soft -"@rescript/linux-x64@npm:12.0.0-alpha.13, @rescript/linux-x64@workspace:packages/@rescript/linux-x64": +"@rescript/linux-x64@workspace:packages/@rescript/linux-x64": version: 0.0.0-use.local resolution: "@rescript/linux-x64@workspace:packages/@rescript/linux-x64" languageName: unknown @@ -452,7 +452,7 @@ __metadata: languageName: unknown linkType: soft -"@rescript/win32-x64@npm:12.0.0-alpha.13, @rescript/win32-x64@workspace:packages/@rescript/win32-x64": +"@rescript/win32-x64@workspace:packages/@rescript/win32-x64": version: 0.0.0-use.local resolution: "@rescript/win32-x64@workspace:packages/@rescript/win32-x64" languageName: unknown @@ -2475,11 +2475,11 @@ __metadata: resolution: "rescript@workspace:." dependencies: "@biomejs/biome": "npm:1.9.4" - "@rescript/darwin-arm64": "npm:12.0.0-alpha.13" - "@rescript/darwin-x64": "npm:12.0.0-alpha.13" - "@rescript/linux-arm64": "npm:12.0.0-alpha.13" - "@rescript/linux-x64": "npm:12.0.0-alpha.13" - "@rescript/win32-x64": "npm:12.0.0-alpha.13" + "@rescript/darwin-arm64": "workspace:packages/@rescript/darwin-arm64" + "@rescript/darwin-x64": "workspace:packages/@rescript/darwin-x64" + "@rescript/linux-arm64": "workspace:packages/@rescript/linux-arm64" + "@rescript/linux-x64": "workspace:packages/@rescript/linux-x64" + "@rescript/win32-x64": "workspace:packages/@rescript/win32-x64" "@types/node": "npm:^20.14.9" "@types/semver": "npm:^7.5.8" mocha: "npm:10.8.2" From fd92bc53b3511543695c62c336e82bfcdc335387 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Fri, 25 Apr 2025 05:46:14 +0900 Subject: [PATCH 30/34] make ninja task recoverable without rebuild --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1763a77eb9..3f37c782e0 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,9 @@ rewatch: ninja/ninja: ./scripts/buildNinjaBinary.js - ./scripts/copyExes.js --ninja ninja: ninja/ninja + ./scripts/copyExes.js --ninja test: build lib node scripts/test.js -all From 496611ab9feb6e4604654ceaaf27590d2db343ac Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Fri, 25 Apr 2025 23:44:02 +0900 Subject: [PATCH 31/34] refactor using readline --- scripts/npmPack.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/scripts/npmPack.js b/scripts/npmPack.js index 41a4b100c0..c542bb131a 100755 --- a/scripts/npmPack.js +++ b/scripts/npmPack.js @@ -11,7 +11,8 @@ // recreates the artifact list and verifies that it has no changes compared to the committed state. import { execSync, spawn } from "node:child_process"; -import fs from "node:fs"; +import * as fs from "node:fs/promises"; +import * as readline from "node:readline/promises"; import { parseArgs } from "node:util"; import { artifactListFile } from "#dev/paths"; @@ -50,23 +51,21 @@ const exitCode = new Promise((resolve, reject) => { child.once("close", code => resolve(code)); }); -fs.unlinkSync(artifactListFile); +await fs.unlink(artifactListFile); -for await (const chunk of child.stdout.setEncoding("utf8")) { - const lines = /** @type {string} */ (chunk) - .trim() - .split(/\s/); - for (const line of lines) { - /** @type {YarnPackOutputLine} */ - const json = JSON.parse(line); - if ("location" in json) { - // Workaround for false positive reports - // See https://github.com/yarnpkg/berry/issues/6766 - if (json.location.startsWith("_build")) { - continue; - } - fs.appendFileSync(artifactListFile, json.location + "\n", "utf8"); +for await (const line of readline.createInterface({ + input: child.stdout.setEncoding("utf8"), + crlfDelay: Number.POSITIVE_INFINITY, +})) { + /** @type {YarnPackOutputLine} */ + const json = JSON.parse(line); + if ("location" in json) { + // Workaround for false positive reports + // See https://github.com/yarnpkg/berry/issues/6766 + if (json.location.startsWith("_build")) { + continue; } + await fs.appendFile(artifactListFile, json.location + "\n", "utf8"); } } From d566a6fbbf459843f39f170f4c18763e889534eb Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Wed, 30 Apr 2025 17:46:49 +0900 Subject: [PATCH 32/34] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a2c497ce1..7831fa250d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ #### :rocket: New Feature - Add shift (`<<`, `>>`, `>>>`) operators for `int` and `bigint`. https://github.com/rescript-lang/rescript/pull/7183 +- Significantly reduced the download size by splitting binaries into optional platform-specific dependencies (e.g, `@rescirpt/linux-x64`). https://github.com/rescript-lang/rescript/pull/7395 #### :bug: Bug fix From 0be8f481c20f70eb645e6f7d25168114b0e6d3de Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Wed, 30 Apr 2025 17:53:29 +0900 Subject: [PATCH 33/34] add note about resolutions override for testing --- CONTRIBUTING.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b72a486baa..960f78d4ef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -404,7 +404,21 @@ To reproduce issues, it can be helpful to the team to install a specific version 1. In your repository run: ```console -npm i npm-packages/rescript-*.tgz +npm i /npm-packages/rescript-*.tgz +``` + +If you use Yarn or pnpm, you should override platform package resolutions by [`resolutions`](https://yarnpkg.com/configuration/manifest#resolutions) in Yarn or [`overrides`](https://pnpm.io/settings#overrides) in Pnpm. + +``` +{ + "resolutions": { + "@rescript/linux-x64": "/npm-packages/rescript-linux-x64.tgz", + "@rescript/linux-arm64": "/npm-packages/rescript-linux-arm64.tgz", + "@rescript/darwin-x64": "/npm-packages/rescript-darwin-x64.tgz", + "@rescript/darwin-arm64": "/npm-packages/rescript-darwin-arm64.tgz", + "@rescript/win32-x64": "/npm-packages/rescript-win32-x64.tgz" + } +} ``` 1. Then attempt to rebuild your project as you would normally. From b93bdafdd2ee180ff14cc1d434315170b541d9d8 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Wed, 30 Apr 2025 20:56:48 +0900 Subject: [PATCH 34/34] Update CHANGELOG.md Co-authored-by: Christoph Knittel --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7831fa250d..00f0ae3295 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ #### :rocket: New Feature - Add shift (`<<`, `>>`, `>>>`) operators for `int` and `bigint`. https://github.com/rescript-lang/rescript/pull/7183 -- Significantly reduced the download size by splitting binaries into optional platform-specific dependencies (e.g, `@rescirpt/linux-x64`). https://github.com/rescript-lang/rescript/pull/7395 +- Significantly reduced the download size by splitting binaries into optional platform-specific dependencies (e.g, `@rescript/linux-x64`). https://github.com/rescript-lang/rescript/pull/7395 #### :bug: Bug fix