Allow downloading of desktop embedding artifacts (#30648)
This commit is contained in:
@@ -51,6 +51,9 @@ class Cache {
|
||||
_artifacts.add(GradleWrapper(this));
|
||||
_artifacts.add(FlutterWebSdk(this));
|
||||
_artifacts.add(FlutterSdk(this));
|
||||
_artifacts.add(WindowsEngineArtifacts(this));
|
||||
_artifacts.add(MacOSEngineArtifacts(this));
|
||||
_artifacts.add(LinuxEngineArtifacts(this));
|
||||
} else {
|
||||
_artifacts.addAll(artifacts);
|
||||
}
|
||||
@@ -535,11 +538,14 @@ abstract class EngineCachedArtifact extends CachedArtifact {
|
||||
|
||||
_makeFilesExecutable(dir);
|
||||
|
||||
final File frameworkZip = fs.file(fs.path.join(dir.path, 'Flutter.framework.zip'));
|
||||
if (frameworkZip.existsSync()) {
|
||||
final Directory framework = fs.directory(fs.path.join(dir.path, 'Flutter.framework'));
|
||||
framework.createSync();
|
||||
os.unzip(frameworkZip, framework);
|
||||
const List<String> frameworkNames = <String>['Flutter', 'FlutterMacOS'];
|
||||
for (String frameworkName in frameworkNames) {
|
||||
final File frameworkZip = fs.file(fs.path.join(dir.path, '$frameworkName.framework.zip'));
|
||||
if (frameworkZip.existsSync()) {
|
||||
final Directory framework = fs.directory(fs.path.join(dir.path, '$frameworkName.framework'));
|
||||
framework.createSync();
|
||||
os.unzip(frameworkZip, framework);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,6 +636,72 @@ class FlutterSdk extends EngineCachedArtifact {
|
||||
List<String> getLicenseDirs() => const <String>[];
|
||||
}
|
||||
|
||||
class MacOSEngineArtifacts extends EngineCachedArtifact {
|
||||
MacOSEngineArtifacts(Cache cache) : super(
|
||||
'macos-sdk',
|
||||
cache,
|
||||
const <DevelopmentArtifact> { DevelopmentArtifact.macOS },
|
||||
);
|
||||
|
||||
@override
|
||||
List<String> getPackageDirs() => const <String>[];
|
||||
|
||||
@override
|
||||
List<List<String>> getBinaryDirs() {
|
||||
if (platform.isMacOS) {
|
||||
return _macOSDesktopBinaryDirs;
|
||||
}
|
||||
return const <List<String>>[];
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> getLicenseDirs() => const <String>[];
|
||||
}
|
||||
|
||||
class WindowsEngineArtifacts extends EngineCachedArtifact {
|
||||
WindowsEngineArtifacts(Cache cache) : super(
|
||||
'windows-sdk',
|
||||
cache,
|
||||
const <DevelopmentArtifact> { DevelopmentArtifact.windows },
|
||||
);
|
||||
|
||||
@override
|
||||
List<String> getPackageDirs() => const <String>[];
|
||||
|
||||
@override
|
||||
List<List<String>> getBinaryDirs() {
|
||||
if (platform.isWindows) {
|
||||
return _windowsDesktopBinaryDirs;
|
||||
}
|
||||
return const <List<String>>[];
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> getLicenseDirs() => const <String>[];
|
||||
}
|
||||
|
||||
class LinuxEngineArtifacts extends EngineCachedArtifact {
|
||||
LinuxEngineArtifacts(Cache cache) : super(
|
||||
'linux-sdk',
|
||||
cache,
|
||||
const <DevelopmentArtifact> { DevelopmentArtifact.linux },
|
||||
);
|
||||
|
||||
@override
|
||||
List<String> getPackageDirs() => const <String>[];
|
||||
|
||||
@override
|
||||
List<List<String>> getBinaryDirs() {
|
||||
if (platform.isLinux) {
|
||||
return _linuxDesktopBinaryDirs;
|
||||
}
|
||||
return const <List<String>>[];
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> getLicenseDirs() => const <String>[];
|
||||
}
|
||||
|
||||
class AndroidEngineArtifacts extends EngineCachedArtifact {
|
||||
AndroidEngineArtifacts(Cache cache) : super(
|
||||
'android-sdk',
|
||||
@@ -797,6 +869,20 @@ void _ensureExists(Directory directory) {
|
||||
}
|
||||
}
|
||||
|
||||
const List<List<String>> _windowsDesktopBinaryDirs = <List<String>>[
|
||||
<String>['windows-x64', 'windows-x64/windows-x64-flutter.zip'],
|
||||
<String>['windows-x64', 'windows-x64/flutter-cpp-client-wrapper.zip'],
|
||||
];
|
||||
|
||||
const List<List<String>> _linuxDesktopBinaryDirs = <List<String>>[
|
||||
<String>['linux-x64', 'linux-x64/linux-x64-flutter.zip'],
|
||||
<String>['linux-x64', 'linux-x64/flutter-cpp-client-wrapper.zip'],
|
||||
];
|
||||
|
||||
const List<List<String>> _macOSDesktopBinaryDirs = <List<String>>[
|
||||
<String>['darwin-x64', 'darwin-x64/FlutterMacOS.framework.zip'],
|
||||
];
|
||||
|
||||
const List<List<String>> _osxBinaryDirs = <List<String>>[
|
||||
<String>['android-arm-profile/darwin-x64', 'android-arm-profile/darwin-x64.zip'],
|
||||
<String>['android-arm-release/darwin-x64', 'android-arm-release/darwin-x64.zip'],
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'dart:async';
|
||||
import '../cache.dart';
|
||||
import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../version.dart';
|
||||
|
||||
class PrecacheCommand extends FlutterCommand {
|
||||
PrecacheCommand() {
|
||||
@@ -18,6 +19,12 @@ class PrecacheCommand extends FlutterCommand {
|
||||
help: 'Precache artifacts for iOS developemnt');
|
||||
argParser.addFlag('web', negatable: true, defaultsTo: false,
|
||||
help: 'Precache artifacts for web development');
|
||||
argParser.addFlag('linux', negatable: true, defaultsTo: false,
|
||||
help: 'Precache artifacts for linux desktop development');
|
||||
argParser.addFlag('windows', negatable: true, defaultsTo: false,
|
||||
help: 'Precache artifacts for windows desktop development');
|
||||
argParser.addFlag('macos', negatable: true, defaultsTo: false,
|
||||
help: 'Precache artifacts for macOS desktop development');
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -41,8 +48,19 @@ class PrecacheCommand extends FlutterCommand {
|
||||
if (argResults['ios']) {
|
||||
requiredArtifacts.add(DevelopmentArtifact.iOS);
|
||||
}
|
||||
if (argResults['web']) {
|
||||
requiredArtifacts.add(DevelopmentArtifact.web);
|
||||
if (!FlutterVersion.instance.isStable) {
|
||||
if (argResults['web']) {
|
||||
requiredArtifacts.add(DevelopmentArtifact.web);
|
||||
}
|
||||
if (argResults['linux']) {
|
||||
requiredArtifacts.add(DevelopmentArtifact.linux);
|
||||
}
|
||||
if (argResults['windows']) {
|
||||
requiredArtifacts.add(DevelopmentArtifact.windows);
|
||||
}
|
||||
if (argResults['macos']) {
|
||||
requiredArtifacts.add(DevelopmentArtifact.macOS);
|
||||
}
|
||||
}
|
||||
|
||||
if (cache.isUpToDate()) {
|
||||
|
||||
Reference in New Issue
Block a user