{{ message }}
add bytecode-compilers.yml workflow - #44
Merged
Merged
Conversation
Comment on lines
+48
to
+111
| name: hermes (${{ matrix.host }}) | ||
| runs-on: ${{ matrix.runner }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - { host: linux-x64, runner: ubuntu-24.04 } | ||
| - { host: linux-arm64, runner: ubuntu-24.04-arm } | ||
| - { host: darwin-x64, runner: macos-13 } | ||
| - { host: darwin-arm64, runner: macos-14 } | ||
| - { host: win32-x64, runner: windows-2022 } | ||
| - { host: win32-arm64, runner: windows-11-arm } | ||
| steps: | ||
| - name: Install toolchain (Linux) | ||
| if: runner.os == 'Linux' | ||
| run: sudo apt-get update && sudo apt-get install -y cmake ninja-build build-essential python3 | ||
| - name: Install toolchain (macOS) | ||
| if: runner.os == 'macOS' | ||
| run: brew install cmake ninja | ||
| - name: Install toolchain (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: choco install ninja -y | ||
|
|
||
| - name: Clone Hermes | ||
| shell: bash | ||
| run: git clone --depth 1 --branch "${{ github.event.inputs.hermes_ref || 'master' }}" "$HERMES_REPO" hermes | ||
|
|
||
| - name: Build hermesc (Unix) | ||
| if: runner.os != 'Windows' | ||
| shell: bash | ||
| run: | | ||
| set -euxo pipefail | ||
| cmake -S hermes -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DHERMES_BUILD_APPLE_FRAMEWORK=OFF | ||
| cmake --build build --target hermesc | ||
|
|
||
| - name: Build hermesc (Windows) | ||
| if: runner.os == 'Windows' | ||
| shell: bash | ||
| run: | | ||
| set -euxo pipefail | ||
| # Use the default (Visual Studio) generator; Ninja+MSVC also works if the | ||
| # VS dev environment is on PATH. | ||
| cmake -S hermes -B build -DCMAKE_BUILD_TYPE=Release | ||
| cmake --build build --target hermesc --config Release | ||
|
|
||
| - name: Stage binary | ||
| shell: bash | ||
| run: | | ||
| set -euxo pipefail | ||
| mkdir -p "out/hermes/${{ matrix.host }}" | ||
| bin="$(find build -type f \( -name hermesc -o -name hermesc.exe \) | head -n1)" | ||
| test -n "$bin" | ||
| cp "$bin" "out/hermes/${{ matrix.host }}/" | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: bytecode-compiler-hermes-${{ matrix.host }} | ||
| path: out/hermes/${{ matrix.host }} | ||
| if-no-files-found: error | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # QuickJS (bellard) — build the engine lib, then our blob-emitting shim. | ||
| # --------------------------------------------------------------------------- | ||
| quickjs: |
Comment on lines
+112
to
+163
| name: quickjs (${{ matrix.host }}) | ||
| runs-on: ${{ matrix.runner }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - { host: linux-x64, runner: ubuntu-24.04 } | ||
| - { host: linux-arm64, runner: ubuntu-24.04-arm } | ||
| - { host: darwin-x64, runner: macos-13 } | ||
| - { host: darwin-arm64, runner: macos-14 } | ||
| - { host: win32-x64, runner: windows-2022 } | ||
| - { host: win32-arm64, runner: windows-11-arm } | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install toolchain (Linux) | ||
| if: runner.os == 'Linux' | ||
| run: sudo apt-get update && sudo apt-get install -y build-essential | ||
| - name: Install toolchain (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: choco install llvm -y | ||
|
|
||
| - name: Clone QuickJS | ||
| shell: bash | ||
| run: git clone --depth 1 --branch "${{ github.event.inputs.quickjs_ref || 'master' }}" "$QUICKJS_REPO" quickjs | ||
|
|
||
| - name: Build shim | ||
| shell: bash | ||
| env: | ||
| SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c | ||
| run: | | ||
| set -euxo pipefail | ||
| cd quickjs | ||
| CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang" | ||
| # Compile the lib sources directly (avoids qjs/qjsc main() collisions). | ||
| # If bellard changes the source set, adjust this list. | ||
| libsrc="quickjs.c cutils.c libregexp.c libunicode.c" | ||
| [ -f dtoa.c ] && libsrc="$libsrc dtoa.c" | ||
| out="../out/quickjs/${{ matrix.host }}"; mkdir -p "$out" | ||
| bin="$out/nsbc-quickjs"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe" | ||
| $CC -O2 -DNSBC_MAGIC='"NSBCQJS"' -I. -o "$bin" "$SHIM" $libsrc -lm | ||
| "$bin" || true # usage line (exit 2) proves it links & runs | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: bytecode-compiler-quickjs-${{ matrix.host }} | ||
| path: out/quickjs/${{ matrix.host }} | ||
| if-no-files-found: error | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # QuickJS-NG — CMake build of libqjs, then our shim (same JS_* API). | ||
| # --------------------------------------------------------------------------- | ||
| quickjs-ng: |
Comment on lines
+164
to
+221
| name: quickjs-ng (${{ matrix.host }}) | ||
| runs-on: ${{ matrix.runner }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - { host: linux-x64, runner: ubuntu-24.04 } | ||
| - { host: linux-arm64, runner: ubuntu-24.04-arm } | ||
| - { host: darwin-x64, runner: macos-13 } | ||
| - { host: darwin-arm64, runner: macos-14 } | ||
| - { host: win32-x64, runner: windows-2022 } | ||
| - { host: win32-arm64, runner: windows-11-arm } | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install toolchain (Linux) | ||
| if: runner.os == 'Linux' | ||
| run: sudo apt-get update && sudo apt-get install -y cmake ninja-build build-essential | ||
| - name: Install toolchain (macOS) | ||
| if: runner.os == 'macOS' | ||
| run: brew install cmake ninja | ||
| - name: Install toolchain (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: choco install ninja llvm -y | ||
|
|
||
| - name: Clone QuickJS-NG | ||
| shell: bash | ||
| run: git clone --depth 1 --branch "${{ github.event.inputs.quickjs_ng_ref || 'master' }}" "$QUICKJS_NG_REPO" quickjs-ng | ||
|
|
||
| - name: Build lib + shim | ||
| shell: bash | ||
| env: | ||
| SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c | ||
| run: | | ||
| set -euxo pipefail | ||
| cmake -S quickjs-ng -B quickjs-ng/build -DCMAKE_BUILD_TYPE=Release -DBUILD_QJS_LIBC=OFF | ||
| cmake --build quickjs-ng/build --config Release | ||
| lib="$(find quickjs-ng/build -type f \( -name 'libqjs.a' -o -name 'qjs.lib' \) | head -n1)" | ||
| test -n "$lib" | ||
| CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang" | ||
| out="out/quickjs-ng/${{ matrix.host }}"; mkdir -p "$out" | ||
| bin="$out/nsbc-quickjs-ng"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe" | ||
| $CC -O2 -DNSBC_MAGIC='"NSBCNGS"' -I quickjs-ng -o "$bin" "$SHIM" "$lib" -lm | ||
| "$bin" || true | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: bytecode-compiler-quickjs-ng-${{ matrix.host }} | ||
| path: out/quickjs-ng/${{ matrix.host }} | ||
| if-no-files-found: error | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # PrimJS — build the engine, then our LEPUS_* shim. | ||
| # NOTE: PrimJS's build system is nonstandard; the steps below are best-effort | ||
| # and will very likely need adjustment against lynx-family/primjs@develop | ||
| # (its actual CMake targets / include + lib paths). Treat the first CI run as | ||
| # the source of truth and pin once green. | ||
| # --------------------------------------------------------------------------- | ||
| primjs: |
Comment on lines
+222
to
+277
| name: primjs (${{ matrix.host }}) | ||
| runs-on: ${{ matrix.runner }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - { host: linux-x64, runner: ubuntu-24.04 } | ||
| - { host: linux-arm64, runner: ubuntu-24.04-arm } | ||
| - { host: darwin-x64, runner: macos-13 } | ||
| - { host: darwin-arm64, runner: macos-14 } | ||
| - { host: win32-x64, runner: windows-2022 } | ||
| - { host: win32-arm64, runner: windows-11-arm } | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install toolchain (Linux) | ||
| if: runner.os == 'Linux' | ||
| run: sudo apt-get update && sudo apt-get install -y cmake ninja-build build-essential python3 | ||
| - name: Install toolchain (macOS) | ||
| if: runner.os == 'macOS' | ||
| run: brew install cmake ninja | ||
| - name: Install toolchain (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: choco install ninja llvm -y | ||
|
|
||
| - name: Clone PrimJS | ||
| shell: bash | ||
| run: | | ||
| git clone --depth 1 --branch "${{ github.event.inputs.primjs_ref || 'develop' }}" "$PRIMJS_REPO" primjs | ||
| # PrimJS vendors deps via a script in some layouts; run it if present. | ||
| if [ -f primjs/tools/hooks/generate_gni.py ]; then python3 primjs/tools/hooks/generate_gni.py || true; fi | ||
|
|
||
| - name: Build engine + shim | ||
| shell: bash | ||
| env: | ||
| SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/primjs-compile.c | ||
| run: | | ||
| set -euxo pipefail | ||
| # Best-effort CMake build of the PrimJS/quickjs static lib. Adjust the | ||
| # target and include/lib paths to match the repo once observed in CI. | ||
| cmake -S primjs -B primjs/build -DCMAKE_BUILD_TYPE=Release || { | ||
| echo "::warning::PrimJS cmake configure needs adjustment for this repo layout"; exit 1; } | ||
| cmake --build primjs/build --config Release | ||
| lib="$(find primjs/build -type f \( -name 'libquick*.a' -o -name 'libprimjs*.a' -o -name '*.lib' \) | head -n1)" | ||
| inc="$(dirname "$(find primjs -name quickjs.h | head -n1)")" | ||
| test -n "$lib" && test -n "$inc" | ||
| CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang" | ||
| out="out/primjs/${{ matrix.host }}"; mkdir -p "$out" | ||
| bin="$out/nsbc-primjs"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe" | ||
| $CC -O2 -I"$inc" -o "$bin" "$SHIM" "$lib" -lm | ||
| "$bin" || true | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: bytecode-compiler-primjs-${{ matrix.host }} | ||
| path: out/primjs/${{ matrix.host }} | ||
| if-no-files-found: error |
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Actions workflow intended to build and publish per-host bytecode compiler CLI artifacts for multiple JS engines (Hermes, QuickJS, QuickJS-NG, PrimJS), to support ahead-of-time bytecode generation compatible with the runtime’s shipped engine libraries.
Changes:
- Introduces
.github/workflows/bytecode-compilers.ymlwith a multi-engine, multi-host build matrix. - Clones upstream engine repositories and builds/packaging artifacts via
actions/upload-artifact@v4. - Defines workflow-dispatch inputs to pin engine revisions for bytecode compatibility.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+137
to
+141
| - name: Build shim | ||
| shell: bash | ||
| env: | ||
| SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c | ||
| run: | |
Comment on lines
+192
to
+196
| - name: Build lib + shim | ||
| shell: bash | ||
| env: | ||
| SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c | ||
| run: | |
Comment on lines
+253
to
+257
| - name: Build engine + shim | ||
| shell: bash | ||
| env: | ||
| SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/primjs-compile.c | ||
| run: | |
|
|
||
| - name: Clone Hermes | ||
| shell: bash | ||
| run: git clone --depth 1 --branch "${{ github.event.inputs.hermes_ref || 'master' }}" "$HERMES_REPO" hermes |
|
|
||
| - name: Clone QuickJS | ||
| shell: bash | ||
| run: git clone --depth 1 --branch "${{ github.event.inputs.quickjs_ref || 'master' }}" "$QUICKJS_REPO" quickjs |
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: bytecode-compiler-quickjs-ng-${{ matrix.host }} | ||
| path: out/quickjs-ng/${{ matrix.host }} |
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: bytecode-compiler-primjs-${{ matrix.host }} | ||
| path: out/primjs/${{ matrix.host }} |
| [ -f dtoa.c ] && libsrc="$libsrc dtoa.c" | ||
| out="../out/quickjs/${{ matrix.host }}"; mkdir -p "$out" | ||
| bin="$out/nsbc-quickjs"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe" | ||
| $CC -O2 -DNSBC_MAGIC='"NSBCQJS"' -I. -o "$bin" "$SHIM" $libsrc -lm |
| CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang" | ||
| out="out/quickjs-ng/${{ matrix.host }}"; mkdir -p "$out" | ||
| bin="$out/nsbc-quickjs-ng"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe" | ||
| $CC -O2 -DNSBC_MAGIC='"NSBCNGS"' -I quickjs-ng -o "$bin" "$SHIM" "$lib" -lm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.