5656 - { host: darwin-x64, runner: macos-13 }
5757 - { host: darwin-arm64, runner: macos-14 }
5858 - { host: win32-x64, runner: windows-2022 }
59- - { host: win32-arm64, runner: windows-11-arm }
59+ # win32-arm64 dropped: hermes' Boost.Context ARM64 assembler + CMake's
60+ # ASM_ARMASM linker support fail on windows-11-arm. The win32-x64
61+ # hermesc runs on ARM Windows via x64 emulation (HBC output is portable).
6062 steps :
6163 - name : Install toolchain (Linux)
6264 if : runner.os == 'Linux'
@@ -114,7 +116,10 @@ jobs:
114116 if-no-files-found : error
115117
116118 # ---------------------------------------------------------------------------
117- # QuickJS (bellard) — build the engine lib, then our blob-emitting shim.
119+ # QuickJS (bellard) — build via its own Makefile (libquickjs.a, which injects
120+ # -D_GNU_SOURCE -DCONFIG_VERSION), then link our blob-emitting shim.
121+ # Unix only: bellard QuickJS has no upstream Windows/MSVC support (use
122+ # QuickJS-NG for Windows).
118123 # ---------------------------------------------------------------------------
119124 quickjs :
120125 name : quickjs (${{ matrix.host }})
@@ -127,16 +132,12 @@ jobs:
127132 - { host: linux-arm64, runner: ubuntu-24.04-arm }
128133 - { host: darwin-x64, runner: macos-13 }
129134 - { host: darwin-arm64, runner: macos-14 }
130- - { host: win32-x64, runner: windows-2022 }
131- - { host: win32-arm64, runner: windows-11-arm }
132135 steps :
133136 - uses : actions/checkout@v4
134137 - name : Install toolchain (Linux)
135138 if : runner.os == 'Linux'
136139 run : sudo apt-get update && sudo apt-get install -y build-essential
137- - name : Install toolchain (Windows)
138- if : runner.os == 'Windows'
139- run : choco install llvm -y
140+ # macOS: make + clang ship with the Xcode command-line tools.
140141
141142 - name : Clone QuickJS
142143 shell : bash
@@ -148,22 +149,19 @@ jobs:
148149 git -C quickjs fetch --depth 1 origin "$ref"
149150 git -C quickjs -c advice.detachedHead=false checkout FETCH_HEAD
150151
151- - name : Build shim
152+ - name : Build lib + shim
152153 shell : bash
153154 env :
154155 SHIM : ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c
155156 run : |
156157 set -euxo pipefail
157158 cd quickjs
158- CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang"
159- # Compile the lib sources directly (avoids qjs/qjsc main() collisions).
160- # If bellard changes the source set, adjust this list.
161- libsrc="quickjs.c cutils.c libregexp.c libunicode.c"
162- [ -f dtoa.c ] && libsrc="$libsrc dtoa.c"
159+ # Use bellard's own Makefile so CONFIG_VERSION / _GNU_SOURCE and the
160+ # correct source set come from upstream.
161+ make -j"$(getconf _NPROCESSORS_ONLN)" libquickjs.a
163162 out="../out/quickjs/${{ matrix.host }}"; mkdir -p "$out"
164- bin="$out/nsbc-quickjs"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe"
165- $CC -O2 -DNSBC_MAGIC='"NSBCQJS"' -I. -o "$bin" "$SHIM" $libsrc -lm
166- "$bin" || true # usage line (exit 2) proves it links & runs
163+ cc -O2 -DNSBC_MAGIC='"NSBCQJS"' -I. -o "$out/nsbc-quickjs" "$SHIM" libquickjs.a -lm
164+ "$out/nsbc-quickjs" || true # usage line (exit 2) proves it links & runs
167165
168166 - uses : actions/upload-artifact@v4
169167 with :
@@ -215,14 +213,18 @@ jobs:
215213 SHIM : ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c
216214 run : |
217215 set -euxo pipefail
218- cmake -S quickjs-ng -B quickjs-ng/build -DCMAKE_BUILD_TYPE=Release -DBUILD_QJS_LIBC=OFF
219- cmake --build quickjs-ng/build --config Release
216+ # Build only the static engine lib target ('qjs' -> libqjs.a / qjs.lib);
217+ # skip the CLI/test executables.
218+ cmake -S quickjs-ng -B quickjs-ng/build -DCMAKE_BUILD_TYPE=Release
219+ cmake --build quickjs-ng/build --config Release --target qjs
220220 lib="$(find quickjs-ng/build -type f \( -name 'libqjs.a' -o -name 'qjs.lib' \) | head -n1)"
221221 test -n "$lib"
222- CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang"
222+ # Windows has no libm (math is in the CRT); only pass -lm off-Windows.
223+ CC="cc"; LIBM="-lm"
224+ if [ "${{ runner.os }}" = "Windows" ]; then CC="clang"; LIBM=""; fi
223225 out="out/quickjs-ng/${{ matrix.host }}"; mkdir -p "$out"
224226 bin="$out/nsbc-quickjs-ng"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe"
225- $CC -O2 -DNSBC_MAGIC='"NSBCNGS"' -I quickjs-ng -o "$bin" "$SHIM" "$lib" -lm
227+ $CC -O2 -DNSBC_MAGIC='"NSBCNGS"' -I quickjs-ng -o "$bin" "$SHIM" "$lib" $LIBM
226228 "$bin" || true
227229
228230 - uses : actions/upload-artifact@v4
@@ -232,11 +234,15 @@ jobs:
232234 if-no-files-found : error
233235
234236 # ---------------------------------------------------------------------------
235- # PrimJS — build the engine, then our LEPUS_* shim.
236- # NOTE: PrimJS's build system is nonstandard; the steps below are best-effort
237- # and will very likely need adjustment against lynx-family/primjs@develop
238- # (its actual CMake targets / include + lib paths). Treat the first CI run as
239- # the source of truth and pin once green.
237+ # PrimJS — build via its own toolchain: `hab sync` fetches gn + ninja + a
238+ # bundled clang + sysroot, then GN/ninja build the engine. We add our LEPUS_*
239+ # shim as a sibling GN executable (reusing the qjs-cli engine deps).
240+ #
241+ # Unix only, and NOT linux-arm64: PrimJS's envsetup.sh aborts on Windows, and
242+ # its DEPS only provides a linux sysroot for x86_64. So: linux-x64 + macOS.
243+ #
244+ # NOTE: this is the first automated PrimJS build; `hab sync` pulls a large
245+ # toolchain and the exact gn/ninja target may need tweaking on the first run.
240246 # ---------------------------------------------------------------------------
241247 primjs :
242248 name : primjs (${{ matrix.host }})
@@ -246,22 +252,13 @@ jobs:
246252 matrix :
247253 include :
248254 - { host: linux-x64, runner: ubuntu-24.04 }
249- - { host: linux-arm64, runner: ubuntu-24.04-arm }
250255 - { host: darwin-x64, runner: macos-13 }
251256 - { host: darwin-arm64, runner: macos-14 }
252- - { host: win32-x64, runner: windows-2022 }
253- - { host: win32-arm64, runner: windows-11-arm }
254257 steps :
255258 - uses : actions/checkout@v4
256- - name : Install toolchain (Linux)
259+ - name : Install prerequisites (Linux)
257260 if : runner.os == 'Linux'
258- run : sudo apt-get update && sudo apt-get install -y cmake ninja-build build-essential python3
259- - name : Install toolchain (macOS)
260- if : runner.os == 'macOS'
261- run : brew install cmake ninja
262- - name : Install toolchain (Windows)
263- if : runner.os == 'Windows'
264- run : choco install ninja llvm -y
261+ run : sudo apt-get update && sudo apt-get install -y python3 curl
265262
266263 - name : Clone PrimJS
267264 shell : bash
@@ -272,28 +269,41 @@ jobs:
272269 git -C primjs remote add origin "$PRIMJS_REPO"
273270 git -C primjs fetch --depth 1 origin "$ref"
274271 git -C primjs -c advice.detachedHead=false checkout FETCH_HEAD
275- # PrimJS vendors deps via a script in some layouts; run it if present.
276- if [ -f primjs/tools/hooks/generate_gni.py ]; then python3 primjs/tools/hooks/generate_gni.py || true; fi
277272
278- - name : Build engine + shim
273+ - name : Add shim as a GN target
279274 shell : bash
280275 env :
281276 SHIM : ${{ github.workspace }}/tools/bytecode-compiler/native/primjs-compile.c
282277 run : |
283278 set -euxo pipefail
284- # Best-effort CMake build of the PrimJS/quickjs static lib. Adjust the
285- # target and include/lib paths to match the repo once observed in CI.
286- cmake -S primjs -B primjs/build -DCMAKE_BUILD_TYPE=Release || {
287- echo "::warning::PrimJS cmake configure needs adjustment for this repo layout"; exit 1; }
288- cmake --build primjs/build --config Release
289- lib="$(find primjs/build -type f \( -name 'libquick*.a' -o -name 'libprimjs*.a' -o -name '*.lib' \) | head -n1)"
290- inc="$(dirname "$(find primjs -name quickjs.h | head -n1)")"
291- test -n "$lib" && test -n "$inc"
292- CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang"
293- out="out/primjs/${{ matrix.host }}"; mkdir -p "$out"
294- bin="$out/nsbc-primjs"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe"
295- $CC -O2 -I"$inc" -o "$bin" "$SHIM" "$lib" -lm
296- "$bin" || true
279+ # Build as C++ (.cc) to match the working qjs-cli target; the LEPUS_*
280+ # API is extern "C", so linkage is fine either way.
281+ cp "$SHIM" primjs/tools/qjs-cli/nsbc-primjs.cc
282+ # A standalone executable that links the same engine as qjs-cli.
283+ cat >> primjs/tools/qjs-cli/BUILD.gn <<'GN'
284+
285+ executable("nsbc-primjs") {
286+ cflags = [ "-Wno-c99-designator" ]
287+ sources = [ "nsbc-primjs.cc" ]
288+ include_dirs = [ "//include" ]
289+ deps = [ ":qjs_wasm_binding" ]
290+ configs += [ ":wasm_internal_config" ]
291+ }
292+ GN
293+
294+ - name : Build (hab sync + gn + ninja)
295+ shell : bash
296+ working-directory : primjs
297+ run : |
298+ set -euxo pipefail
299+ # hab (in-repo) fetches gn, ninja, the bundled clang toolchain + sysroot.
300+ source tools/envsetup.sh
301+ hab sync .
302+ gn gen out/Default --args="is_debug=false"
303+ ninja -C out/Default nsbc-primjs
304+ out="../out/primjs/${{ matrix.host }}"; mkdir -p "$out"
305+ cp out/Default/nsbc-primjs "$out/nsbc-primjs"
306+ "$out/nsbc-primjs" || true # usage line (exit 2) proves it links & runs
297307
298308 - uses : actions/upload-artifact@v4
299309 with :
0 commit comments