Skip to content

Commit

Permalink
Merge branch 'improve-the-rust-library-build-script-to-pass-feature-f…
Browse files Browse the repository at this point in the history
…lags-ios-551'
  • Loading branch information
buggmagnet committed Mar 14, 2024
2 parents 187f52f + 4d7e5ef commit 5208401
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions ios/build-rust-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@

set -euvx

if [ "$#" -ne 1 ]
if [ "$#" -gt 2 ] || [ "$#" -eq 0 ]
then
echo "Usage (note: only call inside xcode!):"
echo "build-rust-library.sh <FFI_TARGET>"
echo "build-rust-library.sh <FFI_TARGET> [FFI_FEATURES]"
exit 1
fi

# what to pass to cargo build -p, e.g. your_lib_ffi
FFI_TARGET=$1

# Enable cargo features by passing feature names to this script, i.e. build-rust-library.sh mullvad-api api-override
# If more than one feature flag needs to be enabled, pass in a single argument all the features flags separated by spaces
# build-rust-library.sh mullvad-api "featureA featureB featureC"
FEATURE_FLAGS=
if [[ "$#" -eq 2 ]] ; then
FEATURE_FLAGS=$2
echo ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
fi


RELFLAG=
if [[ "$CONFIGURATION" == "Release" ]]; then
RELFLAG=--release
Expand Down Expand Up @@ -43,18 +53,18 @@ for arch in $ARCHS; do

# Intel iOS simulator
export CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios"
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target x86_64-apple-ios
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target x86_64-apple-ios
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target x86_64-apple-ios ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target x86_64-apple-ios ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
;;

arm64)
if [ $IS_SIMULATOR -eq 0 ]; then
# Hardware iOS targets
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target aarch64-apple-ios
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target aarch64-apple-ios
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target aarch64-apple-ios ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target aarch64-apple-ios ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
else
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target aarch64-apple-ios-sim
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target aarch64-apple-ios-sim
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target aarch64-apple-ios-sim ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target aarch64-apple-ios-sim ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
fi
esac
done

0 comments on commit 5208401

Please sign in to comment.