BlueGit

timfa posprint

Files

posprint / scripts / ci / build-macos.sh

build-macos.sh

build-macos.sh 1.6 KiB Download Raw
1#!/usr/bin/env bash
2# Cross-build Posprint.app (universal: arm64 + x86_64) on Linux with
3# cargo-zigbuild and the macOS SDK from the cargo-zigbuild image ($SDKROOT).
4# Output: dist/macos-universal.zip (Posprint.app). Not notarized; the
5# binaries carry the linker's ad-hoc signature only.
6set -euo pipefail
7cd "$(dirname "$0")/../.."
8v="$(cat artifacts/version.txt)"
9: "${SDKROOT:?SDKROOT (macOS SDK) is not set in this image}"
10apt-get update -qq
11apt-get install -y -qq zip llvm >/dev/null
12lipo="$(command -v llvm-lipo || ls /usr/bin/llvm-lipo-* | head -n1)"
13rustup target add aarch64-apple-darwin x86_64-apple-darwin
14cargo zigbuild --release --locked --target universal2-apple-darwin
15bin=target/universal2-apple-darwin/release/posprint
16test -f "$bin"
17app=target/macos/Posprint.app
18rm -rf "$app"; mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
19for a in aarch64 x86_64; do
20 zig cc -target "$a-macos.11.0" -O2 -isysroot "$SDKROOT" \
21 -F"$SDKROOT/System/Library/Frameworks" -L"$SDKROOT/usr/lib" -I"$SDKROOT/usr/include" \
22 -framework Cocoa -o "target/macos/launcher-$a" packaging/macos/launcher.m
23done
24"$lipo" -create -output "$app/Contents/MacOS/posprint-launcher" target/macos/launcher-aarch64 target/macos/launcher-x86_64
25cp "$bin" "$app/Contents/MacOS/posprint-bin"
26chmod 755 "$app/Contents/MacOS/"*
27sed "s/@VERSION@/${v}/g" packaging/macos/Info.plist > "$app/Contents/Info.plist"
28"$lipo" -info "$app/Contents/MacOS/posprint-bin" "$app/Contents/MacOS/posprint-launcher"
29mkdir -p dist
30(cd target/macos && rm -f ../../dist/macos-universal.zip && zip -qry ../../dist/macos-universal.zip Posprint.app)
31ls -l dist/macos-universal.zip