Update bundle script to include fat CLI binary

Max Brunsfeld created

Change summary

script/bundle | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)

Detailed changes

script/bundle 🔗

@@ -4,24 +4,33 @@ set -e
 
 export ZED_BUNDLE=true
 
-# Install cargo-bundle 0.5.0 if it's not already installed
+echo "Installing cargo bundle"
 cargo install cargo-bundle --version 0.5.0
 
 # Deal with versions of macOS that don't include libstdc++ headers
 export CXXFLAGS="-stdlib=libc++"
 
-# Build the app bundle for x86_64
-pushd crates/zed > /dev/null
-cargo bundle --release --target x86_64-apple-darwin
-popd > /dev/null
+echo "Compiling binaries"
+cargo build --release --package zed --target aarch64-apple-darwin
+cargo build --release --package zed --target x86_64-apple-darwin
+cargo build --release --package cli --target aarch64-apple-darwin
+cargo build --release --package cli --target x86_64-apple-darwin
 
-# Build the binary for aarch64 (Apple M1)
-cargo build --release --target aarch64-apple-darwin
+echo "Creating application bundle"
+(cd crates/zed && cargo bundle --release --target x86_64-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
+echo "Creating fat binaries"
+lipo \
+    -create \
+    target/{x86_64-apple-darwin,aarch64-apple-darwin}/release/Zed \
+    -output \
+    target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/MacOS/zed
+lipo \
+    -create \
+    target/{x86_64-apple-darwin,aarch64-apple-darwin}/release/cli \
+    -output \
+    target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/MacOS/cli
 
-# Sign the app bundle with an ad-hoc signature so it runs on the M1. We need a real certificate but this works for now.
 if [[ -n $MACOS_CERTIFICATE && -n $MACOS_CERTIFICATE_PASSWORD && -n $APPLE_NOTARIZATION_USERNAME && -n $APPLE_NOTARIZATION_PASSWORD ]]; then
     echo "Signing bundle with Apple-issued certificate"
     security create-keychain -p $MACOS_CERTIFICATE_PASSWORD zed.keychain || echo ""
@@ -39,7 +48,6 @@ else
     codesign --force --deep --sign - target/x86_64-apple-darwin/release/bundle/osx/Zed.app -v
 fi
 
-# Create a DMG
 echo "Creating 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