diff --git a/ios/build-rust-library.sh b/ios/build-rust-library.sh index e5aed2069170..5de58559b07c 100644 --- a/ios/build-rust-library.sh +++ b/ios/build-rust-library.sh @@ -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 " + echo "build-rust-library.sh [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 @@ -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