add bytecode-compilers.yml workflow#44
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| 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: |
| 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: |
| 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: |
| 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.
| - name: Build shim | ||
| shell: bash | ||
| env: | ||
| SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c | ||
| run: | |
| - name: Build lib + shim | ||
| shell: bash | ||
| env: | ||
| SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c | ||
| run: | |
| - 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 |
| 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 |
No description provided.