Unverified Commit 5a41374a authored by Lau Ching Jun's avatar Lau Ching Jun Committed by GitHub

Add option to precache unsigned mac binaries. (#42376)

parent 02470fe2
...@@ -128,6 +128,9 @@ class Cache { ...@@ -128,6 +128,9 @@ class Cache {
// artifacts for the current platform. // artifacts for the current platform.
bool includeAllPlatforms = false; bool includeAllPlatforms = false;
// Whether to cache the unsigned mac binaries. Defaults to caching the signed binaries.
bool useUnsignedMacBinaries = false;
static RandomAccessFile _lock; static RandomAccessFile _lock;
static bool _lockEnabled = true; static bool _lockEnabled = true;
...@@ -1101,12 +1104,14 @@ class IosUsbArtifacts extends CachedArtifact { ...@@ -1101,12 +1104,14 @@ class IosUsbArtifacts extends CachedArtifact {
@override @override
Future<void> updateInner() { Future<void> updateInner() {
if (!platform.isMacOS) { if (!platform.isMacOS && !cache.includeAllPlatforms) {
return Future<void>.value(); return Future<void>.value();
} }
final Uri archiveUri = Uri.parse('$_storageBaseUrl/flutter_infra/ios-usb-dependencies/$name/$version/$name.zip');
return _downloadZipArchive('Downloading $name...', archiveUri, location); return _downloadZipArchive('Downloading $name...', archiveUri, location);
} }
@visibleForTesting
Uri get archiveUri => Uri.parse('$_storageBaseUrl/flutter_infra/ios-usb-dependencies${cache.useUnsignedMacBinaries ? '/unsigned' : ''}/$name/$version/$name.zip');
} }
// Many characters are problematic in filenames, especially on Windows. // Many characters are problematic in filenames, especially on Windows.
......
...@@ -44,6 +44,8 @@ class PrecacheCommand extends FlutterCommand { ...@@ -44,6 +44,8 @@ class PrecacheCommand extends FlutterCommand {
help: 'Precache artifacts required for any development platform.'); help: 'Precache artifacts required for any development platform.');
argParser.addFlag('flutter_runner', negatable: true, defaultsTo: false, argParser.addFlag('flutter_runner', negatable: true, defaultsTo: false,
help: 'Precache the flutter runner artifacts.', hide: true); help: 'Precache the flutter runner artifacts.', hide: true);
argParser.addFlag('use-unsigned-mac-binaries', negatable: true, defaultsTo: false,
help: 'Precache the unsigned mac binaries when available.', hide: true);
} }
@override @override
...@@ -60,6 +62,9 @@ class PrecacheCommand extends FlutterCommand { ...@@ -60,6 +62,9 @@ class PrecacheCommand extends FlutterCommand {
if (argResults['all-platforms']) { if (argResults['all-platforms']) {
cache.includeAllPlatforms = true; cache.includeAllPlatforms = true;
} }
if (argResults['use-unsigned-mac-binaries']) {
cache.useUnsignedMacBinaries = true;
}
final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{}; final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{};
for (DevelopmentArtifact artifact in DevelopmentArtifact.values) { for (DevelopmentArtifact artifact in DevelopmentArtifact.values) {
// Don't include unstable artifacts on stable branches. // Don't include unstable artifacts on stable branches.
......
...@@ -310,6 +310,32 @@ void main() { ...@@ -310,6 +310,32 @@ void main() {
ProcessManager: () => processManager, ProcessManager: () => processManager,
}); });
}); });
group('Unsigned mac artifacts', () {
MockCache mockCache;
setUp(() {
mockCache = MockCache();
});
testUsingContext('use unsigned when specified', () async {
when(mockCache.useUnsignedMacBinaries).thenReturn(true);
final IosUsbArtifacts iosUsbArtifacts = IosUsbArtifacts('name', mockCache);
expect(iosUsbArtifacts.archiveUri.toString(), contains('/unsigned/'));
}, overrides: <Type, Generator>{
Cache: () => mockCache,
});
testUsingContext('not use unsigned when not specified', () async {
when(mockCache.useUnsignedMacBinaries).thenReturn(false);
final IosUsbArtifacts iosUsbArtifacts = IosUsbArtifacts('name', mockCache);
expect(iosUsbArtifacts.archiveUri.toString(), isNot(contains('/unsigned/')));
}, overrides: <Type, Generator>{
Cache: () => mockCache,
});
});
} }
class FakeCachedArtifact extends EngineCachedArtifact { class FakeCachedArtifact extends EngineCachedArtifact {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment