Skip to content

Commit 48ddfe4

Browse files
committed
fix
1 parent 04e416c commit 48ddfe4

File tree

6 files changed

+84
-68
lines changed

6 files changed

+84
-68
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 25 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,20 @@ 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'
73-
run: cargo build --manifest-path rewatch/Cargo.toml --target ${{matrix.rust-target}} --release
74-
75-
- name: Copy rewatch exe to platform bin dir
7678
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
79+
cargo build --manifest-path rewatch/Cargo.toml --target ${{ matrix.rust-target }} --release
80+
cp rewatch/target/${{ matrix.rust-target }}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch/rewatch.exe
81+
shell: bash
8282

8383
- name: "Upload artifact: rewatch binary"
8484
uses: actions/upload-artifact@v4
8585
with:
86-
name: rewatch-${{env.artifact_dir_name}}
87-
path: ${{ env.artifact_dir_name }}
86+
name: rewatch-${{ matrix.node-target }}
87+
path: rewatch/rewatch.exe
8888

8989
build-compiler:
9090
strategy:
@@ -95,21 +95,26 @@ jobs:
9595
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
9696
upload_binaries: true
9797
upload_libs: true
98+
node-target: linux-x64
9899
- os: ubuntu-24.04-arm # ARM
99100
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
100101
upload_binaries: true
101102
# Build the playground compiler and run the benchmarks on the fastest runner
102103
build_playground: true
103104
benchmarks: true
105+
node-target: linux-arm64
104106
- os: macos-13 # x64
105107
ocaml_compiler: 5.3.0
106108
upload_binaries: true
109+
node-target: darwin-x64
107110
- os: macos-14 # ARM
108111
ocaml_compiler: 5.3.0
109112
upload_binaries: true
113+
node-target: darwin-arm64
110114
- os: windows-latest
111115
ocaml_compiler: 5.3.0
112116
upload_binaries: true
117+
node-target: win32-x64
113118

114119
# Verify that the compiler still builds with older OCaml versions
115120
- os: ubuntu-24.04
@@ -144,9 +149,6 @@ jobs:
144149
cache: yarn
145150
node-version-file: .nvmrc
146151

147-
- name: Get artifact dir name
148-
run: node .github/workflows/get_artifact_dir_name.js
149-
150152
- name: Install dependencies (Linux)
151153
if: runner.os == 'Linux'
152154
uses: awalsh128/[email protected]
@@ -303,13 +305,13 @@ jobs:
303305
run: yarn install
304306

305307
- name: Copy compiler exes to platform bin dir
306-
run: node ./scripts/copyExes.js -compiler
308+
run: node scripts/copyExes.js --compiler
307309

308310
- name: Restore ninja build cache
309311
id: ninja-build-cache
310312
uses: actions/cache@v4
311313
with:
312-
path: ${{ env.artifact_dir_name }}/ninja.exe
314+
path: packages/@rescript/${{ matrix.node-target }}/bin/ninja.exe
313315
key: ninja-build-v1-${{ matrix.os }}-${{ hashFiles('ninja/src/**') }}
314316

315317
- name: Setup Python for ninja build
@@ -336,7 +338,7 @@ jobs:
336338

337339
- name: Copy ninja exe to platform bin dir
338340
if: steps.ninja-build-cache.outputs.cache-hit != 'true'
339-
run: node ./scripts/copyExes.js -ninja
341+
run: node scripts/copyExes.js --ninja
340342

341343
- name: "Syntax: Run roundtrip tests"
342344
if: ${{ runner.os != 'Windows' }}
@@ -423,8 +425,8 @@ jobs:
423425
if: matrix.upload_binaries
424426
uses: actions/upload-artifact@v4
425427
with:
426-
name: binaries-${{ env.artifact_dir_name }}
427-
path: ${{ env.artifact_dir_name }}
428+
name: binaries-${{ matrix.node-target }}
429+
path: packages/@rescript/${{ matrix.node-target }}/bin
428430

429431
- name: "Upload artifacts: lib/ocaml"
430432
if: matrix.upload_libs
@@ -491,15 +493,15 @@ jobs:
491493
matrix:
492494
include:
493495
- os: macos-13
494-
target: darwin-x64
496+
node-target: darwin-x64
495497
- os: macos-14
496-
target: darwin-arm64
498+
node-target: darwin-arm64
497499
- os: ubuntu-24.04
498-
target: linux-x64
500+
node-target: linux-x64
499501
- os: ubuntu-24.04-arm
500-
target: linux-arm64
502+
node-target: linux-arm64
501503
- os: windows-latest
502-
target: win32-x64
504+
node-target: win32-x64
503505

504506
runs-on: ${{ matrix.os }}
505507

@@ -535,7 +537,7 @@ jobs:
535537
run: |
536538
npm i --ignore-scripts --no-audit \
537539
rescript-${{ needs.package.outputs.rescript_version }}.tgz \
538-
rescript-${{ matrix.target }}-${{ needs.package.outputs.rescript_version }}.tgz
540+
rescript-${{ matrix.node-target }}-${{ needs.package.outputs.rescript_version }}.tgz
539541
shell: bash
540542
working-directory: ${{ steps.tmp-dir.outputs.path }}
541543

.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-x64/* rewatch-darwin-x64/* "packages/@rescript/darwin-x64/bin"
34+
mv -f binaries-darwin-arm64/* rewatch-darwin-arm64/* "packages/@rescript/darwin-arm64/bin"
35+
mv -f binaries-linux-x64/* rewatch-linux-x64/* "packages/@rescript/linux-x64/bin"
36+
mv -f binaries-linux-arm64/* rewatch-linux-arm64/* "packages/@rescript/linux-arm64/bin"
37+
mv -f binaries-win32-x64/* rewatch-win32-x64/* "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)