58 lines
2.0 KiB
Bash
Executable File
58 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
export CARGO_TARGET_DIR="$DERIVED_FILE_DIR/cargo"
|
|
if [[ "$CONFIGURATION" == "Debug" ]]; then
|
|
profile=debug
|
|
else
|
|
profile=release
|
|
fi
|
|
|
|
if [[ "${PLATFORM_NAME:-}" == watch* ]]; then
|
|
package=ironstorage-watch-apple
|
|
library=ironstorage_watch
|
|
else
|
|
package=ironstorage-apple
|
|
library=ironstorage_apple
|
|
fi
|
|
|
|
libraries=()
|
|
for arch in $ARCHS; do
|
|
toolchain=stable
|
|
cargo_args=(--locked)
|
|
if [[ "$package" == "ironstorage-watch-apple" && "$arch" == "arm64" && "${LLVM_TARGET_TRIPLE_SUFFIX:-}" == "-simulator" ]]; then
|
|
target=aarch64-apple-watchos-sim
|
|
elif [[ "$package" == "ironstorage-watch-apple" && "$arch" == "arm64" ]]; then
|
|
target=aarch64-apple-watchos
|
|
elif [[ "$package" == "ironstorage-watch-apple" && "$arch" == "arm64_32" ]]; then
|
|
target=arm64_32-apple-watchos
|
|
toolchain=nightly
|
|
cargo_args=(-Z build-std=std,panic_abort --locked)
|
|
elif [[ "$package" == "ironstorage-watch-apple" && "$arch" == "x86_64" ]]; then
|
|
target=x86_64-apple-watchos-sim
|
|
elif [[ "$arch" == "arm64" && "${LLVM_TARGET_TRIPLE_SUFFIX:-}" == "-simulator" ]]; then
|
|
target=aarch64-apple-ios-sim
|
|
elif [[ "$arch" == "arm64" ]]; then
|
|
target=aarch64-apple-ios
|
|
elif [[ "$arch" == "x86_64" ]]; then
|
|
target=x86_64-apple-ios
|
|
else
|
|
echo "Unsupported ${PLATFORM_NAME:-Apple} architecture: $arch" >&2
|
|
exit 1
|
|
fi
|
|
|
|
export RUSTC="$(rustup which --toolchain "$toolchain" rustc)"
|
|
export RUSTDOC="$(rustup which --toolchain "$toolchain" rustdoc)"
|
|
if [[ "$profile" == "debug" ]]; then
|
|
rustup run "$toolchain" cargo build "${cargo_args[@]}" \
|
|
--target "$target" --package "$package" --lib
|
|
else
|
|
rustup run "$toolchain" cargo build "${cargo_args[@]}" --release \
|
|
--target "$target" --package "$package" --lib
|
|
fi
|
|
libraries+=("$CARGO_TARGET_DIR/$target/$profile/lib$library.a")
|
|
done
|
|
|
|
mkdir -p "$DERIVED_FILE_DIR/rust"
|
|
lipo -create -output "$DERIVED_FILE_DIR/rust/lib$library.a" "${libraries[@]}"
|