Skip to content

Commit 3a9b0a6

Browse files
committed
1 parent c582da0 commit 3a9b0a6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
1010

1111
## [Unreleased]
1212

13+
- Use [multi-target builds](https://blog.rust-lang.org/2022/09/22/Rust-1.64.0.html#cargo-improvements-workspace-inheritance-and-multi-target-builds) for `universal-apple-darwin` (universal macOS binary) on Rust 1.64+. This makes `universal-apple-darwin` builds up to about 2x faster.
14+
1315
## [1.14.0] - 2023-05-13
1416

1517
- Add `profile` input option to allow specifying custom profiles. ([#44](https://github.com/taiki-e/upload-rust-binary-action/pull/44), thanks @afnanenayet)

main.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ if [[ -n "${checksum}" ]]; then
119119
fi
120120

121121
host=$(rustc -Vv | grep 'host: ' | cut -c 7-)
122+
rustc_version=$(rustc -Vv | grep 'release: ' | cut -c 10-)
123+
rustc_minor_version="${rustc_version#*.}"
124+
rustc_minor_version="${rustc_minor_version%%.*}"
122125
target="${INPUT_TARGET:-"${host}"}"
123126
target_lower="${target//-/_}"
124127
target_lower="${target_lower//./_}"
@@ -256,8 +259,13 @@ case "${INPUT_TARGET:-}" in
256259
;;
257260
universal-apple-darwin)
258261
# Refs: https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary
259-
build --target aarch64-apple-darwin
260-
build --target x86_64-apple-darwin
262+
# multi-target builds requires 1.64
263+
if [[ "${rustc_minor_version}" -ge 64 ]]; then
264+
build --target aarch64-apple-darwin --target x86_64-apple-darwin
265+
else
266+
build --target aarch64-apple-darwin
267+
build --target x86_64-apple-darwin
268+
fi
261269
aarch64_target_dir="${target_dir}/aarch64-apple-darwin/${profile_directory}"
262270
x86_64_target_dir="${target_dir}/x86_64-apple-darwin/${profile_directory}"
263271
target_dir="${target_dir}/${target}/${profile_directory}"

0 commit comments

Comments
 (0)