@@ -9,7 +9,6 @@ open_result=false
99local_arch=false
1010local_only=false
1111local_install=false
12- bundle_name=" "
1312can_code_sign=false
1413
1514# This must match the team in the provisioning profile.
@@ -19,12 +18,11 @@ APPLE_NOTARIZATION_TEAM="MQ55VZLNZQ"
1918# Function for displaying help info
2019help_info () {
2120 echo "
22- Usage: ${0##*/ } [options] [bundle_name ]
21+ Usage: ${0##*/ } [options] [architecture=host ]
2322Build the application bundle for macOS.
2423
2524Options:
2625 -d Compile in debug mode
27- -l Compile for local architecture only.
2826 -o Open dir with the resulting DMG or launch the app itself in local mode.
2927 -i Install the resulting DMG into /Applications in local mode. Noop without -l.
3028 -h Display this help and exit.
4139 build_flag=" " ;
4240 target_dir=" debug"
4341 ;;
44- l)
45- export CARGO_INCREMENTAL=true
46- export CARGO_BUNDLE_SKIP_BUILD=true
47- local_arch=true
48- local_only=true
49- ;;
5042 i) local_install=true;;
5143 h)
5244 help_info
5749
5850shift $(( OPTIND- 1 ))
5951
60- if [[ $# -gt 0 ]]; then
61- if [ " $1 " ]; then
62- bundle_name=$1
63- fi
64- fi
6552
6653# Get release channel
6754pushd crates/zed
@@ -81,24 +68,31 @@ export CXXFLAGS="-stdlib=libc++"
8168
8269version_info=$( rustc --version --verbose)
8370host_line=$( echo " $version_info " | grep host)
84- local_target_triple=${host_line#*: }
71+ target_triple=${host_line#*: }
72+ if [[ $# -gt 0 && -n " $1 " ]]; then
73+ target_triple=" $1 "
74+ fi
75+ remote_server_arch=" "
76+
77+ if [[ " $target_triple " = " x86_64-apple-darwin" ]]; then
78+ remote_server_arch=" x86_64"
79+ elif [[ " $target_triple " = " aarch64-apple-darwin" ]]; then
80+ remote_server_arch=" aarch64"
81+ else
82+ echo " Unsupported architecture $target_triple "
83+ exit 1
84+ fi
8585
8686# Generate the licenses first, so they can be baked into the binaries
8787script/generate-licenses
8888
89- if [ " $local_arch " = true ]; then
90- echo " Building for local target only."
91- cargo build ${build_flag} --package zed --package cli --package remote_server
92- else
93- rustup target add aarch64-apple-darwin
94- rustup target add x86_64-apple-darwin
95-
96- echo " Compiling zed binaries"
97- cargo build ${build_flag} --package zed --package cli --target aarch64-apple-darwin --target x86_64-apple-darwin
98- # Build remote_server in separate invocation to prevent feature unification from other crates
99- # from influencing dynamic libraries required by it.
100- cargo build ${build_flag} --package remote_server --target aarch64-apple-darwin --target x86_64-apple-darwin
101- fi
89+ rustup target add $target_triple
90+
91+ echo " Compiling zed binaries"
92+ cargo build ${build_flag} --package zed --package cli --target $target_triple
93+ # Build remote_server in separate invocation to prevent feature unification from other crates
94+ # from influencing dynamic libraries required by it.
95+ cargo build ${build_flag} --package remote_server --target $target_triple
10296
10397echo " Creating application bundle"
10498pushd crates/zed
@@ -108,13 +102,7 @@ sed \
108102 " s/package.metadata.bundle-${channel} /package.metadata.bundle/" \
109103 Cargo.toml
110104
111- if [ " $local_arch " = true ]; then
112- app_path=$( cargo bundle ${build_flag} --select-workspace-root | xargs)
113- else
114- app_path_x64=$( cargo bundle ${build_flag} --target x86_64-apple-darwin --select-workspace-root | xargs)
115- app_path_aarch64=$( cargo bundle ${build_flag} --target aarch64-apple-darwin --select-workspace-root | xargs)
116- app_path=$app_path_x64
117- fi
105+ app_path=$( cargo bundle ${build_flag} --target $target_triple --select-workspace-root | xargs)
118106
119107mv Cargo.toml.backup Cargo.toml
120108popd
@@ -189,26 +177,12 @@ function download_git() {
189177 rm -rf " $tmp_dir "
190178}
191179
192- function prepare_binaries() {
193- local architecture=$1
194- local app_path=$2
195-
196- cp target/${architecture} /${target_dir} /zed " ${app_path} /Contents/MacOS/zed"
197- cp target/${architecture} /${target_dir} /cli " ${app_path} /Contents/MacOS/cli"
198- }
199-
200180function sign_app_binaries() {
201- local app_path=$1
202- local architecture=$2
203- local architecture_dir=$3
204181 rm -rf " ${app_path} /Contents/Frameworks"
205182 mkdir -p " ${app_path} /Contents/Frameworks"
206- if [ " $local_arch " = true ]; then
207- cp -R target/${target_dir} /cli " ${app_path} /Contents/MacOS/"
208- fi
209183
210184 echo " Downloading git binary"
211- download_git " ${architecture } " " ${app_path} /Contents/MacOS/git"
185+ download_git " ${target_triple } " " ${app_path} /Contents/MacOS/git"
212186
213187 # Note: The app identifier for our development builds is the same as the app identifier for nightly.
214188 cp crates/zed/contents/$channel /embedded.provisionprofile " ${app_path} /Contents/"
@@ -251,15 +225,7 @@ function sign_app_binaries() {
251225 exit 0
252226 fi
253227
254- # If bundle_name is not set or empty, use the basename of $app_path
255- if [ -z " $bundle_name " ]; then
256- bundle_name=$( basename " $app_path " )
257- else
258- # If bundle_name doesn't end in .app, append it
259- if [[ " $bundle_name " != * .app ]]; then
260- bundle_name=" $bundle_name .app"
261- fi
262- fi
228+ bundle_name=$( basename " $app_path " )
263229
264230 if [ " $local_only " = true ]; then
265231 if [ " $local_install " = true ]; then
@@ -277,7 +243,7 @@ function sign_app_binaries() {
277243 fi
278244 fi
279245 else
280- dmg_target_directory=" target/${architecture_dir } /${target_dir} "
246+ dmg_target_directory=" target/${target_triple } /${target_dir} "
281247 dmg_source_directory=" ${dmg_target_directory} /dmg"
282248 dmg_file_path=" ${dmg_target_directory} /Zed.dmg"
283249 xcode_bin_dir_path=" $( xcode-select -p) /usr/bin"
@@ -325,44 +291,29 @@ function sign_binary() {
325291 /usr/bin/codesign --deep --force --timestamp --options runtime --entitlements crates/zed/resources/zed.entitlements --sign " $IDENTITY " " ${binary_path} " -v
326292 fi
327293}
294+ cp target/${target_triple} /${target_dir} /zed " ${app_path} /Contents/MacOS/zed"
295+ cp target/${target_triple} /${target_dir} /cli " ${app_path} /Contents/MacOS/cli"
296+ sign_app_binaries
328297
329- if [ " $local_arch " = true ]; then
330- sign_app_binaries " $app_path " " $local_target_triple " " $local_target_triple "
331-
332- sign_binary " target/release/remote_server"
333- else
334- # Create universal binary
335- prepare_binaries " aarch64-apple-darwin" " $app_path_aarch64 "
336- prepare_binaries " x86_64-apple-darwin" " $app_path_x64 "
337-
338-
339- sign_app_binaries " $app_path_x64 " " x86_64-apple-darwin" " x86_64-apple-darwin"
340- sign_app_binaries " $app_path_aarch64 " " aarch64-apple-darwin" " aarch64-apple-darwin"
341-
342- sign_binary " target/x86_64-apple-darwin/release/remote_server"
343- sign_binary " target/aarch64-apple-darwin/release/remote_server"
344- gzip -f --stdout --best target/x86_64-apple-darwin/release/remote_server > target/zed-remote-server-macos-x86_64.gz
345- gzip -f --stdout --best target/aarch64-apple-darwin/release/remote_server > target/zed-remote-server-macos-aarch64.gz
346- fi
298+ sign_binary " target/$target_triple /release/remote_server"
299+ gzip -f --stdout --best target/$target_triple /release/remote_server > target/zed-remote-server-macos-$remote_server_arch .gz
347300
348301function upload_debug_info() {
349- architecture=$1
350302 if [[ -n " ${SENTRY_AUTH_TOKEN:- } " ]]; then
351303 echo " Uploading zed debug symbols to sentry..."
352304 # note: this uploads the unstripped binary which is needed because it contains
353305 # .eh_frame data for stack unwinding. see https://github.com/getsentry/symbolic/issues/783
354306 sentry-cli debug-files upload --include-sources --wait -p zed -o zed-dev \
355- " target/${architecture } /${target_dir} /zed" \
356- " target/${architecture } /${target_dir} /remote_server" \
357- " target/${architecture } /${target_dir} /zed.dwarf"
307+ " target/${target_triple } /${target_dir} /zed" \
308+ " target/${target_triple } /${target_dir} /remote_server" \
309+ " target/${target_triple } /${target_dir} /zed.dwarf"
358310 else
359311 echo " missing SENTRY_AUTH_TOKEN. skipping sentry upload."
360312 fi
361313}
362314
363315if command -v sentry-cli > /dev/null 2>&1 ; then
364- upload_debug_info " aarch64-apple-darwin"
365- upload_debug_info " x86_64-apple-darwin"
316+ upload_debug_info
366317else
367318 echo " sentry-cli not found. skipping sentry upload."
368319 echo " install with: 'curl -sL https://sentry.io/get-cli | bash'"
0 commit comments