Files
IronStorage/apple/build_rust_core.bash

53 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
export CARGO_TARGET_DIR="$DERIVED_FILE_DIR/cargo"
export RUSTC="$(rustup which --toolchain stable rustc)"
export RUSTDOC="$(rustup which --toolchain stable rustdoc)"
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
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" == "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
if [[ "$profile" == "debug" ]]; then
rustup run stable cargo build --locked \
--target "$target" --package "$package" --lib
else
rustup run stable cargo build --locked --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[@]}"