Skip to content

Commit

Permalink
add script for xcode to build PlayerCore as a static lib
Browse files Browse the repository at this point in the history
  • 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.
40 changes: 40 additions & 0 deletions Scripts/build_player_core.sh
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"

0 comments on commit c228c2a

Please sign in to comment.