-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script for xcode to build PlayerCore as a static lib
- Loading branch information
Lee Jun Kit
committed
Oct 8, 2021
1 parent
7b14ada
commit c228c2a
Showing
1 changed file
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Location of rust project | ||
RUST_PROJ="$PROJECT_DIR/PlayerCore" | ||
# Location of the "Anvil" folder in the iOS project | ||
IOS_ANVIL="$PROJECT_DIR" | ||
# Provide access to Rust utilities | ||
PATH="$PATH:/Users/kit/.cargo/bin" | ||
|
||
cd "$RUST_PROJ" | ||
|
||
# Generate C bindings | ||
cbindgen -l C -o target/libspottie_player_core.h | ||
|
||
configLowercase=$(echo "$CONFIGURATION" | tr '[:upper:]' '[:lower:]') | ||
|
||
echo "Building $configLowercase configuration for target(s) $ARCHS" | ||
|
||
targets=() | ||
for arch in $ARCHS; do | ||
if [ $arch == "arm64" ]; then | ||
arch="aarch64" | ||
fi | ||
targets+=($arch-apple-darwin) | ||
done | ||
|
||
libPaths=() | ||
for target in "${targets[@]}"; do | ||
cargo build $(if [ $CONFIGURATION == "Release" ]; then echo "--release"; fi) --target $target | ||
|
||
libPaths+=("target/$target/$configLowercase/libspottie_player_core.a") | ||
done | ||
|
||
# Create universal library | ||
lipo -create ${libPaths[@]} -output target/libspottie_player_core.a | ||
|
||
# Copy resources to the iOS folder, overwriting old ones | ||
cp target/libspottie_player_core.h target/libspottie_player_core.a "$IOS_ANVIL/Spottie/PlayerCore" |