Skip to content

Commit 7697720

Browse files
committed
fix
1 parent 04e416c commit 7697720

File tree

6 files changed

+81
-60
lines changed

6 files changed

+81
-60
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,19 @@ jobs:
2727
include:
2828
- os: macos-13 # x64
2929
rust-target: x86_64-apple-darwin
30+
node-target: darwin-x64
3031
- os: macos-14 # ARM
3132
rust-target: aarch64-apple-darwin
33+
node-target: darwin-arm64
3234
- os: ubuntu-24.04 # x64
3335
rust-target: x86_64-unknown-linux-musl
36+
node-target: linux-x64
3437
- os: ubuntu-24.04-arm # ARM
3538
rust-target: aarch64-unknown-linux-musl
39+
node-target: linux-arm64
3640
- os: windows-latest
3741
rust-target: x86_64-pc-windows-gnu
42+
node-target: win32-x64
3843

3944
runs-on: ${{matrix.os}}
4045

@@ -66,25 +71,22 @@ jobs:
6671
uses: dtolnay/rust-toolchain@master
6772
with:
6873
toolchain: stable
69-
targets: ${{matrix.rust-target}}
74+
targets: ${{ matrix.rust-target }}
7075

7176
- name: Build rewatch
7277
if: steps.build-cache.outputs.cache-hit != 'true'
7378
run: cargo build --manifest-path rewatch/Cargo.toml --target ${{matrix.rust-target}} --release
7479

7580
- name: Copy rewatch exe to platform bin dir
7681
run: |
77-
cp rewatch/target/${{matrix.rust-target}}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch
78-
node ./scripts/copyExes.js -rewatch
79-
80-
- name: Get artifact dir name
81-
run: node .github/workflows/get_artifact_dir_name.js
82+
cp rewatch/target/${{ matrix.rust-target }}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch
83+
node scripts/copyExes.js --rewatch
8284
8385
- name: "Upload artifact: rewatch binary"
8486
uses: actions/upload-artifact@v4
8587
with:
86-
name: rewatch-${{env.artifact_dir_name}}
87-
path: ${{ env.artifact_dir_name }}
88+
name: rewatch-${{ env.artifact_dir_name }}
89+
path: packages/@rescript/${{ matrix.node-target }}/bin/rewatch.exe
8890

8991
build-compiler:
9092
strategy:
@@ -95,21 +97,26 @@ jobs:
9597
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
9698
upload_binaries: true
9799
upload_libs: true
100+
node-target: linux-x64
98101
- os: ubuntu-24.04-arm # ARM
99102
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
100103
upload_binaries: true
101104
# Build the playground compiler and run the benchmarks on the fastest runner
102105
build_playground: true
103106
benchmarks: true
107+
node-target: linux-arm64
104108
- os: macos-13 # x64
105109
ocaml_compiler: 5.3.0
106110
upload_binaries: true
111+
node-target: darwin-x64
107112
- os: macos-14 # ARM
108113
ocaml_compiler: 5.3.0
109114
upload_binaries: true
115+
node-target: darwin-arm64
110116
- os: windows-latest
111117
ocaml_compiler: 5.3.0
112118
upload_binaries: true
119+
node-target: win32-x64
113120

114121
# Verify that the compiler still builds with older OCaml versions
115122
- os: ubuntu-24.04
@@ -303,7 +310,7 @@ jobs:
303310
run: yarn install
304311

305312
- name: Copy compiler exes to platform bin dir
306-
run: node ./scripts/copyExes.js -compiler
313+
run: node scripts/copyExes.js --compiler
307314

308315
- name: Restore ninja build cache
309316
id: ninja-build-cache
@@ -336,7 +343,7 @@ jobs:
336343

337344
- name: Copy ninja exe to platform bin dir
338345
if: steps.ninja-build-cache.outputs.cache-hit != 'true'
339-
run: node ./scripts/copyExes.js -ninja
346+
run: node scripts/copyExes.js --ninja
340347

341348
- name: "Syntax: Run roundtrip tests"
342349
if: ${{ runner.os != 'Windows' }}
@@ -424,7 +431,7 @@ jobs:
424431
uses: actions/upload-artifact@v4
425432
with:
426433
name: binaries-${{ env.artifact_dir_name }}
427-
path: ${{ env.artifact_dir_name }}
434+
path: packages/@rescript/${{ matrix.node-target }}/bin
428435

429436
- name: "Upload artifacts: lib/ocaml"
430437
if: matrix.upload_libs
@@ -491,15 +498,15 @@ jobs:
491498
matrix:
492499
include:
493500
- os: macos-13
494-
target: darwin-x64
501+
node-target: darwin-x64
495502
- os: macos-14
496-
target: darwin-arm64
503+
node-target: darwin-arm64
497504
- os: ubuntu-24.04
498-
target: linux-x64
505+
node-target: linux-x64
499506
- os: ubuntu-24.04-arm
500-
target: linux-arm64
507+
node-target: linux-arm64
501508
- os: windows-latest
502-
target: win32-x64
509+
node-target: win32-x64
503510

504511
runs-on: ${{ matrix.os }}
505512

@@ -535,7 +542,7 @@ jobs:
535542
run: |
536543
npm i --ignore-scripts --no-audit \
537544
rescript-${{ needs.package.outputs.rescript_version }}.tgz \
538-
rescript-${{ matrix.target }}-${{ needs.package.outputs.rescript_version }}.tgz
545+
rescript-${{ matrix.node-target }}-${{ needs.package.outputs.rescript_version }}.tgz
539546
shell: bash
540547
working-directory: ${{ steps.tmp-dir.outputs.path }}
541548

.github/workflows/get_artifact_dir_name.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/moveArtifacts.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,16 @@ check_statically_linked() {
2525
fi
2626
}
2727

28-
clean_dir() {
29-
local dir="$1"
30-
rm -rf "$dir" && mkdir -p "$dir"
31-
echo -n "$dir"
32-
}
33-
3428
# rescript
3529
mv lib-ocaml lib/ocaml
3630

3731
# @rescript/{target}
3832
chmod +x binaries-*/*.exe rewatch-*/*.exe
39-
mv -f binaries-darwin/* rewatch-darwin/* "$(clean_dir "packages/@rescript/darwin-x64/bin")"
40-
mv -f binaries-darwinarm64/* rewatch-darwinarm64/* "$(clean_dir "packages/@rescript/darwin-arm64/bin")"
41-
mv -f binaries-linux/* rewatch-linux/* "$(clean_dir "packages/@rescript/linux-x64/bin")"
42-
mv -f binaries-linuxarm64/* rewatch-linuxarm64/* "$(clean_dir "packages/@rescript/linux-arm64/bin")"
43-
mv -f binaries-win32/* rewatch-win32/* "$(clean_dir "packages/@rescript/win32-x64/bin")"
33+
mv -f binaries-darwin/* rewatch-darwin/* "packages/@rescript/darwin-x64/bin"
34+
mv -f binaries-darwinarm64/* rewatch-darwinarm64/* "packages/@rescript/darwin-arm64/bin"
35+
mv -f binaries-linux/* rewatch-linux/* "packages/@rescript/linux-x64/bin"
36+
mv -f binaries-linuxarm64/* rewatch-linuxarm64/* "packages/@rescript/linux-arm64/bin"
37+
mv -f binaries-win32/* rewatch-win32/* "packages/@rescript/win32-x64/bin"
4438
check_statically_linked "packages/@rescript/linux-x64/bin"
4539
check_statically_linked "packages/@rescript/linux-arm64/bin"
4640

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ DUNE_BIN_DIR = ./_build/install/default/bin
44

55
build: ninja rewatch
66
dune build
7-
./scripts/copyExes.js -compiler
7+
./scripts/copyExes.js --compiler
88

99
watch:
1010
dune build -w
@@ -18,11 +18,11 @@ dce:
1818
rewatch:
1919
cargo build --manifest-path rewatch/Cargo.toml
2020
cp rewatch/target/debug/rewatch rewatch
21-
./scripts/copyExes.js -rewatch
21+
./scripts/copyExes.js --rewatch
2222

2323
ninja/ninja:
2424
./scripts/buildNinjaBinary.js
25-
./scripts/copyExes.js -ninja
25+
./scripts/copyExes.js --ninja
2626

2727
ninja: ninja/ninja
2828

compiler/ext/config.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
let version = "4.06.1+BS"
22

3+
(* FIXME: Unreliable resolution *)
34
let standard_library =
45
let ( // ) = Filename.concat in
56
let exe_path = Sys.executable_name in
67
if Ext_string.contain_substring exe_path ("node_modules" // "@rescript") then
7-
(* node_modules/@rescirpt/{platform}/bins *)
8+
(* node_modules/@rescript/{platform}/bin *)
89
Filename.dirname exe_path // Filename.parent_dir_name
910
// Filename.parent_dir_name // Filename.parent_dir_name // "rescript"
1011
// "lib" // "ocaml"
11-
else
12-
(* node_modules/rescirpt/{platform} *)
12+
else if Ext_string.contain_substring exe_path ("node_modules" // "rescript")
13+
then
14+
(* node_modules/rescript/{platform} *)
1315
Filename.dirname exe_path // Filename.parent_dir_name // "lib" // "ocaml"
16+
else
17+
(* git repo: rescript/packages/@rescript/{platform}/bin *)
18+
Filename.dirname exe_path // Filename.parent_dir_name
19+
// Filename.parent_dir_name // Filename.parent_dir_name
20+
// Filename.parent_dir_name // "lib" // "ocaml"
1421

1522
let standard_library_default = standard_library
1623

scripts/copyExes.js

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,48 @@
77
import * as child_process from "node:child_process";
88
import * as fs from "node:fs";
99
import * as path from "node:path";
10+
import { parseArgs } from "node:util";
1011
import { binDir } from "#cli/bins";
1112
import { compilerBinDir, ninjaDir, rewatchDir } from "#dev/paths";
1213

14+
const args = parseArgs({
15+
args: process.argv.slice(2),
16+
options: {
17+
all: {
18+
type: "boolean",
19+
},
20+
compiler: {
21+
type: "boolean",
22+
},
23+
ninja: {
24+
type: "boolean",
25+
},
26+
rewatch: {
27+
type: "boolean",
28+
},
29+
},
30+
});
31+
32+
const shouldCopyCompiler = args.values.all || args.values.compiler;
33+
const shouldCopyNinja = args.values.all || args.values.ninja;
34+
const shouldCopyRewatch = args.values.all || args.values.rewatch;
35+
36+
if (shouldCopyCompiler) {
37+
copyExe(compilerBinDir, "rescript");
38+
copyExe(compilerBinDir, "rescript-editor-analysis");
39+
copyExe(compilerBinDir, "rescript-tools");
40+
copyExe(compilerBinDir, "bsc");
41+
copyExe(compilerBinDir, "bsb_helper");
42+
}
43+
44+
if (shouldCopyNinja) {
45+
copyExe(ninjaDir, "ninja");
46+
}
47+
48+
if (shouldCopyRewatch) {
49+
copyExe(rewatchDir, "rewatch");
50+
}
51+
1352
/**
1453
* @param {string} dir
1554
* @param {string} exe
@@ -39,19 +78,3 @@ function copyExe(dir, exe) {
3978
fs.chmodSync(dest, mode);
4079
}
4180
}
42-
43-
if (process.argv.includes("-all") || process.argv.includes("-compiler")) {
44-
copyExe(compilerBinDir, "rescript");
45-
copyExe(compilerBinDir, "rescript-editor-analysis");
46-
copyExe(compilerBinDir, "rescript-tools");
47-
copyExe(compilerBinDir, "bsc");
48-
copyExe(compilerBinDir, "bsb_helper");
49-
}
50-
51-
if (process.argv.includes("-all") || process.argv.includes("-ninja")) {
52-
copyExe(ninjaDir, "ninja");
53-
}
54-
55-
if (process.argv.includes("-all") || process.argv.includes("-rewatch")) {
56-
copyExe(rewatchDir, "rewatch");
57-
}

0 commit comments

Comments
 (0)