diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caa734b..9de6b22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,11 +148,8 @@ jobs: brew install sdl2 pkg-config ffmpeg webp brew install llvm || true - # ANGLE, macOS only. Apple deprecated OpenGL and never shipped GLES3, - # so a 3D example cannot link at all without it -- every macOS run - # failed here even after the Khronos headers were vendored. ANGLE - # translates GLES3 onto Metal and is what native-gles uses for the - # same problem. + # macOS and Windows use pinned ANGLE builds for GLES3. Linux uses its + # system EGL/GLES libraries. - name: Fetch ANGLE if: startsWith(matrix.target, 'macos') || startsWith(matrix.target, 'windows') shell: bash diff --git a/README.md b/README.md index c87746e..57e3d04 100644 --- a/README.md +++ b/README.md @@ -97,27 +97,18 @@ real URLs rather than filenames. | linux-aarch64 | ubuntu-24.04-arm | | | macos-aarch64 | macos-14 | frameworks via Mach-O linker options | | macos-x86_64 | macos-15-intel | | +| windows-x86_64 | windows-latest | MSVC ABI via `zig cc`; SDL2, ANGLE, and Skia ICU runtime files staged beside the executable | Each target builds on its own runner rather than cross-compiling. scriptc can cross-compile, but Skia, SDL2 and the audio graph are per-platform binaries, so only a native runner links a real result. -Windows is not a target yet, and the blocker is a standoff between two -upstreams rather than anything here. scriptc's Windows support is built for -mingw: 16 of its 54 runtime translation units include POSIX headers -(`dirent.h`, `unistd.h`, `poll.h`) unguarded, which mingw-w64 provides and -MSVC does not. Skia's GN goes the other way, routing every `target_os="win"` -build to its `msvc` toolchain, so build-libcanvas can only publish an MSVC -Skia whose objects import a CRT mingw cannot supply. Verified locally: the -gnu triple compiles scriptc programs cleanly and cannot link Skia; the MSVC -triple links Skia and cannot compile the runtime. - -Everything on this side is done: `fetch-archives.sh` vendors the Windows -archives (204 skiac symbols) and `build-shim.sh` merges them, both checked -against the real release tarball. Two of the MSVC-side compiler gaps are -already fixed on branches (see the table above). The likely path to Windows -is a wasmcart build rather than a native one, which avoids the toolchain -question entirely. +Windows uses the MSVC ABI end to end. `scriptc` targets +`x86_64-windows-msvc` through `zig cc`, its runtime uses the static MSVC CRT, +and Skia comes from the matching MSVC build-libcanvas release. SDL2 and +ANGLE use their VC import libraries; `SDL2.dll`, ANGLE's DLLs, and Skia's +`icudtl.dat` are staged beside the executable. CI builds every example and +runs the same headless suite as the other native targets. **Android is blocked upstream**: scriptc has no Android support, and its cross path goes through `zig cc`, which cannot be pointed at an NDK @@ -186,9 +177,10 @@ pins them). Each has a default location and an environment override. | [scriptc](https://github.com/vercel-labs/scriptc) | `../scriptc/packages/cli/dist/main.js` (a sibling checkout) | `SCRIPTC_BIN` | Build from the `game-integration` branch of -[monteslu/scriptc](https://github.com/monteslu/scriptc), which carries two -compiler fixes this project needs. Each lives on its own topic branch, kept -separate and self-contained so any one can go upstream on its own: +[monteslu/scriptc](https://github.com/monteslu/scriptc). It carries the FFI +fix and the Windows MSVC runtime/driver support this project needs. The +original issue-focused branches remain separate so they can go upstream on +their own: | Branch | What it fixes | | --- | --- | @@ -203,7 +195,7 @@ Run the two vendor steps once, then build: ```sh ./scripts/fetch-archives.sh # vendor//libskiac.a + headers ./scripts/build-webaudio.sh # vendor//libwebaudio.a -./scripts/fetch-angle.sh # macOS only: GLES3 via ANGLE +./scripts/fetch-angle.sh # macOS/Windows: GLES3 via ANGLE ./scripts/build.sh examples/dodge # -> build/dodge ``` diff --git a/docs/BUILD-AND-CI.md b/docs/BUILD-AND-CI.md index 5acb578..c1cc206 100644 --- a/docs/BUILD-AND-CI.md +++ b/docs/BUILD-AND-CI.md @@ -26,7 +26,8 @@ Rules (house conventions): ## Per-target archive sets (`vendor//`) -Targets: `linux-x86_64`, `linux-arm64`, `macos-arm64`, `windows-x86_64`. +Targets: `linux-x86_64`, `linux-aarch64`, `macos-aarch64`, +`macos-x86_64`, `windows-x86_64`. | Archive | Source | Notes | | --- | --- | --- | @@ -35,10 +36,11 @@ Targets: `linux-x86_64`, `linux-arm64`, `macos-arm64`, `windows-x86_64`. | `libwebaudio.a` | webaudio-node repo, `scripts/build-webaudio.sh` | clang -O2, plain native, includes dr_libs/stb_vorbis/fdk-aac. SIMD flags per arch (SSE4.2 / NEON). | | `libsgshim.a` | this repo, `scripts/build-shim.sh` | Small; rebuilt constantly during dev. | | `libsggl.a` | this repo, `scripts/build-gl.sh` | The GLES3 tier: generated bindings plus the hand-written shim (out-params, strings, bulk uploads, the EGL pbuffer). Linked only when a game's reachable declaration set uses GL, so a 2D game does not pull in libGLESv2. **Must be scripted, not hand-built**: it being built by hand and never scripted is what broke CI from Phase 8 until it was found. | -| `angle/lib/*.dylib` | `scripts/fetch-angle.sh` (macOS only) | Apple deprecated OpenGL and ships no GLES3, so a 3D game cannot link on macOS at all without ANGLE. Pinned to the same kivy/angle-builder tag native-gles uses. The script rewrites the archive's RELATIVE install names to absolute and verifies with `otool -D`; shipped as-is they link fine and then die at startup with `dyld: Library not loaded: ./libGLESv2.dylib`. A Command-Line-Tools-only `install_name_tool` cannot do that rewrite (the prebuilts have no header padding), so the script falls back to pristine dylibs there and `build.sh` rewrites the load commands in the BINARY after every link instead -- clang linked it locally, so it has room. Both paths end at the same absolute references. | +| `angle/lib/*` | `scripts/fetch-angle.sh` (macOS/Windows) | GLES3 via pinned ANGLE builds, following `native-gles`: kivy/angle-builder dylibs on macOS and mmozeiko/build-angle DLLs plus import libraries on Windows. macOS install names are rewritten after linking; Windows DLLs are staged beside each artifact. Linux uses system EGL/GLES. | +| `skia/icudtl.dat` | build-libcanvas release | Required by Skia text layout on Windows and staged beside the executable. | **Link order is load-bearing**: `libsggl.a` comes BEFORE `libsggfx.a`, with -ANGLE between them on macOS. An archive is scanned once, left to right, so +ANGLE between them on macOS and Windows. An archive is scanned once, left to right, so the GL archive may call into the gfx archive but never the reverse. `scripts/fetch-archives.sh ` populates `vendor//` from @@ -49,24 +51,12 @@ this is called out). ## Build hosts and lanes -scriptc's compiler is an npm package (Node program driving clang); primary -documented host is macOS arm64; static programs cross-compile with -`SCRIPTC_CC=zigcc SCRIPTC_TARGET=`. We never use `--dynamic` -(which is host-native only), so every target is reachable from any host -that runs scriptc itself. - -Two lanes, so no single host type is a dependency: - -1. **Native lane** (preferred when available): build on a runner matching - the target. linux-x86_64 runner builds linux-x86_64, etc. Phase 0.1 - establishes whether scriptc runs on Linux hosts; expectation is yes - (no `os` restriction in the npm package, needs only Node + clang). -2. **Cross lane** (documented-supported): macos-arm64 runner + zig builds - linux-x86_64, linux-arm64, windows-x86_64. FFI archives do not - translate across targets, so the cross lane consumes the SAME - `vendor//` sets the native lane does. This lane is the fallback - if 0.1 says Linux hosting is broken, and the only lane for windows - until someone cares enough to test scriptc-on-Windows-host. +Each target builds on a matching native runner. Linux and macOS use native +clang. Windows runs on `windows-latest` and selects +`SCRIPTC_CC=zigcc SCRIPTC_TARGET=x86_64-windows-msvc`; this uses Zig as the +driver while consuming the runner's MSVC SDK and ABI-compatible native +archives. FFI archives are always target-specific and are never borrowed +from another matrix lane. `scripts/build.sh `: @@ -89,13 +79,11 @@ sites, or the build fails. | Job | Runner | What | | --- | --- | --- | -| `shim-unit` | ubuntu | Shim unit tests native + ASan (no scriptc involved): handle tables, event slot, ring buffer, decode entry points | -| `build-linux-x64` | ubuntu | Native lane full build, all examples | -| `conformance-linux-x64` | ubuntu | Headless canvas goldens + audio hashes + leak counters (SDL dummy video/audio drivers) | -| `build-macos-arm64` | macos-14 | Native macOS build + cross-compile linux-arm64 & windows-x64 artifacts | -| `smoke-linux-arm64` | ubuntu-arm | Run cross-built arm64 artifacts + conformance | -| `smoke-windows` | windows | Run cross-built exe: boots, renders 100 frames headless, exits 0 | -| `report` | ubuntu | Size/startup table per example per target, appended to a tracked CSV; regression thresholds fail the job | +| `linux-x86_64` | ubuntu-24.04 | Build every example, run the full suite, report sizes, upload binaries | +| `linux-aarch64` | ubuntu-24.04-arm | Same | +| `macos-aarch64` | macos-14 | Same; ANGLE translates GLES3 to Metal | +| `macos-x86_64` | macos-15-intel | Same; ANGLE translates GLES3 to Metal | +| `windows-x86_64` | windows-latest | Same; MSVC ABI, SDL2/ANGLE DLLs and `icudtl.dat` staged with artifacts | ### Conformance details @@ -135,10 +123,9 @@ across GPUs without saying so. ## Packaging -Per-game artifact = the binary + `assets/` directory, zipped per target. -No installer, no runtime deps (verified by the clean-machine smoke: -container `FROM scratch`-adjacent image for Linux jobs, `ldd` output -recorded; expected: libc, libm, libpthread, libdl, libstdc++ family only). +Each matrix lane uploads its `build/` directory. Linux and macOS artifacts +contain native executables. Windows additionally carries `SDL2.dll`, +ANGLE's DLLs, and `icudtl.dat`; keep those files beside the executable. The framework itself ships as a template repo (copy, not a package registry dependency) in v1: scriptc resolves plain relative imports, the diff --git a/scripts/build.sh b/scripts/build.sh index f2e1bef..744658b 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -19,11 +19,11 @@ INPUT="${1:?usage: build.sh [target]}" TARGET="${2:-${SG_TARGET:-$(host_target)}}" ROOT="$(cd "$(dirname "$0")/.." && pwd)" -# macOS GL builds need ANGLE (gen-ffi refuses without it). The fetched +# macOS and Windows GL builds need ANGLE (gen-ffi refuses without it). The fetched # location is the only place it ever is locally, so export it rather than # make every shell do so; an explicit ANGLE_LIB still wins. case "$TARGET" in - macos-*) + macos-*|windows-*) if [ -z "${ANGLE_LIB:-}" ] && [ -d "$ROOT/vendor/$TARGET/angle/lib" ]; then export ANGLE_LIB="$ROOT/vendor/$TARGET/angle/lib" fi