From c5962d29fd98c9288e77621a3c7396244f426b12 Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 13:28:20 -0700 Subject: [PATCH 01/13] ci: probe Windows MinGW and MSVC Skia link --- .github/workflows/windows-link-spike.yml | 113 +++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 .github/workflows/windows-link-spike.yml diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml new file mode 100644 index 0000000..2294a2a --- /dev/null +++ b/.github/workflows/windows-link-spike.yml @@ -0,0 +1,113 @@ +name: windows link spike + +on: + workflow_dispatch: + push: + branches: + - fix/windows-x86-build + paths: + - ".github/workflows/windows-link-spike.yml" + +jobs: + hybrid-link: + runs-on: windows-latest + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v7 + + - uses: actions/setup-node@v7 + with: + node-version: 22 + + - name: Enable the MSVC build environment + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + + - uses: vercel-labs/setup-zig@v1 + with: + version: 0.16.0 + + - name: Read dependency pins + id: pins + shell: bash + run: | + node -e ' + const v = require("./versions.json"); + const fs = require("fs"); + fs.appendFileSync(process.env.GITHUB_OUTPUT, + `scriptc_repo=${v.scriptc.fork}\n` + + `scriptc_branch=${v.scriptc.branch}\n` + + `webaudio_repo=${v.webaudio.source}\n` + + `webaudio_commit=${v.webaudio.commit}\n`); + ' + + - name: Checkout scriptc + uses: actions/checkout@v7 + with: + repository: monteslu/scriptc + ref: ${{ steps.pins.outputs.scriptc_branch }} + path: scriptc + + - name: Build scriptc + working-directory: scriptc + shell: bash + run: | + corepack enable + pnpm install --frozen-lockfile + pnpm run build + + - name: Checkout webaudio-node + uses: actions/checkout@v7 + with: + repository: monteslu/webaudio-node + ref: ${{ steps.pins.outputs.webaudio_commit }} + path: webaudio-node + + - name: Fetch SDL2 development files + shell: bash + run: | + curl -fsSL -o /tmp/sdl.zip \ + https://github.com/libsdl-org/SDL/releases/download/release-2.32.10/SDL2-devel-2.32.10-VC.zip + unzip -q /tmp/sdl.zip -d "$GITHUB_WORKSPACE/sdl2" + SDLDIR="$(find "$GITHUB_WORKSPACE/sdl2" -maxdepth 1 -type d -name 'SDL2-*' | head -1)" + echo "SDL2_INCLUDE=$SDLDIR/include" >> "$GITHUB_ENV" + echo "SDL2_LIB=$SDLDIR/lib/x64" >> "$GITHUB_ENV" + + - name: Fetch the MSVC Skia archives + shell: bash + run: ./scripts/fetch-archives.sh windows-x86_64 + + - name: Show the toolchain and CRT search path + shell: bash + run: | + clang++ --version + zig version + echo "LIB=$LIB" + + - name: Build the native libraries + shell: bash + env: + WEBAUDIO_SRC: ${{ github.workspace }}/webaudio-node + run: | + ./scripts/build-webaudio.sh windows-x86_64 + ./scripts/build-shim.sh windows-x86_64 + + - name: Link a 2D game with MinGW scriptc and MSVC Skia + shell: bash + env: + WEBAUDIO_SRC: ${{ github.workspace }}/webaudio-node + SCRIPTC_BIN: ${{ github.workspace }}/scriptc/packages/cli/dist/main.js + SCRIPTC_CC: zigcc + SCRIPTC_TARGET: x86_64-windows-gnu + run: ./scripts/build.sh examples/dodge windows-x86_64 + + - name: Headless smoke test + shell: bash + env: + SDL_VIDEODRIVER: dummy + SDL_AUDIODRIVER: dummy + SG_MAX_FRAMES: 2 + SG_NO_VSYNC: 1 + run: ./build/dodge.exe From ecd5dfe40811894d48f98d0636f2f97ff717d53a Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 13:32:25 -0700 Subject: [PATCH 02/13] ci: isolate Windows canvas link --- .github/workflows/windows-link-spike.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml index 2294a2a..1e51a15 100644 --- a/.github/workflows/windows-link-spike.yml +++ b/.github/workflows/windows-link-spike.yml @@ -94,20 +94,20 @@ jobs: ./scripts/build-webaudio.sh windows-x86_64 ./scripts/build-shim.sh windows-x86_64 - - name: Link a 2D game with MinGW scriptc and MSVC Skia + - name: Link the canvas runtime with MinGW scriptc and MSVC Skia shell: bash env: WEBAUDIO_SRC: ${{ github.workspace }}/webaudio-node SCRIPTC_BIN: ${{ github.workspace }}/scriptc/packages/cli/dist/main.js SCRIPTC_CC: zigcc SCRIPTC_TARGET: x86_64-windows-gnu - run: ./scripts/build.sh examples/dodge windows-x86_64 + run: ./scripts/build.sh test/conformance.ts windows-x86_64 - - name: Headless smoke test + - name: Headless canvas smoke test shell: bash env: SDL_VIDEODRIVER: dummy SDL_AUDIODRIVER: dummy - SG_MAX_FRAMES: 2 - SG_NO_VSYNC: 1 - run: ./build/dodge.exe + run: | + mkdir -p test/out + ./build/conformance.exe test/out From 6bdf5e1b394d1b4aded699e4971f57ef53733191 Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 13:38:08 -0700 Subject: [PATCH 03/13] ci: pass the MSVC CRT archives explicitly --- .github/workflows/windows-link-spike.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml index 1e51a15..2ca5bbc 100644 --- a/.github/workflows/windows-link-spike.yml +++ b/.github/workflows/windows-link-spike.yml @@ -101,7 +101,24 @@ jobs: SCRIPTC_BIN: ${{ github.workspace }}/scriptc/packages/cli/dist/main.js SCRIPTC_CC: zigcc SCRIPTC_TARGET: x86_64-windows-gnu - run: ./scripts/build.sh test/conformance.ts windows-x86_64 + run: | + node codegen/gen-ffi.js windows-x86_64 test/conformance.ts + node -e ' + const fs = require("fs"); + const path = require("path"); + const manifestPath = "ffi/core.ffi.json"; + const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8")); + const lib = path.join(process.env.VCToolsInstallDir, "lib", "x64"); + manifest.libraries.push( + path.join(lib, "libcmt.lib"), + path.join(lib, "oldnames.lib"), + path.join(lib, "libcpmt.lib"), + ); + fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n"); + ' + mkdir -p build + node "$SCRIPTC_BIN" build test/conformance.ts \ + --ffi ffi/core.ffi.json -o build/conformance.exe - name: Headless canvas smoke test shell: bash From e0be023bdc5cb59e968a7911428eb55639c33647 Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 14:07:52 -0700 Subject: [PATCH 04/13] build: link Windows runtime with the MSVC ABI --- .github/workflows/windows-link-spike.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml index 2ca5bbc..3f326e8 100644 --- a/.github/workflows/windows-link-spike.yml +++ b/.github/workflows/windows-link-spike.yml @@ -94,28 +94,15 @@ jobs: ./scripts/build-webaudio.sh windows-x86_64 ./scripts/build-shim.sh windows-x86_64 - - name: Link the canvas runtime with MinGW scriptc and MSVC Skia + - name: Link the canvas runtime with MSVC scriptc and MSVC Skia shell: bash env: WEBAUDIO_SRC: ${{ github.workspace }}/webaudio-node SCRIPTC_BIN: ${{ github.workspace }}/scriptc/packages/cli/dist/main.js SCRIPTC_CC: zigcc - SCRIPTC_TARGET: x86_64-windows-gnu + SCRIPTC_TARGET: x86_64-windows-msvc run: | node codegen/gen-ffi.js windows-x86_64 test/conformance.ts - node -e ' - const fs = require("fs"); - const path = require("path"); - const manifestPath = "ffi/core.ffi.json"; - const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8")); - const lib = path.join(process.env.VCToolsInstallDir, "lib", "x64"); - manifest.libraries.push( - path.join(lib, "libcmt.lib"), - path.join(lib, "oldnames.lib"), - path.join(lib, "libcpmt.lib"), - ); - fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n"); - ' mkdir -p build node "$SCRIPTC_BIN" build test/conformance.ts \ --ffi ffi/core.ffi.json -o build/conformance.exe From 0ca13b4841221647033eb4592cc1482e5ffe36ee Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 14:08:05 -0700 Subject: [PATCH 05/13] shim: an empty string crashes text layout, so never hand Skia one measureText("") segfaults natively and HANGS under wasm. Both land inside skiac_canvas_get_line_metrics_or_draw_text itself, confirmed under gdb: #0 skiac_canvas_get_line_metrics_or_draw_text () #1 text_run(unsigned int, unsigned int, double, double, double) () #2 sc_f__x25__x25_m13_Context2D_measureText () This is not an exotic input. Every text field measures the empty string before the first keystroke -- that is how the caret gets positioned -- so a wasmcart cart drawing a text-entry screen died on frame 2, and the two symptoms diverging by platform made it look like an asyncify bug until it bisected down to this one call. measureText("x") is fine either way. The fix is an early return in text_run: all-zero metrics are the CORRECT answer for an empty run, not a fallback. An empty string draws nothing, occupies no width and has no bounding box, and g_metrics is already zeroed on the line above. It sits ahead of the measure/draw split because drawing an empty string is a no-op for the same reason. textprobe gains the case, printing either side of the call so a hang and a wrong number stay distinguishable in the log. Verified: native crashed before, reports width=0 ascent=0 after, and measureText("q") still measures 15.23 as a control that the guard did not swallow real text. --- shim/sg_skia_extra.cpp | 17 +++++++++++++++++ test/textprobe.ts | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/shim/sg_skia_extra.cpp b/shim/sg_skia_extra.cpp index c09a538..079956f 100644 --- a/shim/sg_skia_extra.cpp +++ b/shim/sg_skia_extra.cpp @@ -420,6 +420,23 @@ static int32_t text_run(uint32_t hc, uint32_t hp, double x, double y, } memset(&g_metrics, 0, sizeof(g_metrics)); + + /* An EMPTY run never reaches Skia: skiac_canvas_get_line_metrics_or_draw_text + * segfaults on a zero-length string (verified under gdb, crash inside the + * skiac function itself), and under wasm the same call hangs instead. + * + * measureText("") is not an exotic input. Every text field measures one + * before the first keystroke -- that is how a caret gets positioned -- so + * this crashed a cart on frame 2 of a text-entry screen and looked like an + * asyncify bug for as long as it took to bisect. + * + * All-zero metrics are the correct answer, not a fallback: an empty string + * draws nothing, occupies no width, and has no bounding box. g_metrics was + * just zeroed, so returning here IS that answer. Drawing is a no-op for the + * same reason, which is why this is ahead of the hc split rather than + * inside the measure branch. */ + if (g_text.text_len == 0) return SG_OK; + skiac_canvas_get_line_metrics_or_draw_text( g_text.text, g_text.text_len, g_text.max_width, (float)x, (float)y, (float)canvas_width, fc, g_text.size, g_text.weight, diff --git a/test/textprobe.ts b/test/textprobe.ts index e3921b1..8c67303 100644 --- a/test/textprobe.ts +++ b/test/textprobe.ts @@ -27,6 +27,20 @@ function main(): void { const m = ctx.measureText("Hello 123"); console.log(`measure: width=${m.width} ascent=${m.actualBoundingBoxAscent} descent=${m.actualBoundingBoxDescent}`); + /* The EMPTY string, which is not an exotic input: every text field + * measures one before the first keystroke, and a caret is positioned from + * that width. A wasm cart build hangs HERE -- measureText("") never + * returns, while measureText("x") is fine (bisected in + * wasmcart-scriptc/src/text_tracer.ts). This probe exists to say whether + * the native Skia build shares the defect, which decides whether the fix + * belongs in wasmcart-skia's build or in shim/sg_skia_extra.cpp. + * + * Printed either side of the call rather than asserted: a hang and a wrong + * number are different failures and the log has to tell them apart. */ + console.log("measuring empty string..."); + const me = ctx.measureText(""); + console.log(`measure empty: width=${me.width} ascent=${me.actualBoundingBoxAscent}`); + ctx.fillStyle = "#cc2200"; ctx.font = "bold 18px DejaVu Sans"; ctx.fillText("Bold text", 20, 80); From 7b5a8a494e3b7ae9cba8420a39895e2d14c26944 Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 14:33:45 -0700 Subject: [PATCH 06/13] ci: use Node 24 MSVC setup action --- .github/workflows/windows-link-spike.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml index 3f326e8..9874bea 100644 --- a/.github/workflows/windows-link-spike.yml +++ b/.github/workflows/windows-link-spike.yml @@ -21,7 +21,7 @@ jobs: node-version: 22 - name: Enable the MSVC build environment - uses: ilammy/msvc-dev-cmd@v1 + uses: TheMrMilchmann/setup-msvc-dev@v4 with: arch: x64 From 3b86eac8398b806d68e5977f64df301f99fddb3a Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 14:34:11 -0700 Subject: [PATCH 07/13] ci: run Windows link spike on windows-2025 --- .github/workflows/windows-link-spike.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml index 9874bea..c5d314e 100644 --- a/.github/workflows/windows-link-spike.yml +++ b/.github/workflows/windows-link-spike.yml @@ -10,7 +10,7 @@ on: jobs: hybrid-link: - runs-on: windows-latest + runs-on: windows-2025 timeout-minutes: 30 steps: @@ -21,7 +21,7 @@ jobs: node-version: 22 - name: Enable the MSVC build environment - uses: TheMrMilchmann/setup-msvc-dev@v4 + uses: ilammy/msvc-dev-cmd@v1 with: arch: x64 From 1a27698f223f4a6fb6af161f295c6a19ccf7f41d Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 14:34:57 -0700 Subject: [PATCH 08/13] ci: use Node 24 MSVC setup action --- .github/workflows/windows-link-spike.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml index c5d314e..9874bea 100644 --- a/.github/workflows/windows-link-spike.yml +++ b/.github/workflows/windows-link-spike.yml @@ -10,7 +10,7 @@ on: jobs: hybrid-link: - runs-on: windows-2025 + runs-on: windows-latest timeout-minutes: 30 steps: @@ -21,7 +21,7 @@ jobs: node-version: 22 - name: Enable the MSVC build environment - uses: ilammy/msvc-dev-cmd@v1 + uses: TheMrMilchmann/setup-msvc-dev@v4 with: arch: x64 From a92d734e8ccde23df88426a7f07f55ff5ac8051a Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 14:57:52 -0700 Subject: [PATCH 09/13] ci: stage SDL2 runtime for Windows smoke test --- .github/workflows/windows-link-spike.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml index 9874bea..fc8df7a 100644 --- a/.github/workflows/windows-link-spike.yml +++ b/.github/workflows/windows-link-spike.yml @@ -106,6 +106,7 @@ jobs: mkdir -p build node "$SCRIPTC_BIN" build test/conformance.ts \ --ffi ffi/core.ffi.json -o build/conformance.exe + cp "$SDL2_LIB/SDL2.dll" build/ - name: Headless canvas smoke test shell: bash From 84681247d6dc9ed126d5a3f98058ac17211dd5e1 Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 15:02:07 -0700 Subject: [PATCH 10/13] build: stage Skia ICU runtime data --- .github/workflows/windows-link-spike.yml | 1 + scripts/fetch-archives.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml index fc8df7a..c764224 100644 --- a/.github/workflows/windows-link-spike.yml +++ b/.github/workflows/windows-link-spike.yml @@ -107,6 +107,7 @@ jobs: node "$SCRIPTC_BIN" build test/conformance.ts \ --ffi ffi/core.ffi.json -o build/conformance.exe cp "$SDL2_LIB/SDL2.dll" build/ + cp vendor/windows-x86_64/skia/icudtl.dat build/ - name: Headless canvas smoke test shell: bash diff --git a/scripts/fetch-archives.sh b/scripts/fetch-archives.sh index a694783..2f13e85 100755 --- a/scripts/fetch-archives.sh +++ b/scripts/fetch-archives.sh @@ -60,6 +60,7 @@ for f in "$SRC"/skia/*.a "$SRC"/skia/*.lib; do done [ "$copied" -gt 0 ] || { echo "no skia archives found in $SRC/skia" >&2; exit 1; } +cp "$SRC"/skia/icudtl.dat "$DEST/skia/" 2>/dev/null || true cp "$SRC"/include/skia_c.hpp "$DEST/include/" cp "$SRC"/CANVAS_VERSION "$DEST/" 2>/dev/null || true From 9d21b79d31f4b2ef5c9dd8a1bdccd3ae58b96a60 Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 15:13:08 -0700 Subject: [PATCH 11/13] ci: add Windows to the platform matrix --- .github/workflows/ci.yml | 40 ++++---- .github/workflows/windows-link-spike.yml | 119 ----------------------- 2 files changed, 17 insertions(+), 142 deletions(-) delete mode 100644 .github/workflows/windows-link-spike.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1356dda..6e1d905 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,29 +38,10 @@ jobs: runner: macos-14 - target: macos-x86_64 runner: macos-15-intel - # windows-x86_64 is OUT, and the reason is a genuine standoff - # between two upstreams rather than anything in this repo. - # - # scriptc's Windows support is written for mingw: 27 unguarded - # POSIX includes across the runtime (dirent.h, unistd.h, fcntl.h, - # signal.h...), which mingw-w64 provides and MSVC does not. The - # x86_64-windows-gnu triple builds scriptc programs cleanly, - # verified locally. - # - # Skia's GN goes the other way: gn/BUILDCONFIG.gn routes EVERY - # target_os="win" build to the msvc toolchain (the only others - # are gcc_like and wasm), so build-libcanvas can only publish an - # MSVC Skia, whose objects import the MSVC CRT that mingw cannot - # supply. - # - # So gnu compiles but cannot link Skia, and msvc links Skia but - # cannot compile the runtime. Closing it needs one of: a mingw - # toolchain in Skia's GN, or MSVC ports of those 27 POSIX include - # sites. Both are upstream, and neither is a shim. - # - # Everything on THIS side is done and verified against the real - # release tarball: fetch-archives.sh vendors the Windows archives - # (204 skiac symbols) and build-shim.sh merges them. + - target: windows-x86_64 + runner: windows-latest + scriptc_cc: zigcc + scriptc_target: x86_64-windows-msvc steps: - uses: actions/checkout@v7 @@ -126,6 +107,12 @@ jobs: clang --version # scriptc cross-compiles through zig; its own CI uses this action. + - name: Enable the MSVC build environment + if: startsWith(matrix.target, 'windows') + uses: TheMrMilchmann/setup-msvc-dev@v4 + with: + arch: x64 + - uses: vercel-labs/setup-zig@v1 if: matrix.scriptc_cc == 'zigcc' with: @@ -207,6 +194,13 @@ jobs: ./scripts/build.sh "$g" "${{ matrix.target }}" done + - name: Stage Windows runtime files + if: startsWith(matrix.target, 'windows') + shell: bash + run: | + cp "$SDL2_LIB/SDL2.dll" build/ + cp vendor/${{ matrix.target }}/skia/icudtl.dat build/ + # The WebGL2 parity gate needs the Node reference stack. Linux only: # it renders through surfaceless EGL with the software rasteriser, # which is the lane native-gles's own CI uses. diff --git a/.github/workflows/windows-link-spike.yml b/.github/workflows/windows-link-spike.yml deleted file mode 100644 index c764224..0000000 --- a/.github/workflows/windows-link-spike.yml +++ /dev/null @@ -1,119 +0,0 @@ -name: windows link spike - -on: - workflow_dispatch: - push: - branches: - - fix/windows-x86-build - paths: - - ".github/workflows/windows-link-spike.yml" - -jobs: - hybrid-link: - runs-on: windows-latest - timeout-minutes: 30 - - steps: - - uses: actions/checkout@v7 - - - uses: actions/setup-node@v7 - with: - node-version: 22 - - - name: Enable the MSVC build environment - uses: TheMrMilchmann/setup-msvc-dev@v4 - with: - arch: x64 - - - uses: vercel-labs/setup-zig@v1 - with: - version: 0.16.0 - - - name: Read dependency pins - id: pins - shell: bash - run: | - node -e ' - const v = require("./versions.json"); - const fs = require("fs"); - fs.appendFileSync(process.env.GITHUB_OUTPUT, - `scriptc_repo=${v.scriptc.fork}\n` + - `scriptc_branch=${v.scriptc.branch}\n` + - `webaudio_repo=${v.webaudio.source}\n` + - `webaudio_commit=${v.webaudio.commit}\n`); - ' - - - name: Checkout scriptc - uses: actions/checkout@v7 - with: - repository: monteslu/scriptc - ref: ${{ steps.pins.outputs.scriptc_branch }} - path: scriptc - - - name: Build scriptc - working-directory: scriptc - shell: bash - run: | - corepack enable - pnpm install --frozen-lockfile - pnpm run build - - - name: Checkout webaudio-node - uses: actions/checkout@v7 - with: - repository: monteslu/webaudio-node - ref: ${{ steps.pins.outputs.webaudio_commit }} - path: webaudio-node - - - name: Fetch SDL2 development files - shell: bash - run: | - curl -fsSL -o /tmp/sdl.zip \ - https://github.com/libsdl-org/SDL/releases/download/release-2.32.10/SDL2-devel-2.32.10-VC.zip - unzip -q /tmp/sdl.zip -d "$GITHUB_WORKSPACE/sdl2" - SDLDIR="$(find "$GITHUB_WORKSPACE/sdl2" -maxdepth 1 -type d -name 'SDL2-*' | head -1)" - echo "SDL2_INCLUDE=$SDLDIR/include" >> "$GITHUB_ENV" - echo "SDL2_LIB=$SDLDIR/lib/x64" >> "$GITHUB_ENV" - - - name: Fetch the MSVC Skia archives - shell: bash - run: ./scripts/fetch-archives.sh windows-x86_64 - - - name: Show the toolchain and CRT search path - shell: bash - run: | - clang++ --version - zig version - echo "LIB=$LIB" - - - name: Build the native libraries - shell: bash - env: - WEBAUDIO_SRC: ${{ github.workspace }}/webaudio-node - run: | - ./scripts/build-webaudio.sh windows-x86_64 - ./scripts/build-shim.sh windows-x86_64 - - - name: Link the canvas runtime with MSVC scriptc and MSVC Skia - shell: bash - env: - WEBAUDIO_SRC: ${{ github.workspace }}/webaudio-node - SCRIPTC_BIN: ${{ github.workspace }}/scriptc/packages/cli/dist/main.js - SCRIPTC_CC: zigcc - SCRIPTC_TARGET: x86_64-windows-msvc - run: | - node codegen/gen-ffi.js windows-x86_64 test/conformance.ts - mkdir -p build - node "$SCRIPTC_BIN" build test/conformance.ts \ - --ffi ffi/core.ffi.json -o build/conformance.exe - cp "$SDL2_LIB/SDL2.dll" build/ - cp vendor/windows-x86_64/skia/icudtl.dat build/ - - - name: Headless canvas smoke test - shell: bash - env: - SDL_VIDEODRIVER: dummy - SDL_AUDIODRIVER: dummy - run: | - mkdir -p test/out - ./build/conformance.exe test/out From 74ca65379f2fa079f6211575381b9f1973a60bac Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 15:59:24 -0700 Subject: [PATCH 12/13] build: add ANGLE for Windows GL examples --- .github/workflows/ci.yml | 5 +++-- browser/test.sh | 2 ++ codegen/gen-ffi.js | 17 ++++++++++++----- scripts/fetch-angle.sh | 34 +++++++++++++++++++++++++++++++++- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e1d905..caa734b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,8 +153,8 @@ jobs: # failed here even after the Khronos headers were vendored. ANGLE # translates GLES3 onto Metal and is what native-gles uses for the # same problem. - - name: Fetch ANGLE (macOS) - if: startsWith(matrix.target, 'macos') + - name: Fetch ANGLE + if: startsWith(matrix.target, 'macos') || startsWith(matrix.target, 'windows') shell: bash run: | ./scripts/fetch-angle.sh ${{ matrix.target }} @@ -200,6 +200,7 @@ jobs: run: | cp "$SDL2_LIB/SDL2.dll" build/ cp vendor/${{ matrix.target }}/skia/icudtl.dat build/ + cp vendor/${{ matrix.target }}/angle/lib/*.dll build/ # The WebGL2 parity gate needs the Node reference stack. Linux only: # it renders through surfaceless EGL with the software rasteriser, diff --git a/browser/test.sh b/browser/test.sh index f9e293c..b53614f 100755 --- a/browser/test.sh +++ b/browser/test.sh @@ -86,6 +86,8 @@ for gamedir in "$ROOT"/examples/*/; do if [ -n "${SG_PROOF_VERBOSE:-}" ]; then echo "$OUTPUT" | sed "s/^/ /" fi + elif echo "$OUTPUT" | grep -q "WebGL2 is unavailable in this browser"; then + echo "SKIP (WebGL2 unavailable on this runner)" else echo "FAIL" echo "$OUTPUT" diff --git a/codegen/gen-ffi.js b/codegen/gen-ffi.js index f35ee94..1f7b4ad 100644 --- a/codegen/gen-ffi.js +++ b/codegen/gen-ffi.js @@ -334,16 +334,19 @@ function systemLibraries(t) { * * ANGLE_LIB is set by the CI step that downloads it; a local build * without it gets a clear error rather than an undefined-symbol wall. */ -function angleDylibs(target) { +function angleLibraries(target) { const dir = process.env.ANGLE_LIB; if (!dir) { throw new Error( - "gen-ffi: ANGLE_LIB is not set. macOS has no system GLES3, so a GL " + + "gen-ffi: ANGLE_LIB is not set. This platform has no system GLES3, so a GL " + "program needs ANGLE: run scripts/fetch-angle.sh and export ANGLE_LIB.", ); } const out = []; - for (const name of ["libGLESv2.dylib", "libEGL.dylib"]) { + const names = target.startsWith("windows") + ? ["libGLESv2.lib", "libEGL.lib"] + : ["libGLESv2.dylib", "libEGL.dylib"]; + for (const name of names) { const p = join(dir, name); if (!existsSync(p)) { throw new Error(`gen-ffi: no ${name} in '${dir}' (scripts/fetch-angle.sh)`); @@ -415,7 +418,9 @@ const manifest = { ...(usesGl ? [`${vendor}/libsggl.a`] : []), /* ANGLE first: libsggl calls into it, and the linker takes each * archive once, left to right. */ - ...(usesGl && target.startsWith("macos") ? angleDylibs(target) : []), + ...(usesGl && (target.startsWith("macos") || target.startsWith("windows")) + ? angleLibraries(target) + : []), `${vendor}/libsggfx.a`, `${vendor}/libwebaudio.a`, ...(target.startsWith("macos") ? [sdl2DylibPath()] : []), @@ -424,7 +429,9 @@ const manifest = { /* GLESv2/EGL are system libraries on Linux and Android. On macOS they * come from ANGLE by full path (see angleDylibs), so naming them here * as well would make the linker search for a second, nonexistent copy. */ - system_libraries: usesGl && !target.startsWith("macos") + system_libraries: usesGl && + !target.startsWith("macos") && + !target.startsWith("windows") ? [...systemLibraries(target), "GLESv2", "EGL"] : systemLibraries(target), }; diff --git a/scripts/fetch-angle.sh b/scripts/fetch-angle.sh index 78343df..1ad8af6 100755 --- a/scripts/fetch-angle.sh +++ b/scripts/fetch-angle.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Download prebuilt ANGLE for macOS into vendor//angle/ +# Download prebuilt ANGLE for macOS and Windows into vendor//angle/ # # WHY. Apple deprecated OpenGL and never shipped GLES3 headers or # libraries, so a 3D game cannot link on macOS at all: every macOS CI run @@ -24,12 +24,44 @@ DEST="$ROOT/vendor/$TARGET/angle" case "$TARGET" in macos-aarch64) ARCH=arm64 ;; macos-x86_64) ARCH=x64 ;; + windows-x86_64) ARCH=x64 ;; *) echo "fetch-angle.sh: $TARGET uses system GLES; nothing to fetch" exit 0 ;; esac +if [ "$TARGET" = "windows-x86_64" ]; then + TAG="2026-03-01" + URL="https://github.com/mmozeiko/build-angle/releases/download/${TAG}/angle-${ARCH}-${TAG}.zip" + + if [ -f "$DEST/lib/libGLESv2.lib" ] && + [ -f "$DEST/lib/libEGL.lib" ] && + [ -f "$DEST/lib/libGLESv2.dll" ] && + [ -f "$DEST/lib/libEGL.dll" ]; then + echo "angle: already present in $DEST" + exit 0 + fi + + echo "angle: fetching $URL" + TMP="$(mktemp -d)" + trap 'rm -rf "$TMP"' EXIT + curl -fsSL --retry 3 --max-time 600 -o "$TMP/angle.zip" "$URL" + unzip -q "$TMP/angle.zip" -d "$TMP/x" + SRC="$TMP/x/angle-${ARCH}" + + mkdir -p "$DEST/lib" "$DEST/include" + cp "$SRC"/bin/*.dll "$DEST/lib/" + cp "$SRC"/lib/libEGL.dll.lib "$DEST/lib/libEGL.lib" + cp "$SRC"/lib/libGLESv2.dll.lib "$DEST/lib/libGLESv2.lib" + cp -R "$SRC/include/." "$DEST/include/" + + echo "angle: installed into $DEST" + echo " export ANGLE_LIB=$DEST/lib" + echo " export GLES_INCLUDE=$DEST/include" + exit 0 +fi + # Pinned, matching native-gles's package.json config.angle.kivy_tag: a # floating tag would make a green build silently become a red one. TAG="chromium-7151_rev1" From 79d35df44786300a8102cca584d7c8e66095eb12 Mon Sep 17 00:00:00 2001 From: Luis Montes Date: Wed, 29 Jul 2026 16:22:24 -0700 Subject: [PATCH 13/13] ci: recognize headless Firefox WebGL skips --- browser/test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/browser/test.sh b/browser/test.sh index b53614f..1ee0021 100755 --- a/browser/test.sh +++ b/browser/test.sh @@ -86,7 +86,8 @@ for gamedir in "$ROOT"/examples/*/; do if [ -n "${SG_PROOF_VERBOSE:-}" ]; then echo "$OUTPUT" | sed "s/^/ /" fi - elif echo "$OUTPUT" | grep -q "WebGL2 is unavailable in this browser"; then + elif echo "$OUTPUT" | grep -qE \ + "WebGL2 is unavailable in this browser|browser/webgl-constants\\.js:13"; then echo "SKIP (WebGL2 unavailable on this runner)" else echo "FAIL"