Skip to content

Commit 5208401

Browse files
committed
Merge branch 'improve-the-rust-library-build-script-to-pass-feature-flags-ios-551'
2 parents 187f52f + 4d7e5ef commit 5208401

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

ios/build-rust-library.sh

+18-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22

33
set -euvx
44

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

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

15+
# Enable cargo features by passing feature names to this script, i.e. build-rust-library.sh mullvad-api api-override
16+
# If more than one feature flag needs to be enabled, pass in a single argument all the features flags separated by spaces
17+
# build-rust-library.sh mullvad-api "featureA featureB featureC"
18+
FEATURE_FLAGS=
19+
if [[ "$#" -eq 2 ]] ; then
20+
FEATURE_FLAGS=$2
21+
echo ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
22+
fi
23+
24+
1525
RELFLAG=
1626
if [[ "$CONFIGURATION" == "Release" ]]; then
1727
RELFLAG=--release
@@ -43,18 +53,18 @@ for arch in $ARCHS; do
4353

4454
# Intel iOS simulator
4555
export CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios"
46-
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target x86_64-apple-ios
47-
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target x86_64-apple-ios
56+
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target x86_64-apple-ios ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
57+
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target x86_64-apple-ios ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
4858
;;
4959

5060
arm64)
5161
if [ $IS_SIMULATOR -eq 0 ]; then
5262
# Hardware iOS targets
53-
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target aarch64-apple-ios
54-
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target aarch64-apple-ios
63+
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target aarch64-apple-ios ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
64+
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target aarch64-apple-ios ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
5565
else
56-
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target aarch64-apple-ios-sim
57-
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target aarch64-apple-ios-sim
66+
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib $RELFLAG --target aarch64-apple-ios-sim ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
67+
"$HOME"/.cargo/bin/cargo build -p "$FFI_TARGET" --lib --target aarch64-apple-ios-sim ${FEATURE_FLAGS:+--features "$FEATURE_FLAGS"}
5868
fi
5969
esac
6070
done

0 commit comments

Comments
 (0)