Add option to precache unsigned mac binaries. (#42376)
This commit is contained in:
@@ -128,6 +128,9 @@ class Cache {
|
||||
// artifacts for the current platform.
|
||||
bool includeAllPlatforms = false;
|
||||
|
||||
// Whether to cache the unsigned mac binaries. Defaults to caching the signed binaries.
|
||||
bool useUnsignedMacBinaries = false;
|
||||
|
||||
static RandomAccessFile _lock;
|
||||
static bool _lockEnabled = true;
|
||||
|
||||
@@ -1101,12 +1104,14 @@ class IosUsbArtifacts extends CachedArtifact {
|
||||
|
||||
@override
|
||||
Future<void> updateInner() {
|
||||
if (!platform.isMacOS) {
|
||||
if (!platform.isMacOS && !cache.includeAllPlatforms) {
|
||||
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);
|
||||
}
|
||||
|
||||
@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.
|
||||
|
||||
@@ -44,6 +44,8 @@ class PrecacheCommand extends FlutterCommand {
|
||||
help: 'Precache artifacts required for any development platform.');
|
||||
argParser.addFlag('flutter_runner', negatable: true, defaultsTo: false,
|
||||
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
|
||||
@@ -60,6 +62,9 @@ class PrecacheCommand extends FlutterCommand {
|
||||
if (argResults['all-platforms']) {
|
||||
cache.includeAllPlatforms = true;
|
||||
}
|
||||
if (argResults['use-unsigned-mac-binaries']) {
|
||||
cache.useUnsignedMacBinaries = true;
|
||||
}
|
||||
final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{};
|
||||
for (DevelopmentArtifact artifact in DevelopmentArtifact.values) {
|
||||
// Don't include unstable artifacts on stable branches.
|
||||
|
||||
@@ -310,6 +310,32 @@ void main() {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user