|
|
|
|
@@ -15,6 +15,30 @@ import 'base/os.dart';
|
|
|
|
|
import 'base/platform.dart';
|
|
|
|
|
import 'globals.dart';
|
|
|
|
|
|
|
|
|
|
/// A tag for a set of development artifacts that need to be cached.
|
|
|
|
|
enum DevelopmentArtifact {
|
|
|
|
|
/// Artifacts required for Android development.
|
|
|
|
|
android,
|
|
|
|
|
|
|
|
|
|
/// Artifacts required for iOS development.
|
|
|
|
|
iOS,
|
|
|
|
|
|
|
|
|
|
/// Artifacts required for web development,
|
|
|
|
|
web,
|
|
|
|
|
|
|
|
|
|
/// Artifacts required for desktop macOS.
|
|
|
|
|
macOS,
|
|
|
|
|
|
|
|
|
|
/// Artifacts required for desktop Windows.
|
|
|
|
|
windows,
|
|
|
|
|
|
|
|
|
|
/// Artifacts required for desktop linux.
|
|
|
|
|
linux,
|
|
|
|
|
|
|
|
|
|
/// Artifacts required by all developments.
|
|
|
|
|
universal,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A wrapper around the `bin/cache/` directory.
|
|
|
|
|
class Cache {
|
|
|
|
|
/// [rootOverride] is configurable for testing.
|
|
|
|
|
@@ -22,9 +46,11 @@ class Cache {
|
|
|
|
|
Cache({ Directory rootOverride, List<CachedArtifact> artifacts }) : _rootOverride = rootOverride {
|
|
|
|
|
if (artifacts == null) {
|
|
|
|
|
_artifacts.add(MaterialFonts(this));
|
|
|
|
|
_artifacts.add(FlutterEngine(this));
|
|
|
|
|
_artifacts.add(AndroidEngineArtifacts(this));
|
|
|
|
|
_artifacts.add(IOSEngineArtifacts(this));
|
|
|
|
|
_artifacts.add(GradleWrapper(this));
|
|
|
|
|
_artifacts.add(FlutterWebSdk(this));
|
|
|
|
|
_artifacts.add(FlutterSdk(this));
|
|
|
|
|
} else {
|
|
|
|
|
_artifacts.addAll(artifacts);
|
|
|
|
|
}
|
|
|
|
|
@@ -217,13 +243,16 @@ class Cache {
|
|
|
|
|
return cachedFile.path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> updateAll() async {
|
|
|
|
|
if (!_lockEnabled)
|
|
|
|
|
/// Update the cache to contain all `requiredArtifacts`.
|
|
|
|
|
Future<void> updateAll(Set<DevelopmentArtifact> requiredArtifacts) async {
|
|
|
|
|
if (!_lockEnabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
for (CachedArtifact artifact in _artifacts) {
|
|
|
|
|
if (!artifact.isUpToDate())
|
|
|
|
|
await artifact.update();
|
|
|
|
|
if (!artifact.isUpToDate()) {
|
|
|
|
|
await artifact.update(requiredArtifacts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} on SocketException catch (e) {
|
|
|
|
|
if (_hostsBlockedInChina.contains(e.address?.host)) {
|
|
|
|
|
@@ -237,15 +266,38 @@ class Cache {
|
|
|
|
|
rethrow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<bool> areRemoteArtifactsAvailable({
|
|
|
|
|
String engineVersion,
|
|
|
|
|
bool includeAllPlatforms = true,
|
|
|
|
|
}) async {
|
|
|
|
|
final bool includeAllPlatformsState = cache.includeAllPlatforms;
|
|
|
|
|
bool allAvailible = true;
|
|
|
|
|
cache.includeAllPlatforms = includeAllPlatforms;
|
|
|
|
|
for (CachedArtifact cachedArtifact in _artifacts) {
|
|
|
|
|
if (cachedArtifact is EngineCachedArtifact) {
|
|
|
|
|
allAvailible &= await cachedArtifact.checkForArtifacts(engineVersion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cache.includeAllPlatforms = includeAllPlatformsState;
|
|
|
|
|
return allAvailible;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// An artifact managed by the cache.
|
|
|
|
|
abstract class CachedArtifact {
|
|
|
|
|
CachedArtifact(this.name, this.cache);
|
|
|
|
|
CachedArtifact(this.name, this.cache, this.developmentArtifacts);
|
|
|
|
|
|
|
|
|
|
final String name;
|
|
|
|
|
final Cache cache;
|
|
|
|
|
|
|
|
|
|
// The name of the stamp file. Defaults to the same as the
|
|
|
|
|
// artifact name.
|
|
|
|
|
String get stampName => name;
|
|
|
|
|
|
|
|
|
|
/// All development artifacts this cache provides.
|
|
|
|
|
final Set<DevelopmentArtifact> developmentArtifacts;
|
|
|
|
|
|
|
|
|
|
Directory get location => cache.getArtifactDirectory(name);
|
|
|
|
|
String get version => cache.getVersionFor(name);
|
|
|
|
|
|
|
|
|
|
@@ -256,19 +308,27 @@ abstract class CachedArtifact {
|
|
|
|
|
final List<File> _downloadedFiles = <File>[];
|
|
|
|
|
|
|
|
|
|
bool isUpToDate() {
|
|
|
|
|
if (!location.existsSync())
|
|
|
|
|
if (!location.existsSync()) {
|
|
|
|
|
return false;
|
|
|
|
|
if (version != cache.getStampFor(name))
|
|
|
|
|
}
|
|
|
|
|
if (version != cache.getStampFor(stampName)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return isUpToDateInner();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> update() async {
|
|
|
|
|
if (location.existsSync())
|
|
|
|
|
location.deleteSync(recursive: true);
|
|
|
|
|
location.createSync(recursive: true);
|
|
|
|
|
Future<void> update(Set<DevelopmentArtifact> requiredArtifacts) async {
|
|
|
|
|
// If the set of required artifacts does not include any from this cache,
|
|
|
|
|
// then we can claim we are up to date to skip downloading.
|
|
|
|
|
if (!requiredArtifacts.any(developmentArtifacts.contains)) {
|
|
|
|
|
printTrace('Artifact $this is not required, skipping update.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!location.existsSync()) {
|
|
|
|
|
location.createSync(recursive: true);
|
|
|
|
|
}
|
|
|
|
|
await updateInner();
|
|
|
|
|
cache.setStampFor(name, version);
|
|
|
|
|
cache.setStampFor(stampName, version);
|
|
|
|
|
_removeDownloadedFiles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -355,7 +415,11 @@ void _maybeWarnAboutStorageOverride(String overrideUrl) {
|
|
|
|
|
|
|
|
|
|
/// A cached artifact containing fonts used for Material Design.
|
|
|
|
|
class MaterialFonts extends CachedArtifact {
|
|
|
|
|
MaterialFonts(Cache cache) : super('material_fonts', cache);
|
|
|
|
|
MaterialFonts(Cache cache) : super(
|
|
|
|
|
'material_fonts',
|
|
|
|
|
cache,
|
|
|
|
|
const <DevelopmentArtifact>{ DevelopmentArtifact.universal },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<void> updateInner() {
|
|
|
|
|
@@ -369,7 +433,11 @@ class MaterialFonts extends CachedArtifact {
|
|
|
|
|
///
|
|
|
|
|
/// This SDK references code within the regular Dart sdk to reduce download size.
|
|
|
|
|
class FlutterWebSdk extends CachedArtifact {
|
|
|
|
|
FlutterWebSdk(Cache cache) : super('flutter_web_sdk', cache);
|
|
|
|
|
FlutterWebSdk(Cache cache) : super(
|
|
|
|
|
'flutter_web_sdk',
|
|
|
|
|
cache,
|
|
|
|
|
const <DevelopmentArtifact>{ DevelopmentArtifact.web },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Directory get location => cache.getWebSdkDirectory();
|
|
|
|
|
@@ -405,133 +473,47 @@ class FlutterWebSdk extends CachedArtifact {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A cached artifact containing the Flutter engine binaries.
|
|
|
|
|
class FlutterEngine extends CachedArtifact {
|
|
|
|
|
FlutterEngine(Cache cache) : super('engine', cache);
|
|
|
|
|
abstract class EngineCachedArtifact extends CachedArtifact {
|
|
|
|
|
EngineCachedArtifact(
|
|
|
|
|
this.stampName,
|
|
|
|
|
Cache cache,
|
|
|
|
|
Set<DevelopmentArtifact> requiredArtifacts,
|
|
|
|
|
) : super('engine', cache, requiredArtifacts);
|
|
|
|
|
|
|
|
|
|
List<String> _getPackageDirs() => const <String>['sky_engine'];
|
|
|
|
|
@override
|
|
|
|
|
final String stampName;
|
|
|
|
|
|
|
|
|
|
// Return a list of (cache directory path, download URL path) tuples.
|
|
|
|
|
List<List<String>> _getBinaryDirs() {
|
|
|
|
|
final List<List<String>> binaryDirs = <List<String>>[];
|
|
|
|
|
/// Return a list of (directory path, download URL path) tuples.
|
|
|
|
|
List<List<String>> getBinaryDirs();
|
|
|
|
|
|
|
|
|
|
binaryDirs.add(<String>['common', 'flutter_patched_sdk.zip']);
|
|
|
|
|
/// A list of cache directory paths to which the LICENSE file should be copied.
|
|
|
|
|
List<String> getLicenseDirs();
|
|
|
|
|
|
|
|
|
|
if (cache.includeAllPlatforms)
|
|
|
|
|
binaryDirs
|
|
|
|
|
..addAll(_osxBinaryDirs)
|
|
|
|
|
..addAll(_linuxBinaryDirs)
|
|
|
|
|
..addAll(_windowsBinaryDirs)
|
|
|
|
|
..addAll(_androidBinaryDirs)
|
|
|
|
|
..addAll(_iosBinaryDirs)
|
|
|
|
|
..addAll(_dartSdks);
|
|
|
|
|
else if (platform.isLinux)
|
|
|
|
|
binaryDirs
|
|
|
|
|
..addAll(_linuxBinaryDirs)
|
|
|
|
|
..addAll(_androidBinaryDirs);
|
|
|
|
|
else if (platform.isMacOS)
|
|
|
|
|
binaryDirs
|
|
|
|
|
..addAll(_osxBinaryDirs)
|
|
|
|
|
..addAll(_androidBinaryDirs)
|
|
|
|
|
..addAll(_iosBinaryDirs);
|
|
|
|
|
else if (platform.isWindows)
|
|
|
|
|
binaryDirs
|
|
|
|
|
..addAll(_windowsBinaryDirs)
|
|
|
|
|
..addAll(_androidBinaryDirs);
|
|
|
|
|
|
|
|
|
|
return binaryDirs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<List<String>> get _osxBinaryDirs => <List<String>>[
|
|
|
|
|
<String>['darwin-x64', 'darwin-x64/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-profile/darwin-x64', 'android-arm-profile/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm-release/darwin-x64', 'android-arm-release/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm64-profile/darwin-x64', 'android-arm64-profile/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm64-release/darwin-x64', 'android-arm64-release/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-profile/darwin-x64', 'android-arm-dynamic-profile/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-release/darwin-x64', 'android-arm-dynamic-release/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-profile/darwin-x64', 'android-arm64-dynamic-profile/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-release/darwin-x64', 'android-arm64-dynamic-release/darwin-x64.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
List<List<String>> get _linuxBinaryDirs => <List<String>>[
|
|
|
|
|
<String>['linux-x64', 'linux-x64/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-profile/linux-x64', 'android-arm-profile/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm-release/linux-x64', 'android-arm-release/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm64-profile/linux-x64', 'android-arm64-profile/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm64-release/linux-x64', 'android-arm64-release/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-profile/linux-x64', 'android-arm-dynamic-profile/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-release/linux-x64', 'android-arm-dynamic-release/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-profile/linux-x64', 'android-arm64-dynamic-profile/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-release/linux-x64', 'android-arm64-dynamic-release/linux-x64.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
List<List<String>> get _windowsBinaryDirs => <List<String>>[
|
|
|
|
|
<String>['windows-x64', 'windows-x64/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-profile/windows-x64', 'android-arm-profile/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm-release/windows-x64', 'android-arm-release/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm64-profile/windows-x64', 'android-arm64-profile/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm64-release/windows-x64', 'android-arm64-release/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-profile/windows-x64', 'android-arm-dynamic-profile/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-release/windows-x64', 'android-arm-dynamic-release/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-profile/windows-x64', 'android-arm64-dynamic-profile/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-release/windows-x64', 'android-arm64-dynamic-release/windows-x64.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
List<List<String>> get _androidBinaryDirs => <List<String>>[
|
|
|
|
|
<String>['android-x86', 'android-x86/artifacts.zip'],
|
|
|
|
|
<String>['android-x64', 'android-x64/artifacts.zip'],
|
|
|
|
|
<String>['android-arm', 'android-arm/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-profile', 'android-arm-profile/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-release', 'android-arm-release/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64', 'android-arm64/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64-profile', 'android-arm64-profile/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64-release', 'android-arm64-release/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-profile', 'android-arm-dynamic-profile/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-release', 'android-arm-dynamic-release/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-profile', 'android-arm64-dynamic-profile/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-release', 'android-arm64-dynamic-release/artifacts.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
List<List<String>> get _iosBinaryDirs => <List<String>>[
|
|
|
|
|
<String>['ios', 'ios/artifacts.zip'],
|
|
|
|
|
<String>['ios-profile', 'ios-profile/artifacts.zip'],
|
|
|
|
|
<String>['ios-release', 'ios-release/artifacts.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
List<List<String>> get _dartSdks => <List<String>> [
|
|
|
|
|
<String>['darwin-x64', 'dart-sdk-darwin-x64.zip'],
|
|
|
|
|
<String>['linux-x64', 'dart-sdk-linux-x64.zip'],
|
|
|
|
|
<String>['windows-x64', 'dart-sdk-windows-x64.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// A list of cache directory paths to which the LICENSE file should be copied.
|
|
|
|
|
List<String> _getLicenseDirs() {
|
|
|
|
|
if (cache.includeAllPlatforms || platform.isMacOS) {
|
|
|
|
|
return const <String>['ios', 'ios-profile', 'ios-release'];
|
|
|
|
|
}
|
|
|
|
|
return const <String>[];
|
|
|
|
|
}
|
|
|
|
|
/// A list of the dart package directories to download.
|
|
|
|
|
List<String> getPackageDirs();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool isUpToDateInner() {
|
|
|
|
|
final Directory pkgDir = cache.getCacheDir('pkg');
|
|
|
|
|
for (String pkgName in _getPackageDirs()) {
|
|
|
|
|
for (String pkgName in getPackageDirs()) {
|
|
|
|
|
final String pkgPath = fs.path.join(pkgDir.path, pkgName);
|
|
|
|
|
if (!fs.directory(pkgPath).existsSync())
|
|
|
|
|
if (!fs.directory(pkgPath).existsSync()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (List<String> toolsDir in _getBinaryDirs()) {
|
|
|
|
|
for (List<String> toolsDir in getBinaryDirs()) {
|
|
|
|
|
final Directory dir = fs.directory(fs.path.join(location.path, toolsDir[0]));
|
|
|
|
|
if (!dir.existsSync())
|
|
|
|
|
if (!dir.existsSync()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (String licenseDir in _getLicenseDirs()) {
|
|
|
|
|
for (String licenseDir in getLicenseDirs()) {
|
|
|
|
|
final File file = fs.file(fs.path.join(location.path, licenseDir, 'LICENSE'));
|
|
|
|
|
if (!file.existsSync())
|
|
|
|
|
if (!file.existsSync()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@@ -541,15 +523,11 @@ class FlutterEngine extends CachedArtifact {
|
|
|
|
|
final String url = '$_storageBaseUrl/flutter_infra/flutter/$version/';
|
|
|
|
|
|
|
|
|
|
final Directory pkgDir = cache.getCacheDir('pkg');
|
|
|
|
|
for (String pkgName in _getPackageDirs()) {
|
|
|
|
|
final String pkgPath = fs.path.join(pkgDir.path, pkgName);
|
|
|
|
|
final Directory dir = fs.directory(pkgPath);
|
|
|
|
|
if (dir.existsSync())
|
|
|
|
|
dir.deleteSync(recursive: true);
|
|
|
|
|
for (String pkgName in getPackageDirs()) {
|
|
|
|
|
await _downloadZipArchive('Downloading package $pkgName...', Uri.parse(url + pkgName + '.zip'), pkgDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (List<String> toolsDir in _getBinaryDirs()) {
|
|
|
|
|
for (List<String> toolsDir in getBinaryDirs()) {
|
|
|
|
|
final String cacheDir = toolsDir[0];
|
|
|
|
|
final String urlPath = toolsDir[1];
|
|
|
|
|
final Directory dir = fs.directory(fs.path.join(location.path, cacheDir));
|
|
|
|
|
@@ -566,48 +544,35 @@ class FlutterEngine extends CachedArtifact {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final File licenseSource = fs.file(fs.path.join(Cache.flutterRoot, 'LICENSE'));
|
|
|
|
|
for (String licenseDir in _getLicenseDirs()) {
|
|
|
|
|
for (String licenseDir in getLicenseDirs()) {
|
|
|
|
|
final String licenseDestinationPath = fs.path.join(location.path, licenseDir, 'LICENSE');
|
|
|
|
|
await licenseSource.copy(licenseDestinationPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<bool> areRemoteArtifactsAvailable({
|
|
|
|
|
String engineVersion,
|
|
|
|
|
bool includeAllPlatforms = true,
|
|
|
|
|
}) async {
|
|
|
|
|
final bool includeAllPlatformsState = cache.includeAllPlatforms;
|
|
|
|
|
cache.includeAllPlatforms = includeAllPlatforms;
|
|
|
|
|
Future<bool> checkForArtifacts(String engineVersion) async {
|
|
|
|
|
engineVersion ??= version;
|
|
|
|
|
final String url = '$_storageBaseUrl/flutter_infra/flutter/$engineVersion/';
|
|
|
|
|
|
|
|
|
|
Future<bool> checkForArtifacts(String engineVersion) async {
|
|
|
|
|
engineVersion ??= version;
|
|
|
|
|
final String url = '$_storageBaseUrl/flutter_infra/flutter/$engineVersion/';
|
|
|
|
|
|
|
|
|
|
bool exists = false;
|
|
|
|
|
for (String pkgName in _getPackageDirs()) {
|
|
|
|
|
exists = await _doesRemoteExist('Checking package $pkgName is available...',
|
|
|
|
|
Uri.parse(url + pkgName + '.zip'));
|
|
|
|
|
if (!exists) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool exists = false;
|
|
|
|
|
for (String pkgName in getPackageDirs()) {
|
|
|
|
|
exists = await _doesRemoteExist('Checking package $pkgName is available...',
|
|
|
|
|
Uri.parse(url + pkgName + '.zip'));
|
|
|
|
|
if (!exists) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (List<String> toolsDir in _getBinaryDirs()) {
|
|
|
|
|
final String cacheDir = toolsDir[0];
|
|
|
|
|
final String urlPath = toolsDir[1];
|
|
|
|
|
exists = await _doesRemoteExist('Checking $cacheDir tools are available...',
|
|
|
|
|
Uri.parse(url + urlPath));
|
|
|
|
|
if (!exists) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final bool result = await checkForArtifacts(engineVersion);
|
|
|
|
|
cache.includeAllPlatforms = includeAllPlatformsState;
|
|
|
|
|
return result;
|
|
|
|
|
for (List<String> toolsDir in getBinaryDirs()) {
|
|
|
|
|
final String cacheDir = toolsDir[0];
|
|
|
|
|
final String urlPath = toolsDir[1];
|
|
|
|
|
exists = await _doesRemoteExist('Checking $cacheDir tools are available...',
|
|
|
|
|
Uri.parse(url + urlPath));
|
|
|
|
|
if (!exists) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -622,9 +587,126 @@ class FlutterEngine extends CachedArtifact {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// A cached artifact containing the dart:ui source code.
|
|
|
|
|
class FlutterSdk extends EngineCachedArtifact {
|
|
|
|
|
FlutterSdk(Cache cache) : super(
|
|
|
|
|
'flutter_sdk',
|
|
|
|
|
cache,
|
|
|
|
|
const <DevelopmentArtifact>{ DevelopmentArtifact.universal },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<String> getPackageDirs() => const <String>['sky_engine'];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<List<String>> getBinaryDirs() {
|
|
|
|
|
final List<List<String>> binaryDirs = <List<String>>[
|
|
|
|
|
<String>['common', 'flutter_patched_sdk.zip'],
|
|
|
|
|
];
|
|
|
|
|
if (cache.includeAllPlatforms) {
|
|
|
|
|
binaryDirs.addAll(<List<String>>[
|
|
|
|
|
<String>['windows-x64', 'windows-x64/artifacts.zip'],
|
|
|
|
|
<String>['linux-x64', 'linux-x64/artifacts.zip'],
|
|
|
|
|
<String>['darwin-x64', 'darwin-x64/artifacts.zip'],
|
|
|
|
|
]);
|
|
|
|
|
} else if (platform.isWindows) {
|
|
|
|
|
binaryDirs.addAll(<List<String>>[
|
|
|
|
|
<String>['windows-x64', 'windows-x64/artifacts.zip'],
|
|
|
|
|
]);
|
|
|
|
|
} else if (platform.isMacOS) {
|
|
|
|
|
binaryDirs.addAll(<List<String>>[
|
|
|
|
|
<String>['darwin-x64', 'darwin-x64/artifacts.zip'],
|
|
|
|
|
]);
|
|
|
|
|
} else if (platform.isLinux) {
|
|
|
|
|
binaryDirs.addAll(<List<String>>[
|
|
|
|
|
<String>['linux-x64', 'linux-x64/artifacts.zip'],
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
return binaryDirs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<String> getLicenseDirs() => const <String>[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AndroidEngineArtifacts extends EngineCachedArtifact {
|
|
|
|
|
AndroidEngineArtifacts(Cache cache) : super(
|
|
|
|
|
'android-sdk',
|
|
|
|
|
cache,
|
|
|
|
|
const <DevelopmentArtifact>{ DevelopmentArtifact.android },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<String> getPackageDirs() => const <String>[];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<List<String>> getBinaryDirs() {
|
|
|
|
|
final List<List<String>> binaryDirs = <List<String>>[];
|
|
|
|
|
if (cache.includeAllPlatforms) {
|
|
|
|
|
binaryDirs
|
|
|
|
|
..addAll(_osxBinaryDirs)
|
|
|
|
|
..addAll(_linuxBinaryDirs)
|
|
|
|
|
..addAll(_windowsBinaryDirs)
|
|
|
|
|
..addAll(_androidBinaryDirs)
|
|
|
|
|
..addAll(_dartSdks);
|
|
|
|
|
} else if (platform.isWindows) {
|
|
|
|
|
binaryDirs
|
|
|
|
|
..addAll(_windowsBinaryDirs)
|
|
|
|
|
..addAll(_androidBinaryDirs);
|
|
|
|
|
} else if (platform.isMacOS) {
|
|
|
|
|
binaryDirs
|
|
|
|
|
..addAll(_osxBinaryDirs)
|
|
|
|
|
..addAll(_androidBinaryDirs);
|
|
|
|
|
} else if (platform.isLinux) {
|
|
|
|
|
binaryDirs
|
|
|
|
|
..addAll(_linuxBinaryDirs)
|
|
|
|
|
..addAll(_androidBinaryDirs);
|
|
|
|
|
}
|
|
|
|
|
return binaryDirs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<String> getLicenseDirs() { return <String>[]; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class IOSEngineArtifacts extends EngineCachedArtifact {
|
|
|
|
|
IOSEngineArtifacts(Cache cache) : super(
|
|
|
|
|
'ios-sdk',
|
|
|
|
|
cache,
|
|
|
|
|
<DevelopmentArtifact>{ DevelopmentArtifact.iOS },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<List<String>> getBinaryDirs() {
|
|
|
|
|
final List<List<String>> binaryDirs = <List<String>>[];
|
|
|
|
|
if (platform.isMacOS || cache.includeAllPlatforms) {
|
|
|
|
|
binaryDirs.addAll(_iosBinaryDirs);
|
|
|
|
|
}
|
|
|
|
|
return binaryDirs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<String> getLicenseDirs() {
|
|
|
|
|
if (cache.includeAllPlatforms || platform.isMacOS) {
|
|
|
|
|
return const <String>['ios', 'ios-profile', 'ios-release'];
|
|
|
|
|
}
|
|
|
|
|
return const <String>[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<String> getPackageDirs() {
|
|
|
|
|
return <String>[];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A cached artifact containing Gradle Wrapper scripts and binaries.
|
|
|
|
|
class GradleWrapper extends CachedArtifact {
|
|
|
|
|
GradleWrapper(Cache cache) : super('gradle_wrapper', cache);
|
|
|
|
|
GradleWrapper(Cache cache) : super(
|
|
|
|
|
'gradle_wrapper',
|
|
|
|
|
cache,
|
|
|
|
|
const <DevelopmentArtifact>{ DevelopmentArtifact.android },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
List<String> get _gradleScripts => <String>['gradlew', 'gradlew.bat'];
|
|
|
|
|
|
|
|
|
|
@@ -644,8 +726,9 @@ class GradleWrapper extends CachedArtifact {
|
|
|
|
|
@override
|
|
|
|
|
bool isUpToDateInner() {
|
|
|
|
|
final Directory wrapperDir = cache.getCacheDir(fs.path.join('artifacts', 'gradle_wrapper'));
|
|
|
|
|
if (!fs.directory(wrapperDir).existsSync())
|
|
|
|
|
if (!fs.directory(wrapperDir).existsSync()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for (String scriptName in _gradleScripts) {
|
|
|
|
|
final File scriptFile = fs.file(fs.path.join(wrapperDir.path, scriptName));
|
|
|
|
|
if (!scriptFile.existsSync())
|
|
|
|
|
@@ -706,6 +789,67 @@ Future<bool> _doesRemoteExist(String message, Uri url) async {
|
|
|
|
|
|
|
|
|
|
/// Create the given [directory] and parents, as necessary.
|
|
|
|
|
void _ensureExists(Directory directory) {
|
|
|
|
|
if (!directory.existsSync())
|
|
|
|
|
if (!directory.existsSync()) {
|
|
|
|
|
directory.createSync(recursive: true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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'],
|
|
|
|
|
<String>['android-arm64-profile/darwin-x64', 'android-arm64-profile/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm64-release/darwin-x64', 'android-arm64-release/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-profile/darwin-x64', 'android-arm-dynamic-profile/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-release/darwin-x64', 'android-arm-dynamic-release/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-profile/darwin-x64', 'android-arm64-dynamic-profile/darwin-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-release/darwin-x64', 'android-arm64-dynamic-release/darwin-x64.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const List<List<String>> _linuxBinaryDirs = <List<String>>[
|
|
|
|
|
<String>['android-arm-profile/linux-x64', 'android-arm-profile/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm-release/linux-x64', 'android-arm-release/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm64-profile/linux-x64', 'android-arm64-profile/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm64-release/linux-x64', 'android-arm64-release/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-profile/linux-x64', 'android-arm-dynamic-profile/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-release/linux-x64', 'android-arm-dynamic-release/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-profile/linux-x64', 'android-arm64-dynamic-profile/linux-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-release/linux-x64', 'android-arm64-dynamic-release/linux-x64.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const List<List<String>> _windowsBinaryDirs = <List<String>>[
|
|
|
|
|
<String>['android-arm-profile/windows-x64', 'android-arm-profile/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm-release/windows-x64', 'android-arm-release/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm64-profile/windows-x64', 'android-arm64-profile/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm64-release/windows-x64', 'android-arm64-release/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-profile/windows-x64', 'android-arm-dynamic-profile/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-release/windows-x64', 'android-arm-dynamic-release/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-profile/windows-x64', 'android-arm64-dynamic-profile/windows-x64.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-release/windows-x64', 'android-arm64-dynamic-release/windows-x64.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const List<List<String>> _androidBinaryDirs = <List<String>>[
|
|
|
|
|
<String>['android-x86', 'android-x86/artifacts.zip'],
|
|
|
|
|
<String>['android-x64', 'android-x64/artifacts.zip'],
|
|
|
|
|
<String>['android-arm', 'android-arm/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-profile', 'android-arm-profile/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-release', 'android-arm-release/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64', 'android-arm64/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64-profile', 'android-arm64-profile/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64-release', 'android-arm64-release/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-profile', 'android-arm-dynamic-profile/artifacts.zip'],
|
|
|
|
|
<String>['android-arm-dynamic-release', 'android-arm-dynamic-release/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-profile', 'android-arm64-dynamic-profile/artifacts.zip'],
|
|
|
|
|
<String>['android-arm64-dynamic-release', 'android-arm64-dynamic-release/artifacts.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const List<List<String>> _iosBinaryDirs = <List<String>>[
|
|
|
|
|
<String>['ios', 'ios/artifacts.zip'],
|
|
|
|
|
<String>['ios-profile', 'ios-profile/artifacts.zip'],
|
|
|
|
|
<String>['ios-release', 'ios-release/artifacts.zip'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const List<List<String>> _dartSdks = <List<String>> [
|
|
|
|
|
<String>['darwin-x64', 'dart-sdk-darwin-x64.zip'],
|
|
|
|
|
<String>['linux-x64', 'dart-sdk-linux-x64.zip'],
|
|
|
|
|
<String>['windows-x64', 'dart-sdk-windows-x64.zip'],
|
|
|
|
|
];
|
|
|
|
|
|