zed/script/bundle
Nathan Sobo 5cf65ed6b7 Ad hoc code-sign the app bundle
Apparently this is necessary to run on the M1 macs
2021-05-04 17:29:39 -06:00

30 lines
1 KiB
Bash
Executable file

#!/bin/bash
set -e
# Build the app bundle for x86_64
pushd zed > /dev/null
cargo bundle --release --target x86_64-apple-darwin
popd > /dev/null
# 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
# 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.
codesign --force --deep -s - target/x86_64-apple-darwin/release/bundle/osx/Zed.app
# 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;;
esac
done