Skip to content

Commit cf57f9f

Browse files
author
Tarik Eshaq
authored
Ships a focus megazord and updates to 93.2.0 (#56)
* Ships a focus megazord * Updates package swift script * Updates package swift to use proper release url * Updates package swift to use version 93.2.0 * Version 93.2.0
1 parent ab13793 commit cf57f9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+4470
-11
lines changed

FocusRustComponentsWrapper/dummy.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
*/
5+
6+
// Swift Package Manager needs at least one source file.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
*/
5+
6+
// Swift Package Manager needs at least one header to prevent a warning. See
7+
// https://github.com/mozilla/application-services/issues/4422.

Package.swift

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
// swift-tools-version:5.4
22
import PackageDescription
33

4-
let checksum = "3d97e0661ccc4b45ee58b35ed958e19d8e419985ea5efd9b58078dd086f057ce"
5-
let version = "v93.1.0"
4+
let checksum = "8df6c1aeb572c5efbf792b58dbe1fc4dab31672d83be2cf41c5339ef4b1680c8"
5+
let version = "v93.2.0"
66
let url = "https://github.com/mozilla/application-services/releases/download/\(version)/MozillaRustComponents.xcframework.zip"
77

8+
// Focus xcframework
9+
let focusChecksum = "2c9fbc8086c124a9256eb921290a605ec7de5e865e3cd1af6df7779662f0683a"
10+
let focusUrl = "https://github.com/mozilla/application-services/releases/download/\(version)/FocusRustComponents.xcframework.zip"
811
let package = Package(
912
name: "MozillaRustComponentsSwift",
1013
platforms: [.iOS(.v11)],
1114
products: [
1215
.library(name: "MozillaAppServices", targets: ["MozillaAppServices"]),
16+
.library(name: "FocusAppServices", targets: ["FocusAppServices"]),
1317
],
1418
dependencies: [
1519
],
@@ -26,6 +30,13 @@ let package = Package(
2630
],
2731
path: "MozillaRustComponentsWrapper"
2832
),
33+
.target(
34+
name: "FocusRustComponentsWrapper",
35+
dependencies: [
36+
.target(name: "FocusRustComponents", condition: .when(platforms: [.iOS]))
37+
],
38+
path: "FocusRustComponentsWrapper"
39+
),
2940
.binaryTarget(
3041
name: "MozillaRustComponents",
3142
//
@@ -40,10 +51,29 @@ let package = Package(
4051
//
4152
//path: "./MozillaRustComponents.xcframework"
4253
),
54+
.binaryTarget(
55+
name: "FocusRustComponents",
56+
//
57+
// For release artifacts, reference the MozillaRustComponents as a URL with checksum.
58+
// IMPORTANT: The checksum has to be on the line directly after the `url`
59+
// this is important for our release script so that all values are updated correctly
60+
url: focusUrl,
61+
checksum: focusChecksum
62+
63+
// For local testing, you can point at an (unzipped) XCFramework that's part of the repo.
64+
// Note that you have to actually check it in and make a tag for it to work correctly.
65+
//
66+
//path: "./FocusRustComponents.xcframework"
67+
),
4368
.target(
4469
name: "MozillaAppServices",
4570
dependencies: ["MozillaRustComponentsWrapper"],
46-
path: "swift-source"
71+
path: "swift-source/all"
72+
),
73+
.target(
74+
name: "FocusAppServices",
75+
dependencies: ["FocusRustComponentsWrapper"],
76+
path: "swift-source/focus"
4777
),
4878
]
4979
)

automation/update_package_swift.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
GITHUB_REPO = "mozilla/application-services"
99
XC_FRAMEWORK_NAME = "MozillaRustComponents.xcframework.zip"
10+
FOCUS_FRAMEWORK_NAME = "FocusRustComponents.xcframework.zip"
11+
1012
PACKAGE_SWIFT = "Package.swift"
1113
github_access_token = os.getenv("GITHUB_TOKEN")
1214
as_version = os.getenv("AS_VERSION")
@@ -16,25 +18,33 @@ def get_xcframework_artifact():
1618
repo = g.get_repo(GITHUB_REPO)
1719

1820
release = repo.get_release(as_version)
21+
full_xcframework = None
22+
focus_xcframework = None
1923
for asset in release.get_assets():
2024
if asset.name == XC_FRAMEWORK_NAME:
21-
return asset.browser_download_url
25+
full_xcframework = asset.browser_download_url
26+
elif asset.name == FOCUS_FRAMEWORK_NAME:
27+
focus_xcframework = asset.browser_download_url
28+
return (full_xcframework, focus_xcframework)
2229

2330
def compute_checksum(xc_framework_url):
2431
req = requests.get(xc_framework_url)
2532
return hashlib.sha256(req.content).hexdigest()
2633

27-
def update_package_swift(as_version, checksum):
34+
def update_package_swift(as_version, checksum, focus_checksum):
2835
version_line = "let version ="
2936
checksum_line = "let checksum ="
30-
37+
focus_checksum_line = "let focusChecksum ="
3138
for line in fileinput.input(PACKAGE_SWIFT, inplace=1):
3239
if line.strip().startswith(version_line):
3340
# Replace the line with the new version included
3441
line = f"{version_line} \"{as_version}\"\n"
3542
elif line.strip().startswith(checksum_line):
3643
# Replace the line with the new computed checksum
3744
line = f"{checksum_line} \"{checksum}\"\n"
45+
elif line.strip().startswith(focus_checksum_line):
46+
# Replace the line with the new computed checksum
47+
line = f"{focus_checksum_line} \"{focus_checksum}\"\n"
3848
sys.stdout.write(line)
3949
def main():
4050
'''
@@ -43,10 +53,10 @@ def main():
4353
'''
4454
if not github_access_token or not as_version:
4555
exit(1)
46-
xc_framework_url = get_xcframework_artifact()
56+
xc_framework_url, focus_xcframework_url = get_xcframework_artifact()
4757
checksum = compute_checksum(xc_framework_url)
48-
update_package_swift(as_version, checksum)
49-
58+
focus_checksum = compute_checksum(focus_xcframework_url)
59+
update_package_swift(as_version, checksum, focus_checksum)
5060

5161

5262
if __name__ == '__main__':

generate.sh

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ GLEAN_GENERATOR="$APP_SERVICES_DIR/components/external/glean/glean-core/ios/sdk_
2121

2222
set -euvx
2323

24-
OUT_DIR="$THIS_DIR/swift-source"
24+
OUT_DIR="$THIS_DIR/swift-source/all"
25+
FOCUS_DIR="$THIS_DIR/swift-source/focus"
2526

2627
rm -rf "$OUT_DIR" && mkdir -p "$OUT_DIR"
28+
rm -rf "$FOCUS_DIR" && mkdir -p "$FOCUS_DIR"
29+
2730

2831
# Glean metrics.
2932
# Run this first, because it appears to delete any other .swift files in the output directory.
@@ -139,4 +142,44 @@ cp -r "$APP_SERVICES_DIR/components/rc_log/ios/" $OUT_DIR
139142
# We only need to copy the hand-written Swift, Viaduct does not use `uniffi` yet
140143
cp -r "$APP_SERVICES_DIR/components/viaduct/ios/" $OUT_DIR
141144

145+
146+
###################### Swift code generation for Focus ######################
147+
# Glean metrics.
148+
# Run this first, because it appears to delete any other .swift files in the output directory.
149+
# Also, it wants to be run from inside Xcode, so we set some env vars to fake it out.
150+
SOURCE_ROOT="$THIS_DIR" PROJECT="FocusAppServices" "$GLEAN_GENERATOR" -o "$FOCUS_DIR/Generated/Metrics/" "$APP_SERVICES_DIR/components/nimbus/metrics.yaml"
151+
152+
153+
154+
###
155+
#
156+
# Nimbus
157+
#
158+
###
159+
# UniFFI bindings.
160+
"${UNIFFI_BINDGEN[@]}" generate -l swift -o "$FOCUS_DIR/Generated" "$APP_SERVICES_DIR/components/nimbus/src/nimbus.udl"
161+
# Copy the hand-written Swift, since it all needs to be together in one directory.
162+
cp -r "$APP_SERVICES_DIR/components/nimbus/ios/Nimbus" "$FOCUS_DIR"
163+
164+
###
165+
#
166+
# RustLog
167+
#
168+
###
169+
170+
# We only need to copy the hand-written Swift, RustLog does not use `uniffi` yet
171+
cp -r "$APP_SERVICES_DIR/components/rc_log/ios/" $FOCUS_DIR
172+
173+
174+
###
175+
#
176+
# Viaduct
177+
#
178+
###
179+
180+
# We only need to copy the hand-written Swift, Viaduct does not use `uniffi` yet
181+
cp -r "$APP_SERVICES_DIR/components/viaduct/ios/" $FOCUS_DIR
182+
183+
184+
142185
echo "Successfully generated uniffi code!"

0 commit comments

Comments
 (0)