Skip to content

Commit 242098f

Browse files
author
Tarik Eshaq
authored
Fixes SYNC-3801: Use the same taskcluster script in a-s for local development (#120)
* Fixes SYNC-3801: Use the same taskcluster script in a-s for local development * Removes outdated scripts and documentation
1 parent 99d233d commit 242098f

File tree

6 files changed

+52
-396
lines changed

6 files changed

+52
-396
lines changed

README.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ a format understood by the Swift package manager, and depends on a pre-compiled
66
binary release of the underlying Rust code published from [mozilla/application-services](
77
https://github.com/mozilla/application-service).
88

9+
**This repository is mostly updated by automation, all the logic is copied from [mozilla/application-services](
10+
https://github.com/mozilla/application-service)**
11+
12+
## Overview
13+
14+
* The `application-services` repo publishes two binary artifacts `MozillaRustComponents.xcframework.zip` and `FocusRustComponents.xcframework.zip` containing
15+
the Rust code and FFI definitions for all components, compiled together into a single library.
16+
* The `Package.swift` file refrences the xcframeworks as Swift binary targets.
17+
* The `Package.swift` file defines a library per target (one for all the components used by `firefox-ios` and one for `focus-ios`)
18+
* Each library references its Swift source code directly as files in the repo. All components used by a target are copied into the same directory. For example, all the `firefox-ios` files are in the `swift-source/all` directory.
19+
* Each library depends on wrapper which wraps the binary to provide the pre-compiled Rust code. For example, [`FocusRustComponentWrapper`](./FocusRustComponentsWrapper/) wraps the Focus xcframework.
20+
921
For more information, please consult:
1022

1123
* [application-services ADR-0003](https://github.com/mozilla/application-services/blob/main/docs/adr/0003-swift-packaging.md),
@@ -15,43 +27,29 @@ For more information, please consult:
1527
* The [`ios-rust` crate](https://github.com/mozilla/application-services/tree/main/megazords/ios-rust) which is currently
1628
responsible for publishing the pre-built `MozillaRustComponents.xcframework.zip` and `FocusRustComponents.xcframework.zip` bundles on which this repository depends.
1729

18-
## Overview
19-
20-
Here's a diagram of how this repository relates to the application-services repository
21-
and its release artifacts:
22-
23-
<!--
24-
N.B. you can edit this image in Google Docs and changes will be reflected automatically:
2530

26-
https://docs.google.com/drawings/d/1tX05I-e6hNBQxch7PescDH7k4G7ddAJwXDPoIqp1RYk/edit
27-
-->
28-
<img src="https://docs.google.com/drawings/d/e/2PACX-1vRnyxy7VjdD3bYTso8V3AL5FpIQ4_S54dOCDI6fxfZEbG3_CVBwZZP1uLYbUVE9M54GSXUkNgewzOQm/pub?w=720&h=540" width="720" height="540" alt="A box diagram describing how the rust-components-swift repo, applicaiton-services repo, and MozillaRustComponents XCFramework interact">
31+
## Releases
32+
### Nightly
2933

30-
Key points:
34+
Nightly releases are automated and run every night as a cron job that pushes directly to the main branch. Nightly releases are tagged with three components (i.e `X.0.Y`) where the first component is the current Firefox release (i.e `117`, etc) and the last component is a timestamp.
3135

32-
* The `application-services` repo publishes two binary artifacts `MozillaRustComponents.xcframework.zip` and `FocusRustComponents.xcframework.zip` containing
33-
the Rust code and FFI definitions for all components, compiled together into a single library.
34-
* The `Package.swift` file refrences the xcframeworks as Swift binary targets.
35-
* The `Package.swift` file defines a library per target (one for all the components used by `firefox-ios` and one for `focus-ios`)
36-
* Each library references its Swift source code directly as files in the repo. All components used by a target are copied into the same directory. For example, all the `firefox-ios` files are in the `swift-source/all` directory.
37-
* Each library depends on wrapper which wraps the binary to provide the pre-compiled Rust code. For example, [`FocusRustComponentWrapper`](./FocusRustComponentsWrapper/) wraps the Focus xcframework.
36+
Note that we need three components because that's a Swift Package manager requirement.
3837

39-
## Cutting a new release
38+
### Cutting a Release
4039

41-
Whenever a new release of the underlying components is availble, we need to tag a new release
42-
in this repo to make them available to Swift components. To do so:
40+
To cut a release of `rust-components-swift`, you will need to do the following:
41+
- Run `./automation/update-from-application-services.py <X.Y>`, where `X.Y` is the version of application services.
42+
- Open a pull request with the resulting changes
43+
- Once landed on the main branch, cut a release using the GitHub UI and tag it
44+
- **IMPORTANT**: The release tag must be in the form `X.0.Y`, where `X.Y` is the version of application services
4345

44-
* Edit `Package.swift` to update the URL and checksum of `MozillaRustComponents.xcframework.zip`.
45-
* Run `./make_tag.sh --as-version {APP_SERVICES_VERSION} X.Y.Z` to create the new tag.
46-
* Run `git push origin X.Y.Z` to publish it to GitHub.
46+
## Testing and Local development
47+
To enable local development of `rust-component-swift` read the instructions [documented in application services](https://mozilla.github.io/application-services/book/howtos/locally-published-components-in-firefox-ios.html)
4748

4849
## Adding a new component
4950

5051
Check out the instructions in the [docs in `application-services` for adding a new component and publishing it for iOS](https://github.com/mozilla/application-services/blob/main/docs/howtos/adding-a-new-component.md#distribute-your-component-with-rust-components-swift). The docs are also published for convenience in <https://mozilla.github.io/application-services/book/index.html>.
5152

5253

53-
## Testing
54-
For testing instructions, you can checkout the [docs in the `application-services`](https://github.com/mozilla/application-services/tree/main/docs/howtos) which are published for convenience in <https://mozilla.github.io/application-services/book/index.html>
55-
5654
## Filing issues with rust-components-swift
5755
Please open a ticket in https://github.com/mozilla/application-services/issues for any rust-component-swift related issues.

appservices_local_xcframework.sh

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
4646
PACKAGE_FILE="$THIS_DIR/Package.swift"
4747
SWIFT_SOURCE="$THIS_DIR/swift-source"
4848
FRAMEWORK_PATH="./MozillaRustComponents.xcframework"
49+
FOCUS_FRAMEWORK_PATH="./FocusRustComponents.xcframework"
4950
FRAMEWORK_PATH_ESCAPED=$( echo $FRAMEWORK_PATH | sed 's/\//\\\//g' )
51+
FOCUS_FRAMEWORK_PATH_ESCAPED=$( echo $FOCUS_FRAMEWORK_PATH | sed 's/\//\\\//g' )
5052
APP_SERVICES_REMOTE="https://github.com/mozilla/application-services"
5153

5254
DISABLE="false"
@@ -87,6 +89,8 @@ if [ "true" = $DISABLE ]; then
8789
# state they were in before any of the changes happened.
8890
perl -0777 -pi -e "s/ path: \"$FRAMEWORK_PATH_ESCAPED\"/ url: url,
8991
checksum: checksum/igs" $PACKAGE_FILE
92+
perl -0777 -pi -e "s/ path: \"$FOCUS_FRAMEWORK_PATH_ESCAPED\"/ url: focusUrl,
93+
checksum: focusChecksum/igs" $PACKAGE_FILE
9094

9195
msg "Done reseting $PACKAGE_FILE"
9296
git add $PACKAGE_FILE
@@ -98,6 +102,12 @@ if [ "true" = $DISABLE ]; then
98102
git add $FRAMEWORK_PATH
99103
msg "Deleted and staged the deletion of the local framework"
100104
fi
105+
if [ -d $FOCUS_FRAMEWORK_PATH ]; then
106+
msg "Detected local framework, deleting it.."
107+
rm -rf $FOCUS_FRAMEWORK_PATH
108+
git add $FOCUS_FRAMEWORK_PATH
109+
msg "Deleted and staged the deletion of the local framework"
110+
fi
101111
msg "IMPORTANT: reminder that changes to this repository are not visable to consumers until
102112
commited"
103113
exit 0
@@ -110,31 +120,36 @@ if [ -z $APP_SERVICES_DIR ]; then
110120
exit 1
111121
fi
112122

123+
## We replace the url and checksum in the Package.swift with a refernce to the local
124+
## framework path
125+
perl -0777 -pi -e "s/ url: url,
126+
checksum: checksum/ path: \"$FRAMEWORK_PATH_ESCAPED\"/igs" $PACKAGE_FILE
127+
128+
## We replace the url and checksum in the Package.swift with a refernce to the local
129+
## framework path
130+
perl -0777 -pi -e "s/ url: focusUrl,
131+
checksum: focusChecksum/ path: \"$FOCUS_FRAMEWORK_PATH_ESCAPED\"/igs" $PACKAGE_FILE
132+
133+
rm -rf "$SWIFT_SOURCE"
134+
113135
## First we build the xcframework in the application services repository
114136
msg "Building the xcframework in $APP_SERVICES_DIR"
115137
msg "This might take a few minutes"
116-
pushd $APP_SERVICES_DIR/megazords/ios-rust/
117-
./build-xcframework.sh
138+
pushd $APP_SERVICES_DIR
139+
./taskcluster/scripts/build-and-test-swift.py "$SWIFT_SOURCE" "$THIS_DIR" "$THIS_DIR/build/glean-dir" --force_build
118140
popd
141+
unzip -o "$THIS_DIR/MozillaRustComponents.xcframework.zip" && rm "$THIS_DIR/MozillaRustComponents.xcframework.zip"
142+
unzip -o "$THIS_DIR/FocusRustComponents.xcframework.zip" && rm "$THIS_DIR/FocusRustComponents.xcframework.zip"
119143

120-
## Once built, we want to move the frameowork to this repository, then unzip it
121-
rsync -a --delete $APP_SERVICES_DIR/megazords/ios-rust/MozillaRustComponents.xcframework/ $THIS_DIR/MozillaRustComponents.xcframework/
122-
123-
## We replace the url and checksum in the Package.swift with a refernce to the local
124-
## framework path
125-
perl -0777 -pi -e "s/ url: url,
126-
checksum: checksum/ path: \"$FRAMEWORK_PATH_ESCAPED\"/igs" $PACKAGE_FILE
127144

128-
## We also add the xcframework to git, and remind the user that it **needs** to be committed
145+
## We also add the xcframework and swiftsource to git, and remind the user that it **needs** to be committed
129146
## for it to be used
130147
msg "Staging the xcframework and package.swift changes to git"
131148
git add $FRAMEWORK_PATH
149+
git add $FOCUS_FRAMEWORK_PATH
132150
git add $PACKAGE_FILE
133151

134152

135-
## We should also get the swift-source code copied and staged as well
136-
msg "Generating swift source code..."
137-
./generate.sh $APP_SERVICES_DIR
138153
msg "Swift source code also generated, staging it now"
139154
git add $SWIFT_SOURCE
140155

automation/is_already_updated.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

automation/read_as_tag.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)