Commit 435ad476 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Add --all-platforms option to `flutter precache` (#5254)

parent eebe09d4
...@@ -25,6 +25,10 @@ class Cache { ...@@ -25,6 +25,10 @@ class Cache {
// Initialized by FlutterCommandRunner on startup. // Initialized by FlutterCommandRunner on startup.
static String flutterRoot; static String flutterRoot;
// Whether to cache artifacts for all platforms. Defaults to only caching
// artifacts for the current platform.
bool includeAllPlatforms = false;
static RandomAccessFile _lock; static RandomAccessFile _lock;
static bool _lockEnabled = true; static bool _lockEnabled = true;
...@@ -238,7 +242,9 @@ class FlutterEngine { ...@@ -238,7 +242,9 @@ class FlutterEngine {
'android-x86', 'android-x86',
]; ];
if (Platform.isMacOS) if (cache.includeAllPlatforms)
dirs.addAll(<String>['ios', 'ios-profile', 'ios-release', 'linux-x64']);
else if (Platform.isMacOS)
dirs.addAll(<String>['ios', 'ios-profile', 'ios-release']); dirs.addAll(<String>['ios', 'ios-profile', 'ios-release']);
else if (Platform.isLinux) else if (Platform.isLinux)
dirs.add('linux-x64'); dirs.add('linux-x64');
......
...@@ -8,6 +8,11 @@ import '../globals.dart'; ...@@ -8,6 +8,11 @@ import '../globals.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
class PrecacheCommand extends FlutterCommand { class PrecacheCommand extends FlutterCommand {
PrecacheCommand() {
argParser.addFlag('all-platforms', abbr: 'a', negatable: false,
help: 'Precache artifacts for all platforms.');
}
@override @override
final String name = 'precache'; final String name = 'precache';
...@@ -19,6 +24,9 @@ class PrecacheCommand extends FlutterCommand { ...@@ -19,6 +24,9 @@ class PrecacheCommand extends FlutterCommand {
@override @override
Future<int> runInProject() async { Future<int> runInProject() async {
if (argResults['all-platforms'])
cache.includeAllPlatforms = true;
if (cache.isUpToDate()) if (cache.isUpToDate())
printStatus('Already up-to-date.'); printStatus('Already up-to-date.');
else else
......
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