Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release two architectures for macOS #18

Merged
merged 5 commits into from
Apr 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,34 @@ else
echo
fi

# Build a macOS AMD64 binary
rustup target add x86_64-apple-darwin
cargo build --release --target=x86_64-apple-darwin

# On $LIVE builds this will be the same as $NEW_VERSION_NUMBER since we just
# made a tag with $NEW_VERSION_NUMBER.
EXPECTED_VERSION_NUMBER=$(git describe --dirty=-modified)
if ! ./target/x86_64-apple-darwin/release/riff --version | grep -E " $EXPECTED_VERSION_NUMBER\$" >/dev/null; then

# Build macOS binaries
targets="aarch64-apple-darwin x86_64-apple-darwin"
for target in $targets; do
rustup target add $target

# From: https://stackoverflow.com/a/66875783/473672
SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path) \
MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version) \
cargo build --release "--target=$target"
done

# From: https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary#Update-the-Architecture-List-of-Custom-Makefiles
lipo -create \
-output target/riff-universal-apple-darwin-release \
target/aarch64-apple-darwin/release/riff \
target/x86_64-apple-darwin/release/riff

if ! target/riff-universal-apple-darwin-release --version | grep -E " $EXPECTED_VERSION_NUMBER\$" >/dev/null; then
echo >&2 ""
echo >&2 "ERROR: Version number <$EXPECTED_VERSION_NUMBER> not found in --version output:"
./target/x86_64-apple-darwin/release/riff --version
target/riff-universal-apple-darwin-release --version
exit 1
fi
$LIVE && cp "target/x86_64-apple-darwin/release/riff" "riff-$NEW_VERSION_NUMBER-x86_64-macos"
$LIVE && cp "target/riff-universal-apple-darwin-release" "riff-$EXPECTED_VERSION_NUMBER-universal-macos"

# Build a Linux-x64 binary on macOS
#
Expand Down