From da66cf61f55d7ccf08d6dbfb6d81fea86f35e8d5 Mon Sep 17 00:00:00 2001 From: jess Date: Mon, 27 Apr 2026 14:05:02 -0700 Subject: [PATCH] Universal macos binary script --- build_universal.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 build_universal.sh diff --git a/build_universal.sh b/build_universal.sh new file mode 100755 index 0000000..3180b38 --- /dev/null +++ b/build_universal.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")" && pwd)" +BUILD="$ROOT/build" +APP="$BUILD/bin/Acord.app" +CONTENTS="$APP/Contents" +MACOS="$CONTENTS/MacOS" +RESOURCES="$CONTENTS/Resources" +SDK=$(xcrun --show-sdk-path) +export MACOSX_DEPLOYMENT_TARGET=14.0 + +# 1. Build Rust for both architectures +echo "Building Rust workspace (Universal)..." +rustup target add aarch64-apple-darwin x86_64-apple-darwin + +cargo build --release -p acord-viewport --target aarch64-apple-darwin +cargo build --release -p acord-viewport --target x86_64-apple-darwin + +# 2. Create Universal Rust Static Lib +mkdir -p "$ROOT/target/universal" +lipo -create \ + "$ROOT/target/aarch64-apple-darwin/release/libacord_viewport.a" \ + "$ROOT/target/x86_64-apple-darwin/release/libacord_viewport.a" \ + -output "$ROOT/target/universal/libacord_viewport.a" + +# --- Icon Generation (Remains the same) --- +# [Your existing rsvg-convert and iconutil code here] + +# --- Bundle structure --- +mkdir -p "$MACOS" "$RESOURCES" +cp "$ROOT/Info.plist" "$CONTENTS/Info.plist" +[ -f "$BUILD/AppIcon.icns" ] && cp "$BUILD/AppIcon.icns" "$RESOURCES/AppIcon.icns" + +# 3. Compile Swift for both architectures +echo "Compiling Swift (Universal)..." +SWIFT_FILES=("$ROOT"/src/*.swift) +RUST_INCLUDES=(-import-objc-header "$ROOT/viewport/include/acord.h" -L "$ROOT/target/universal" -lacord_viewport) + +# Compile arm64 slice +swiftc -target arm64-apple-macosx14.0 -sdk "$SDK" "${RUST_INCLUDES[@]}" \ + -framework Cocoa -framework SwiftUI -framework Metal -framework MetalKit -O \ + -o "$MACOS/Acord_arm64" "${SWIFT_FILES[@]}" + +# Compile x86_64 slice +swiftc -target x86_64-apple-macosx14.0 -sdk "$SDK" "${RUST_INCLUDES[@]}" \ + -framework Cocoa -framework SwiftUI -framework Metal -framework MetalKit -O \ + -o "$MACOS/Acord_x86" "${SWIFT_FILES[@]}" + +# 4. Merge Swift binaries into one Universal binary +lipo -create "$MACOS/Acord_arm64" "$MACOS/Acord_x86" -output "$MACOS/Acord" +rm "$MACOS/Acord_arm64" "$MACOS/Acord_x86" + +# 5. Code sign the universal bundle +codesign --force --sign - --deep "$APP" + +echo "Successfully built Universal App: $APP" +