-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS: replace cargo-lipo, and update for new macOS (#3109)
# Objective - Remove `cargo-lipo` as [it's deprecated](https://github.com/TimNN/cargo-lipo#maintenance-status) and doesn't work on new Apple processors - Fix CI that will fail as soon as GitHub update the worker used by Bevy to macOS 11 ## Solution - Replace `cargo-lipo` with building with the correct target - Setup the correct path to libraries by using `xcrun --show-sdk-path` - Also try and fix path to cmake in case it's not found but available through homebrew
- Loading branch information
Showing
6 changed files
with
146 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,54 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
# based on https://github.com/mozilla/glean/blob/main/build-scripts/xc-universal-binary.sh | ||
|
||
set -eux | ||
|
||
PATH=$PATH:$HOME/.cargo/bin | ||
|
||
# If you want your build to run faster, add a "--targets x86_64-apple-ios" for just using the ios simulator. | ||
if [ -n ${IOS_TARGETS} ]; then | ||
cargo lipo --targets ${IOS_TARGETS} | ||
RELFLAG= | ||
if [[ "$CONFIGURATION" != "Debug" ]]; then | ||
RELFLAG=--release | ||
fi | ||
|
||
set -euvx | ||
|
||
# add path to the system SDK, needed since macOS 11 | ||
if [ -z ${LIBRARY_PATH+x} ]; then | ||
export LIBRARY_PATH="$(xcrun --show-sdk-path)/usr/lib" | ||
else | ||
cargo lipo | ||
export LIBRARY_PATH="$LIBRARY_PATH:$(xcrun --show-sdk-path)/usr/lib" | ||
fi | ||
|
||
# add homebrew bin path, as it's the most commonly used package manager on macOS | ||
# this is needed for cmake on apple arm processors as it's not available by default | ||
export PATH="$PATH:/opt/homebrew/bin" | ||
|
||
IS_SIMULATOR=0 | ||
if [ "${LLVM_TARGET_TRIPLE_SUFFIX-}" = "-simulator" ]; then | ||
IS_SIMULATOR=1 | ||
fi | ||
|
||
for arch in $ARCHS; do | ||
case "$arch" in | ||
x86_64) | ||
if [ $IS_SIMULATOR -eq 0 ]; then | ||
echo "Building for x86_64, but not a simulator build. What's going on?" >&2 | ||
exit 2 | ||
fi | ||
|
||
# Intel iOS simulator | ||
export CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios" | ||
cargo build --lib $RELFLAG --target x86_64-apple-ios | ||
;; | ||
|
||
arm64) | ||
if [ $IS_SIMULATOR -eq 0 ]; then | ||
# Hardware iOS targets | ||
cargo build --lib $RELFLAG --target aarch64-apple-ios | ||
else | ||
# M1 iOS simulator -- currently in Nightly only and requires to build `libstd` | ||
cargo build --lib $RELFLAG --target aarch64-apple-ios-sim | ||
fi | ||
esac | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters