summaryrefslogtreecommitdiff
path: root/src/macos/build-app.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/macos/build-app.sh')
-rwxr-xr-xsrc/macos/build-app.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/macos/build-app.sh b/src/macos/build-app.sh
new file mode 100755
index 00000000..6734f8d3
--- /dev/null
+++ b/src/macos/build-app.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Assemble pardes.app from libpardes.a and the Swift sources. Run it through
+# `zig build macos-app -Dplatform=macos`, or by hand with the install prefix as
+# $1 once `zig build -Dplatform=macos` has produced the library.
+#
+# There is no Xcode project on purpose. An .app is a directory with a plist and
+# a binary in it, swiftc ships with the Command Line Tools, and a hand-written
+# pbxproj would be a second build system to keep in step for no gain at this
+# stage. What Xcode buys — an xcframework of universal slices, codesigning,
+# notarization, a DMG — is distribution machinery; see docs/macos.md for the
+# upgrade path when that day comes.
+set -eu
+
+root=$(cd "$(dirname "$0")/../.." && pwd)
+out=${1:-"$root/zig-out"}
+app="$out/pardes.app"
+lib="$out/lib/libpardes.a"
+
+[ -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; }
+
+rm -rf "$app"
+mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
+cp "$root/src/macos/Info.plist" "$app/Contents/Info.plist"
+
+# -import-objc-header rather than a module map: the header is consumed straight
+# from the source tree, so there is nothing to stage and nothing to keep in
+# sync. A module map is what an xcframework needs, and there isn't one.
+#
+# -lc++ because ghostty-vt pulls in simdutf and highway, which are C++. The Zig
+# side bundles compiler_rt/ubsan_rt into the archive (see build.zig), so the
+# C++ runtime is the only thing left for this link to supply.
+# -target is not optional. Without it swiftc uses the host triple, so
+# LC_BUILD_VERSION records whatever macOS built the thing and dyld refuses to
+# launch it on anything older — the Info.plist's LSMinimumSystemVersion is a
+# claim, not the enforcement. It is also what turns on the availability
+# diagnostics that catch a post-13 API before a user does.
+swiftc -O -target "$(uname -m)-apple-macos13.0" \
+ -import-objc-header "$root/src/macos/pardes.h" \
+ -o "$app/Contents/MacOS/pardes" \
+ "$root"/src/macos/Sources/*.swift \
+ "$lib" -lc++ \
+ -framework AppKit -framework CoreText -framework CoreGraphics
+
+echo "built $app"