diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-10 09:58:31 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-11 09:58:59 -0300 |
| commit | eb11ab331b4e13e2b9e5a673a4c012d22fdd1d9c (patch) | |
| tree | cc993ad239451adb6f23645ee5ca001802832ed0 /src/macos/build-e2e.sh | |
| parent | 38e9919a9ea9055538409b388d580c4e4c838434 (diff) | |
| download | pardes-eb11ab331b4e13e2b9e5a673a4c012d22fdd1d9c.tar.gz pardes-eb11ab331b4e13e2b9e5a673a4c012d22fdd1d9c.zip | |
macos: the AppKit shell, its icon, and the offscreen e2e harness
Diffstat (limited to 'src/macos/build-e2e.sh')
| -rwxr-xr-x | src/macos/build-e2e.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/macos/build-e2e.sh b/src/macos/build-e2e.sh new file mode 100755 index 00000000..7e0d2233 --- /dev/null +++ b/src/macos/build-e2e.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Link the offscreen end-to-end harness: the app's own Swift shell, plus +# test/macos_e2e.swift as the entry point, against the same libpardes.a. Run it +# through `zig build macos-e2e -Dplatform=macos`, or by hand with the install +# prefix as $1 and the deployment target as $2. +# +# A SECOND BINARY rather than a `--e2e` flag on the app, for two reasons. +# +# Test scaffolding does not ship inside the product. A flag would put the script +# interpreter, the /tmp world-builder and the golden differ into the thing a +# user launches, and would give the app a mode in which it rewrites files under +# /tmp and calls exit() — none of which anyone should be one argv typo away from. +# +# And src/macos/Sources/main.swift holds top-level code, which IS an entry +# point: a module cannot contain both top-level statements and a @main type, so +# the harness could not join that link even if the first reason went away. Every +# other Swift file the app builds from is compiled here, so this link is also +# what proves the shell still compiles as a library rather than as an app. +set -eu + +root=$(cd "$(dirname "$0")/../.." && pwd) +out=${1:-"$root/zig-out"} +# Keep in step with macos_min_version in build.zig, which passes it in. The +# default is only for a by-hand run. Same string as build-app.sh, and for the +# same reason: -target is what decides LC_BUILD_VERSION and turns on the +# availability diagnostics. +minver=${2:-13.0} +lib="$out/lib/libpardes.a" +bin="$out/bin/pardes-macos-e2e" + +[ -f "$lib" ] || { echo "missing $lib — run: zig build -Dplatform=macos" >&2; exit 1; } +command -v swiftc >/dev/null || { echo "swiftc not found (needs macOS + Command Line Tools)" >&2; exit 1; } + +mkdir -p "$out/bin" + +# -import-objc-header and -lc++ are build-app.sh's, unchanged, and have to stay +# that way: this link exists to exercise the app's link, so anything that +# differs here is something the harness cannot vouch for. +# +# -O for the same reason. A debug build of the CoreText pass and the effect +# drain settles on different timings than a user sees, and `stable` waits on +# exactly those timings. +swiftc -O -target "$(uname -m)-apple-macos$minver" \ + -import-objc-header "$root/src/macos/pardes.h" \ + -o "$bin" \ + "$root/src/macos/Sources/PardesView.swift" \ + "$root/src/macos/Sources/AppDelegate.swift" \ + "$root/test/macos_e2e.swift" \ + "$lib" -lc++ \ + -framework AppKit -framework CoreText -framework CoreGraphics + +echo "built $bin" |
