From 52a5777fbdf121c8ae6c927a46e65b2a6f61821d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 4 May 2021 17:18:14 -0600 Subject: [PATCH] Create the bundle as a "fat binary" supporting the M1 --- .github/workflows/ci.yml | 2 +- script/bundle | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcb244a81b..7a3a551ef3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,4 +50,4 @@ jobs: - uses: actions/upload-artifact@v2 with: name: Zed.dmg - path: target/release/bundle/Zed.dmg + path: target/release/Zed.dmg diff --git a/script/bundle b/script/bundle index 6732d24743..ac13d903ff 100755 --- a/script/bundle +++ b/script/bundle @@ -2,14 +2,25 @@ set -e +# Build the app bundle for x86_64 pushd zed > /dev/null -cargo bundle --release +cargo bundle --release --target x86_64-apple-darwin popd > /dev/null -hdiutil create -volname Zed -srcfolder target/release/bundle/osx -ov -format UDZO target/release/bundle/Zed.dmg +# Build the binary for aarch64 (Apple M1) +cargo build --release --target aarch64-apple-darwin + +# Replace the bundle's binary with a "fat binary" that combines the two architecture-specific binaries +lipo -create target/x86_64-apple-darwin/release/Zed target/aarch64-apple-darwin/release/Zed -output target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/MacOS/zed + +# Create a DMG +mkdir -p target/release +hdiutil create -volname Zed -srcfolder target/x86_64-apple-darwin/release/bundle/osx -ov -format UDZO target/release/Zed.dmg + +# If -o option is specified, open the target/release directory in Finder to reveal the DMG while getopts o flag do case "${flag}" in - o) open target/release/bundle;; + o) open target/release;; esac done