diff --git a/qt/launcher/mac/build.sh b/qt/launcher/mac/build.sh index 4f50f6c69..260af5c6d 100755 --- a/qt/launcher/mac/build.sh +++ b/qt/launcher/mac/build.sh @@ -5,9 +5,11 @@ set -e # Define output path OUTPUT_DIR="../../../out/launcher" APP_LAUNCHER="$OUTPUT_DIR/Anki.app" +rm -rf "$APP_LAUNCHER" -# Build rust binary in debug mode -cargo build -p launcher +# Build binaries for both architectures +cargo build -p launcher --release --target aarch64-apple-darwin +cargo build -p launcher --release --target x86_64-apple-darwin (cd ../../.. && ./ninja launcher:uv_universal) # Ensure output directory exists @@ -19,9 +21,12 @@ rm -rf "$APP_LAUNCHER" # Create app launcher structure mkdir -p "$APP_LAUNCHER/Contents/MacOS" "$APP_LAUNCHER/Contents/Resources" -# Copy binaries +# Copy binaries in TARGET_DIR=${CARGO_TARGET_DIR:-target} -cp $TARGET_DIR/debug/launcher "$APP_LAUNCHER/Contents/MacOS/" +lipo -create \ + "$TARGET_DIR/aarch64-apple-darwin/release/launcher" \ + "$TARGET_DIR/x86_64-apple-darwin/release/launcher" \ + -output "$APP_LAUNCHER/Contents/MacOS/launcher" cp "$OUTPUT_DIR/uv" "$APP_LAUNCHER/Contents/MacOS/" # Copy support files @@ -39,3 +44,9 @@ done # Check codesign -vvv "$APP_LAUNCHER" spctl -a "$APP_LAUNCHER" + +# Notarize +./notarize.sh "$OUTPUT_DIR" + +# Bundle +./dmg/build.sh "$OUTPUT_DIR" \ No newline at end of file diff --git a/qt/launcher/mac/dmg/build.sh b/qt/launcher/mac/dmg/build.sh index 6efb510a7..16b48c06a 100755 --- a/qt/launcher/mac/dmg/build.sh +++ b/qt/launcher/mac/dmg/build.sh @@ -4,9 +4,9 @@ set -e # base folder with Anki.app in it -dist=$1 -dmg_path=$2 -script_folder=$(dirname $0) +output="$1" +dist="$1/tmp" +dmg_path="$output/Anki.dmg" if [ -d "/Volumes/Anki" ] then @@ -14,9 +14,14 @@ then exit 1 fi +rm -rf $dist $dmg_path +mkdir -p $dist +rsync -av $output/Anki.app $dist/ +script_folder=$(dirname $0) + echo "bundling..." ln -s /Applications $dist/Applications -mkdir $dist/.background +mkdir -p $dist/.background cp ${script_folder}/anki-logo-bg.png $dist/.background cp ${script_folder}/dmg_ds_store $dist/.DS_Store diff --git a/qt/launcher/mac/notarize.sh b/qt/launcher/mac/notarize.sh new file mode 100755 index 000000000..d906bd7f8 --- /dev/null +++ b/qt/launcher/mac/notarize.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Define output path +OUTPUT_DIR="$1" +APP_LAUNCHER="$OUTPUT_DIR/Anki.app" +ZIP_FILE="$OUTPUT_DIR/Anki.zip" + +# Create zip for notarization +(cd "$OUTPUT_DIR" && rm -rf Anki.zip && zip -r Anki.zip Anki.app) + +# Upload for notarization +xcrun notarytool submit "$ZIP_FILE" -p default --wait + +# Staple the app +xcrun stapler staple "$APP_LAUNCHER" \ No newline at end of file