Skip to content

Commit b6d82c3

Browse files
committed
review nits and fixes
1 parent fa58ec2 commit b6d82c3

File tree

5 files changed

+52
-17
lines changed

5 files changed

+52
-17
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ logins.jwk
1010
*~
1111
.vscode/
1212
credentials.json
13+
.venv
1314

1415
# Android stuff.
1516
*.iml
@@ -34,17 +35,16 @@ components/**/ios/Generated
3435
# We don't car about Cargo.lock for our tests.
3536
testing/sync-test/Cargo.lock
3637

37-
# XCFramework artifact
38+
# iOS Building & XCFramework artifacts
3839
megazords/ios-rust/MozillaRustComponents.xcframework*
3940
megazords/ios-rust/focus/FocusRustComponents.xcframework*
4041
megazords/ios-rust/include*
4142
megazords/ios-rust/.build*
4243
megazords/ios-rust/sources/MozillaRustComponentsWrapper/generated*
43-
44+
megazords/ios-rust/.swiftpm
4445

4546
# Glean generated artifacts
46-
megazords/ios-rust/MozillaTestServices/MozillaTestServices/Generated
47-
megazords/ios-rust/MozillaTestServices/.venv
47+
megazords/ios-rust/.venv
4848

4949
# Carthage generated artifacts
5050
# We no longer use Carthage, but those

automation/run_ios_tests.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if [ "$SKIP_BUILDING" != true ]; then
3737
"${SOURCE_ROOT}"/components/sync_manager/pings.yaml
3838

3939
# Build the XCFramework
40-
./megazords/ios-rust/build-xcframework.sh --build-profile release
40+
./megazords/ios-rust/build-xcframework.sh --generate-swift-sources --build-profile release
4141
else
4242
echo "Skipping xcframework & glean metrics generation as --test-only was passed."
4343
fi
@@ -52,7 +52,7 @@ set -o pipefail
5252
xcodebuild \
5353
-scheme MozillaRustComponents \
5454
-sdk iphonesimulator \
55-
-destination 'platform=iOS Simulator,name=iPhone 15' \
55+
-destination 'platform=iOS Simulator,OS=17.2,name=iPhone 15' \
5656
test | tee raw_xcodetest.log | xcpretty
5757
result=${PIPESTATUS[0]}
5858
set -e
@@ -67,5 +67,4 @@ else
6767
echo "❌ Swift tests failed!"
6868
fi
6969

70-
71-
exit "${result}"
70+
exit "${result}"

libs/verify-ios-environment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ echo " ./automation/run_ios_tests.sh"
2525
echo ""
2626
echo " If you want to just generate the rust binaries"
2727
echo "- Build the XCFramework:"
28-
echo " ./megazords/ios-rust/build-xcframework.sh"
28+
echo " ./megazords/ios-rust/build-xcframework.sh"

megazords/ios-rust/build-xcframework.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
BUILD_PROFILE="release"
66
FRAMEWORK_NAME="MozillaRustComponents"
77
IS_FOCUS=
8+
# Optional flags to pass on to generate-files.sh
9+
GENERATE_ARGS=()
810
# FRAMEWORK_FILENAME exist purely because we would like to ship
911
# multiple frameworks that have the same swift code
1012
# namely for focus. However, components that use
@@ -14,6 +16,9 @@ IS_FOCUS=
1416
# under different file names.
1517
FRAMEWORK_FILENAME=$FRAMEWORK_NAME
1618
while [[ "$#" -gt 0 ]]; do case $1 in
19+
--generate-swift-sources)
20+
GENERATE_ARGS+=(--generate-swift-sources)
21+
shift;;
1722
--build-profile) BUILD_PROFILE="$2"; shift;shift;;
1823
--focus) IS_FOCUS="true"; FRAMEWORK_FILENAME="FocusRustComponents";shift;;
1924
--framework-name) FRAMEWORK_NAME="$2"; shift;shift;;
@@ -146,8 +151,17 @@ UNIFFI_BINDGEN_LIBRARY="$TARGET_DIR/aarch64-apple-ios/$BUILD_PROFILE/$LIB_NAME"
146151
cp "$WORKING_DIR/$FRAMEWORK_NAME.h" "$COMMON/Headers"
147152
cp "$REPO_ROOT/components/viaduct/ios/RustViaductFFI.h" "$COMMON/Headers"
148153

149-
# Next, generate files with uniffi-bindgen
150-
"$THIS_DIR/generate-files.sh" "$UNIFFI_BINDGEN_LIBRARY" "$COMMON"
154+
# Next, generate files with uniffi-bindgen (forward --generate-swift-sources if present)
155+
# You generally want to generate the swift sources if you want to see/test the generated uniffi code
156+
if (( ${#GENERATE_ARGS[@]:-0} )); then
157+
# we have at least one flag in the array
158+
"$THIS_DIR/generate-files.sh" "${GENERATE_ARGS[@]}" \
159+
"$UNIFFI_BINDGEN_LIBRARY" "$COMMON"
160+
else
161+
# no extra flags
162+
"$THIS_DIR/generate-files.sh" \
163+
"$UNIFFI_BINDGEN_LIBRARY" "$COMMON"
164+
fi
151165

152166
# Flesh out the framework for each architecture based on the common files.
153167
# It's a little fiddly, because we apparently need to put all the simulator targets

megazords/ios-rust/generate-files.sh

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,28 @@
22

33
set -ex
44

5-
if [[ $# -ne 2 ]] ; then
6-
echo "USAGE megazords/ios-rust/generate-files.sh [UNIFFI_BINDGEN_LIBRARY] [COMMON]"
5+
BUILD_SOURCES=false
6+
7+
# parse optional flags
8+
while [[ $# -gt 0 ]]; do
9+
case "$1" in
10+
--generate-swift-sources)
11+
BUILD_SOURCES=true
12+
shift
13+
;;
14+
--help|-h)
15+
echo "USAGE: $0 [--generate-swift-sources] UNIFFI_BINDGEN_LIBRARY COMMON"
16+
exit 0
17+
;;
18+
*)
19+
break
20+
;;
21+
esac
22+
done
23+
24+
# expect only two args after optional
25+
if [[ $# -ne 2 ]]; then
26+
echo "USAGE: $0 [--generate-swift-sources] UNIFFI_BINDGEN_LIBRARY COMMON"
727
exit 1
828
fi
929

@@ -26,10 +46,12 @@ CARGO="$HOME/.cargo/bin/cargo"
2646
"$CARGO" uniffi-bindgen-library-mode -l "$UNIFFI_BINDGEN_LIBRARY" swift --modulemap "$COMMON/Modules" --xcframework --modulemap-filename module.modulemap
2747

2848
## Tests will need the generated swift files from uniffi
29-
# TODO: Should we wrap this around an argument? we'd only need this for tests
30-
GENERATED_SWIFT_OUT_DIR="$THIS_DIR/Sources/MozillaRustComponentsWrapper/Generated"
31-
mkdir -p "$GENERATED_SWIFT_OUT_DIR"
32-
"$CARGO" uniffi-bindgen-library-mode -l "$UNIFFI_BINDGEN_LIBRARY" swift --swift-sources "$GENERATED_SWIFT_OUT_DIR"
49+
if [[ "$BUILD_SOURCES" == true ]]; then
50+
echo "Generating uniffi Swift sources..."
51+
GENERATED_SWIFT_OUT_DIR="$THIS_DIR/Sources/MozillaRustComponentsWrapper/Generated"
52+
mkdir -p "$GENERATED_SWIFT_OUT_DIR"
53+
"$CARGO" uniffi-bindgen-library-mode -l "$UNIFFI_BINDGEN_LIBRARY" swift --swift-sources "$GENERATED_SWIFT_OUT_DIR"
54+
fi
3355

3456
# Hack to copy in the RustViaductFFI.h (https://bugzilla.mozilla.org/show_bug.cgi?id=1925601)
3557
cp "$THIS_DIR/../../components/viaduct/ios/RustViaductFFI.h" "$COMMON/Headers"

0 commit comments

Comments
 (0)