Skip to content

Commit 9b26398

Browse files
Make Google Maps package self-contained (#204)
* Make Google Maps package self-contained * Add Maps self-contained package validation
1 parent 41d0962 commit 9b26398

14 files changed

Lines changed: 194 additions & 428 deletions

.github/workflows/google-foundation-validation.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212
- "*.cake"
1313
- "icons/googleiosmaps_128x128.png"
1414
- "icons/googleiosplaces_128x128.png"
15-
- "scripts/check-maps-resource-manifest.py"
1615
- "source/AssemblyInfo.cs"
1716
- "source/Google/Maps/**"
1817
- "source/Google/Places/**"
@@ -34,7 +33,6 @@ on:
3433
- "*.cake"
3534
- "icons/googleiosmaps_128x128.png"
3635
- "icons/googleiosplaces_128x128.png"
37-
- "scripts/check-maps-resource-manifest.py"
3836
- "source/AssemblyInfo.cs"
3937
- "source/Google/Maps/**"
4038
- "source/Google/Places/**"
@@ -154,15 +152,24 @@ jobs:
154152
- name: Pack Google.Maps
155153
run: dotnet tool run dotnet-cake -- --target=nuget --names=Google.Maps
156154

157-
- name: Maps resource manifest check
158-
run: python3 scripts/check-maps-resource-manifest.py
155+
- name: Package structure checks
156+
run: >-
157+
tools/e2e/check-package-structure.sh
158+
--target Maps
159+
--package-dir output
159160
160161
- name: Direct and transitive consumer checks
161162
run: >-
162163
tools/e2e/check-consumer-shapes.sh
163164
--target Maps
164165
--package-dir output
165166
167+
- name: Offline build proof
168+
run: >-
169+
tools/e2e/check-offline-build.sh
170+
--target Maps
171+
--package-dir output
172+
166173
- name: Simulator E2E
167174
run: >-
168175
tools/e2e/run-google-foundation.sh

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Firebase `12.10.0` is the current published Firebase package line.
196196

197197
| Package | Version |
198198
| --- | --- |
199-
| `Maps` | `9.2.0.8` |
199+
| `Maps` | `9.2.0.9` |
200200
| `Places` | `7.4.0.3` |
201201
| `SignIn` | `9.0.0` |
202202

build.cake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ Task ("externals")
171171
FirebaseAnalyticsDownload ();
172172
if (ARTIFACTS_TO_BUILD.Contains (GOOGLE_GOOGLE_APP_MEASUREMENT_ARTIFACT))
173173
GoogleAppMeasurementDownload ();
174+
if (ARTIFACTS_TO_BUILD.Contains (GOOGLE_MAPS_ARTIFACT))
175+
GoogleMapsDownload ();
174176
if (ARTIFACTS_TO_BUILD.Contains (GOOGLE_PLACES_ARTIFACT))
175177
GooglePlacesDownload ();
176178
});

components.cake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Artifact FIREBASE_APP_CHECK_ARTIFACT = new Artifact ("Firebase.App
1919
// Google artifacts available to be built. These artifacts generate NuGets.
2020
Artifact GOOGLE_ANALYTICS_ARTIFACT = new Artifact ("Google.Analytics", "3.20.0.2", "15.0", ComponentGroup.Google, csprojName: "Analytics");
2121
Artifact GOOGLE_CAST_ARTIFACT = new Artifact ("Google.Cast", "4.7.0.1", "15.0", ComponentGroup.Google, csprojName: "Cast");
22-
Artifact GOOGLE_MAPS_ARTIFACT = new Artifact ("Google.Maps", "9.2.0.8", "15.0", ComponentGroup.Google, csprojName: "Maps");
22+
Artifact GOOGLE_MAPS_ARTIFACT = new Artifact ("Google.Maps", "9.2.0.9", "15.0", ComponentGroup.Google, csprojName: "Maps");
2323
Artifact GOOGLE_UMP_ARTIFACT = new Artifact ("Google.UserMessagingPlatform", "1.1.0.1", "15.0", ComponentGroup.Google, csprojName: "UserMessagingPlatform");
2424
Artifact GOOGLE_PLACES_ARTIFACT = new Artifact ("Google.Places", "7.4.0.3", "15.0", ComponentGroup.Google, csprojName: "Places");
2525
Artifact GOOGLE_APP_CHECK_CORE_ARTIFACT = new Artifact ("Google.AppCheckCore", "11.2.0.0", "15.0", ComponentGroup.Google, csprojName: "AppCheckCore");
@@ -220,7 +220,7 @@ void SetArtifactsPodSpecs ()
220220
PodSpec.Create ("google-cast-sdk", "4.7.0")
221221
};
222222
GOOGLE_MAPS_ARTIFACT.PodSpecs = new [] {
223-
PodSpec.Create ("GoogleMaps", "9.2.0")
223+
PodSpec.Create ("GoogleMaps", "9.2.0", frameworkSource: FrameworkSource.Custom)
224224
};
225225
GOOGLE_UMP_ARTIFACT.PodSpecs = new [] {
226226
PodSpec.Create ("GoogleUserMessagingPlatform", "1.1.0")

custom_externals_download.cake

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,44 @@ class ExternalDownloadSource
88
public string Version { get; }
99
public string ArchiveKey { get; }
1010
public string UrlPrefix { get; }
11-
12-
public ExternalDownloadSource (string id, string version, string archiveKey, string urlPrefix = DefaultUrlPrefix)
11+
public string ExtractionRootName { get; }
12+
public string ExpectedSha256 { get; }
13+
14+
public ExternalDownloadSource (
15+
string id,
16+
string version,
17+
string archiveKey,
18+
string urlPrefix = DefaultUrlPrefix,
19+
string extractionRootName = null,
20+
string expectedSha256 = null)
1321
{
1422
Id = id;
1523
Version = version;
1624
ArchiveKey = archiveKey;
1725
UrlPrefix = urlPrefix;
26+
ExtractionRootName = extractionRootName ?? $"{Id}-{Version}";
27+
ExpectedSha256 = expectedSha256;
1828
}
1929

2030
public string ArchiveFileName => $"{Id}-{Version}.tar.gz";
21-
public string ExtractionRootName => $"{Id}-{Version}";
2231
public string Url => $"{UrlPrefix}/{ArchiveKey}/{ArchiveFileName}";
2332
}
2433

2534
// *.tar.gz URLs can be found in the podspecs (e.g., CocoaPods Specs repo paths), such as:
2635
// FirebaseAnalytics: https://github.com/CocoaPods/Specs/tree/master/Specs/e/2/1/FirebaseAnalytics
2736
// GoogleAppMeasurement: https://github.com/CocoaPods/Specs/tree/master/Specs/e/3/b/GoogleAppMeasurement
37+
// GoogleMaps: https://github.com/CocoaPods/Specs/tree/master/Specs/1/9/0/GoogleMaps
2838
// GooglePlaces: https://github.com/CocoaPods/Specs/tree/master/Specs/c/3/2/GooglePlaces
2939
var ExternalDownloads = new Dictionary<string, ExternalDownloadSource> {
3040
{ "FirebaseAnalytics", new ExternalDownloadSource ("FirebaseAnalytics", "12.10.0", "3c185b45848d98d8") },
3141
{ "GoogleAppMeasurement", new ExternalDownloadSource ("GoogleAppMeasurement", "12.10.0", "5f5e4d8cb469941e") },
42+
{ "GoogleMaps", new ExternalDownloadSource (
43+
"GoogleMaps",
44+
"9.2.0",
45+
"33a7ac549361ab23",
46+
"https://dl.google.com/dl/cpdc",
47+
extractionRootName: "Maps",
48+
expectedSha256: "81bbd92c2d627087ae222ae955e5f746590812d7389b9d800add15e4004b6431") },
3249
{ "GooglePlaces", new ExternalDownloadSource ("GooglePlaces", "7.4.0", "3e8dc2602895d53405d075ff4eb569bff93ff1af97e69915d1e657c07ef28dd8", "https://dl.google.com/dl/geosdk") },
3350
};
3451

@@ -60,6 +77,7 @@ void DownloadAndExtract (ExternalDownloadSource source, Func<bool> artifactsAlre
6077
DeleteFile (archivePath);
6178

6279
DownloadArchive (source, archivePath);
80+
VerifyArchiveHash (source, archivePath);
6381

6482
var exitCode = ExtractArchive (source, externalsPath, archivePath);
6583

@@ -84,6 +102,22 @@ void DownloadArchive (ExternalDownloadSource source, FilePath archivePath)
84102
DownloadFile (source.Url, archivePath);
85103
}
86104

105+
void VerifyArchiveHash (ExternalDownloadSource source, FilePath archivePath)
106+
{
107+
if (string.IsNullOrWhiteSpace (source.ExpectedSha256))
108+
return;
109+
110+
string actualSha256;
111+
using (var stream = System.IO.File.OpenRead (archivePath.FullPath))
112+
using (var sha256 = System.Security.Cryptography.SHA256.Create ())
113+
actualSha256 = BitConverter.ToString (sha256.ComputeHash (stream)).Replace ("-", "").ToLowerInvariant ();
114+
115+
if (!string.Equals (actualSha256, source.ExpectedSha256, StringComparison.OrdinalIgnoreCase))
116+
throw new Exception ($"SHA-256 mismatch for {source.ArchiveFileName}: expected {source.ExpectedSha256}, got {actualSha256}.");
117+
118+
Information ($"Verified SHA-256 for {source.ArchiveFileName}.");
119+
}
120+
87121
void FirebaseAnalyticsDownload ()
88122
{
89123
var source = ExternalDownloads["FirebaseAnalytics"];
@@ -126,6 +160,37 @@ void GooglePlacesDownload ()
126160
});
127161
}
128162

163+
void GoogleMapsDownload ()
164+
{
165+
var source = ExternalDownloads["GoogleMaps"];
166+
167+
DownloadAndExtract (
168+
source,
169+
() => DirectoryExists (new DirectoryPath ("./externals/GoogleMaps.xcframework")) &&
170+
DirectoryExists (new DirectoryPath ("./externals/GoogleMaps.bundle")),
171+
(extractionRoot, externalsPath, deleteSettings) => {
172+
var frameworkSource = extractionRoot.Combine ("Frameworks").Combine ("GoogleMaps.xcframework");
173+
var resourceSource = extractionRoot.Combine ("Resources").Combine ("GoogleMapsResources").Combine ("GoogleMaps.bundle");
174+
var frameworkDestination = externalsPath.Combine ("GoogleMaps.xcframework");
175+
var resourceDestination = externalsPath.Combine ("GoogleMaps.bundle");
176+
177+
if (!DirectoryExists (frameworkSource))
178+
throw new Exception ($"Expected GoogleMaps.xcframework at {frameworkSource} after extraction.");
179+
180+
if (!DirectoryExists (resourceSource))
181+
throw new Exception ($"Expected GoogleMaps.bundle at {resourceSource} after extraction.");
182+
183+
if (DirectoryExists (frameworkDestination))
184+
DeleteDirectory (frameworkDestination, deleteSettings);
185+
186+
if (DirectoryExists (resourceDestination))
187+
DeleteDirectory (resourceDestination, deleteSettings);
188+
189+
CopyDirectory (frameworkSource, frameworkDestination);
190+
CopyDirectory (resourceSource, resourceDestination);
191+
});
192+
}
193+
129194
void GoogleAppMeasurementDownload ()
130195
{
131196
var source = ExternalDownloads["GoogleAppMeasurement"];

0 commit comments

Comments
 (0)