Create the bundle as a "fat binary" supporting the M1

Nathan Sobo created

Change summary

.github/workflows/ci.yml |  2 +-
script/bundle            | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 4 deletions(-)

Detailed changes

.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

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