@@ -85,6 +85,7 @@ class AOTSnapshotter {
|
||||
if (fs.file('pubspec.yaml').existsSync()) {
|
||||
flutterProject = await FlutterProject.current();
|
||||
}
|
||||
final FlutterEngine engine = FlutterEngine(cache);
|
||||
if (!_isValidAotPlatform(platform, buildMode)) {
|
||||
printError('${getNameForTargetPlatform(platform)} does not support AOT compilation.');
|
||||
return 1;
|
||||
@@ -186,7 +187,7 @@ class AOTSnapshotter {
|
||||
'entryPoint': mainPath,
|
||||
'sharedLib': buildSharedLibrary.toString(),
|
||||
'extraGenSnapshotOptions': extraGenSnapshotOptions.join(' '),
|
||||
'engineHash': Cache.instance.engineRevision,
|
||||
'engineHash': engine.version,
|
||||
'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}',
|
||||
},
|
||||
depfilePaths: <String>[],
|
||||
|
||||
@@ -15,30 +15,6 @@ 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.
|
||||
@@ -46,11 +22,9 @@ class Cache {
|
||||
Cache({ Directory rootOverride, List<CachedArtifact> artifacts }) : _rootOverride = rootOverride {
|
||||
if (artifacts == null) {
|
||||
_artifacts.add(MaterialFonts(this));
|
||||
_artifacts.add(AndroidEngineArtifacts(this));
|
||||
_artifacts.add(IOSEngineArtifacts(this));
|
||||
_artifacts.add(FlutterEngine(this));
|
||||
_artifacts.add(GradleWrapper(this));
|
||||
_artifacts.add(FlutterWebSdk(this));
|
||||
_artifacts.add(FlutterSdk(this));
|
||||
} else {
|
||||
_artifacts.addAll(artifacts);
|
||||
}
|
||||
@@ -220,7 +194,7 @@ class Cache {
|
||||
return isOlderThanReference(entity: entity, referenceFile: flutterToolsStamp);
|
||||
}
|
||||
|
||||
bool isUpToDate(Set<DevelopmentArtifact> requiredArtifacts) => _artifacts.every((CachedArtifact artifact) => artifact.isUpToDate(requiredArtifacts));
|
||||
bool isUpToDate() => _artifacts.every((CachedArtifact artifact) => artifact.isUpToDate());
|
||||
|
||||
Future<String> getThirdPartyFile(String urlStr, String serviceName) async {
|
||||
final Uri url = Uri.parse(urlStr);
|
||||
@@ -243,16 +217,13 @@ class Cache {
|
||||
return cachedFile.path;
|
||||
}
|
||||
|
||||
/// Update the cache to contain all `requiredArtifacts`.
|
||||
Future<void> updateAll(Set<DevelopmentArtifact> requiredArtifacts) async {
|
||||
if (!_lockEnabled) {
|
||||
Future<void> updateAll() async {
|
||||
if (!_lockEnabled)
|
||||
return;
|
||||
}
|
||||
try {
|
||||
for (CachedArtifact artifact in _artifacts) {
|
||||
if (!artifact.isUpToDate(requiredArtifacts)) {
|
||||
if (!artifact.isUpToDate())
|
||||
await artifact.update();
|
||||
}
|
||||
}
|
||||
} on SocketException catch (e) {
|
||||
if (_hostsBlockedInChina.contains(e.address?.host)) {
|
||||
@@ -266,34 +237,15 @@ 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, this.developmentArtifacts);
|
||||
CachedArtifact(this.name, this.cache);
|
||||
|
||||
final String name;
|
||||
final Cache cache;
|
||||
|
||||
/// All development artifacts this cache provides.
|
||||
final Set<DevelopmentArtifact> developmentArtifacts;
|
||||
|
||||
Directory get location => cache.getArtifactDirectory(name);
|
||||
String get version => cache.getVersionFor(name);
|
||||
|
||||
@@ -303,25 +255,18 @@ abstract class CachedArtifact {
|
||||
/// starting from scratch.
|
||||
final List<File> _downloadedFiles = <File>[];
|
||||
|
||||
bool isUpToDate(Set<DevelopmentArtifact> requiredArtifacts) {
|
||||
// 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)) {
|
||||
return true;
|
||||
}
|
||||
if (!location.existsSync()) {
|
||||
bool isUpToDate() {
|
||||
if (!location.existsSync())
|
||||
return false;
|
||||
}
|
||||
if (version != cache.getStampFor(name)) {
|
||||
if (version != cache.getStampFor(name))
|
||||
return false;
|
||||
}
|
||||
return isUpToDateInner();
|
||||
}
|
||||
|
||||
Future<void> update() async {
|
||||
if (!location.existsSync()) {
|
||||
location.createSync(recursive: true);
|
||||
}
|
||||
if (location.existsSync())
|
||||
location.deleteSync(recursive: true);
|
||||
location.createSync(recursive: true);
|
||||
await updateInner();
|
||||
cache.setStampFor(name, version);
|
||||
_removeDownloadedFiles();
|
||||
@@ -410,11 +355,7 @@ void _maybeWarnAboutStorageOverride(String overrideUrl) {
|
||||
|
||||
/// A cached artifact containing fonts used for Material Design.
|
||||
class MaterialFonts extends CachedArtifact {
|
||||
MaterialFonts(Cache cache) : super(
|
||||
'material_fonts',
|
||||
cache,
|
||||
const <DevelopmentArtifact>{ DevelopmentArtifact.universal },
|
||||
);
|
||||
MaterialFonts(Cache cache) : super('material_fonts', cache);
|
||||
|
||||
@override
|
||||
Future<void> updateInner() {
|
||||
@@ -428,11 +369,7 @@ 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,
|
||||
const <DevelopmentArtifact>{ DevelopmentArtifact.web },
|
||||
);
|
||||
FlutterWebSdk(Cache cache) : super('flutter_web_sdk', cache);
|
||||
|
||||
@override
|
||||
Directory get location => cache.getWebSdkDirectory();
|
||||
@@ -468,37 +405,130 @@ class FlutterWebSdk extends CachedArtifact {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class EngineCachedArtifact extends CachedArtifact {
|
||||
EngineCachedArtifact(
|
||||
Cache cache,
|
||||
Set<DevelopmentArtifact> requiredArtifacts,
|
||||
) : super('engine', cache, requiredArtifacts);
|
||||
/// A cached artifact containing the Flutter engine binaries.
|
||||
class FlutterEngine extends CachedArtifact {
|
||||
FlutterEngine(Cache cache) : super('engine', cache);
|
||||
|
||||
/// Return a list of (directory path, download URL path) tuples.
|
||||
List<List<String>> getBinaryDirs();
|
||||
List<String> _getPackageDirs() => const <String>['sky_engine'];
|
||||
|
||||
/// A list of cache directory paths to which the LICENSE file should be copied.
|
||||
List<String> getLicenseDirs();
|
||||
// Return a list of (cache directory path, download URL path) tuples.
|
||||
List<List<String>> _getBinaryDirs() {
|
||||
final List<List<String>> binaryDirs = <List<String>>[];
|
||||
|
||||
/// A list of the dart package directories to download.
|
||||
List<String> getPackageDirs();
|
||||
binaryDirs.add(<String>['common', 'flutter_patched_sdk.zip']);
|
||||
|
||||
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>[];
|
||||
}
|
||||
|
||||
@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())
|
||||
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())
|
||||
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())
|
||||
return false;
|
||||
@@ -511,16 +541,15 @@ abstract class EngineCachedArtifact extends CachedArtifact {
|
||||
final String url = '$_storageBaseUrl/flutter_infra/flutter/$version/';
|
||||
|
||||
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);
|
||||
final Directory dir = fs.directory(pkgPath);
|
||||
if (dir.existsSync()) {
|
||||
if (dir.existsSync())
|
||||
dir.deleteSync(recursive: true);
|
||||
}
|
||||
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));
|
||||
@@ -537,35 +566,48 @@ abstract class EngineCachedArtifact 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> checkForArtifacts(String engineVersion) async {
|
||||
engineVersion ??= version;
|
||||
final String url = '$_storageBaseUrl/flutter_infra/flutter/$engineVersion/';
|
||||
Future<bool> areRemoteArtifactsAvailable({
|
||||
String engineVersion,
|
||||
bool includeAllPlatforms = true,
|
||||
}) async {
|
||||
final bool includeAllPlatformsState = cache.includeAllPlatforms;
|
||||
cache.includeAllPlatforms = includeAllPlatforms;
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -580,123 +622,9 @@ abstract class EngineCachedArtifact extends CachedArtifact {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// A cached artifact containing the dart:ui source code.
|
||||
class FlutterSdk extends EngineCachedArtifact {
|
||||
FlutterSdk(Cache cache) : super(
|
||||
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(
|
||||
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(
|
||||
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,
|
||||
const <DevelopmentArtifact>{ DevelopmentArtifact.android },
|
||||
);
|
||||
GradleWrapper(Cache cache) : super('gradle_wrapper', cache);
|
||||
|
||||
List<String> get _gradleScripts => <String>['gradlew', 'gradlew.bat'];
|
||||
|
||||
@@ -716,9 +644,8 @@ 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())
|
||||
@@ -779,67 +706,6 @@ 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'],
|
||||
];
|
||||
|
||||
@@ -64,11 +64,6 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
@override
|
||||
String get description => "Analyze the project's Dart code.";
|
||||
|
||||
@override
|
||||
Set<DevelopmentArtifact> get requiredArtifacts => const <DevelopmentArtifact>{
|
||||
DevelopmentArtifact.universal,
|
||||
};
|
||||
|
||||
@override
|
||||
bool get shouldRunPub {
|
||||
// If they're not analyzing the current project.
|
||||
|
||||
@@ -8,7 +8,7 @@ import '../base/common.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../build_info.dart';
|
||||
import '../globals.dart';
|
||||
import '../runner/flutter_command.dart' show DevelopmentArtifact, FlutterCommandResult;
|
||||
import '../runner/flutter_command.dart' show FlutterCommandResult;
|
||||
import '../web/compile.dart';
|
||||
import 'build.dart';
|
||||
|
||||
@@ -19,12 +19,6 @@ class BuildWebCommand extends BuildSubCommand {
|
||||
defaultBuildMode = BuildMode.release;
|
||||
}
|
||||
|
||||
@override
|
||||
Set<DevelopmentArtifact> get requiredArtifacts => const <DevelopmentArtifact>{
|
||||
DevelopmentArtifact.universal,
|
||||
DevelopmentArtifact.web,
|
||||
};
|
||||
|
||||
@override
|
||||
final String name = 'web';
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ class CreateCommand extends FlutterCommand {
|
||||
throwToolExit('Neither the --flutter-root command line flag nor the FLUTTER_ROOT environment '
|
||||
'variable was specified. Unable to find package:flutter.', exitCode: 2);
|
||||
|
||||
await Cache.instance.updateAll(<DevelopmentArtifact>{ DevelopmentArtifact.universal });
|
||||
await Cache.instance.updateAll();
|
||||
|
||||
final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ class IdeConfigCommand extends FlutterCommand {
|
||||
throwToolExit('Currently, the only supported IDE is IntelliJ\n$usage', exitCode: 2);
|
||||
}
|
||||
|
||||
await Cache.instance.updateAll(<DevelopmentArtifact>{ DevelopmentArtifact.universal });
|
||||
await Cache.instance.updateAll();
|
||||
|
||||
if (argResults['update-templates']) {
|
||||
_handleTemplateUpdate();
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import '../cache.dart';
|
||||
import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
@@ -12,12 +11,6 @@ class PrecacheCommand extends FlutterCommand {
|
||||
PrecacheCommand() {
|
||||
argParser.addFlag('all-platforms', abbr: 'a', negatable: false,
|
||||
help: 'Precache artifacts for all platforms.');
|
||||
argParser.addFlag('android', negatable: true, defaultsTo: true,
|
||||
help: 'Precache artifacts for Android development');
|
||||
argParser.addFlag('ios', negatable: true, defaultsTo: true,
|
||||
help: 'Precache artifacts for iOS developemnt');
|
||||
argParser.addFlag('web', negatable: true, defaultsTo: false,
|
||||
help: 'Precache artifacts for web development');
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -31,25 +24,14 @@ class PrecacheCommand extends FlutterCommand {
|
||||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
if (argResults['all-platforms']) {
|
||||
if (argResults['all-platforms'])
|
||||
cache.includeAllPlatforms = true;
|
||||
}
|
||||
final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{ DevelopmentArtifact.universal };
|
||||
if (argResults['android']) {
|
||||
requiredArtifacts.add(DevelopmentArtifact.android);
|
||||
}
|
||||
if (argResults['ios']) {
|
||||
requiredArtifacts.add(DevelopmentArtifact.iOS);
|
||||
}
|
||||
if (argResults['web']) {
|
||||
requiredArtifacts.add(DevelopmentArtifact.web);
|
||||
}
|
||||
|
||||
if (cache.isUpToDate(requiredArtifacts)) {
|
||||
if (cache.isUpToDate())
|
||||
printStatus('Already up-to-date.');
|
||||
} else {
|
||||
await cache.updateAll(requiredArtifacts);
|
||||
}
|
||||
else
|
||||
await cache.updateAll();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +232,7 @@ class KernelCompiler {
|
||||
if (fs.file('pubspec.yaml').existsSync()) {
|
||||
flutterProject = await FlutterProject.current();
|
||||
}
|
||||
final FlutterEngine engine = FlutterEngine(cache);
|
||||
|
||||
// TODO(cbracken): eliminate pathFilter.
|
||||
// Currently the compiler emits buildbot paths for the core libs in the
|
||||
@@ -245,7 +246,7 @@ class KernelCompiler {
|
||||
'entryPoint': mainPath,
|
||||
'trackWidgetCreation': trackWidgetCreation.toString(),
|
||||
'linkPlatformKernelIn': linkPlatformKernelIn.toString(),
|
||||
'engineHash': Cache.instance.engineRevision,
|
||||
'engineHash': engine.version,
|
||||
'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}',
|
||||
},
|
||||
depfilePaths: <String>[depFilePath],
|
||||
|
||||
@@ -170,7 +170,9 @@ class Doctor {
|
||||
}
|
||||
|
||||
Future<bool> checkRemoteArtifacts(String engineRevision) async {
|
||||
return Cache.instance.areRemoteArtifactsAvailable(engineVersion: engineRevision);
|
||||
final Cache cache = Cache();
|
||||
final FlutterEngine engine = FlutterEngine(cache);
|
||||
return await engine.areRemoteArtifactsAvailable(engineVersion: engineRevision);
|
||||
}
|
||||
|
||||
/// Print information about the state of installed tooling.
|
||||
|
||||
@@ -19,7 +19,6 @@ import '../base/user_messages.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../build_info.dart';
|
||||
import '../bundle.dart' as bundle;
|
||||
import '../cache.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../dart/pub.dart';
|
||||
import '../device.dart';
|
||||
@@ -29,8 +28,6 @@ import '../project.dart';
|
||||
import '../usage.dart';
|
||||
import 'flutter_command_runner.dart';
|
||||
|
||||
export '../cache.dart' show DevelopmentArtifact;
|
||||
|
||||
enum ExitStatus {
|
||||
success,
|
||||
warning,
|
||||
@@ -533,9 +530,8 @@ abstract class FlutterCommand extends Command<void> {
|
||||
|
||||
// Populate the cache. We call this before pub get below so that the sky_engine
|
||||
// package is available in the flutter cache for pub to find.
|
||||
if (shouldUpdateCache) {
|
||||
await cache.updateAll(requiredArtifacts);
|
||||
}
|
||||
if (shouldUpdateCache)
|
||||
await cache.updateAll();
|
||||
|
||||
if (shouldRunPub) {
|
||||
await pubGet(context: PubContext.getVerifyContext(name));
|
||||
@@ -553,16 +549,6 @@ abstract class FlutterCommand extends Command<void> {
|
||||
return await runCommand();
|
||||
}
|
||||
|
||||
/// The set of development artifacts required for this command.
|
||||
///
|
||||
/// Defaults to [DevelopmentArtifact.universal],
|
||||
/// [DevelopmentArtifact.android], and [DevelopmentArtifact.iOS].
|
||||
Set<DevelopmentArtifact> get requiredArtifacts => const <DevelopmentArtifact>{
|
||||
DevelopmentArtifact.universal,
|
||||
DevelopmentArtifact.iOS,
|
||||
DevelopmentArtifact.android,
|
||||
};
|
||||
|
||||
/// Subclasses must implement this to execute the command.
|
||||
/// Optionally provide a [FlutterCommandResult] to send more details about the
|
||||
/// execution for analytics.
|
||||
|
||||
@@ -84,34 +84,34 @@ void main() {
|
||||
test('should not be up to date, if some cached artifact is not', () {
|
||||
final CachedArtifact artifact1 = MockCachedArtifact();
|
||||
final CachedArtifact artifact2 = MockCachedArtifact();
|
||||
when(artifact1.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(true);
|
||||
when(artifact2.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(false);
|
||||
when(artifact1.isUpToDate()).thenReturn(true);
|
||||
when(artifact2.isUpToDate()).thenReturn(false);
|
||||
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
|
||||
expect(cache.isUpToDate(const <DevelopmentArtifact>{}), isFalse);
|
||||
expect(cache.isUpToDate(), isFalse);
|
||||
});
|
||||
test('should be up to date, if all cached artifacts are', () {
|
||||
final CachedArtifact artifact1 = MockCachedArtifact();
|
||||
final CachedArtifact artifact2 = MockCachedArtifact();
|
||||
when(artifact1.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(true);
|
||||
when(artifact2.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(true);
|
||||
when(artifact1.isUpToDate()).thenReturn(true);
|
||||
when(artifact2.isUpToDate()).thenReturn(true);
|
||||
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
|
||||
expect(cache.isUpToDate(const <DevelopmentArtifact>{}), isTrue);
|
||||
expect(cache.isUpToDate(), isTrue);
|
||||
});
|
||||
test('should update cached artifacts which are not up to date', () async {
|
||||
final CachedArtifact artifact1 = MockCachedArtifact();
|
||||
final CachedArtifact artifact2 = MockCachedArtifact();
|
||||
when(artifact1.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(true);
|
||||
when(artifact2.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(false);
|
||||
when(artifact1.isUpToDate()).thenReturn(true);
|
||||
when(artifact2.isUpToDate()).thenReturn(false);
|
||||
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
|
||||
await cache.updateAll(const <DevelopmentArtifact>{});
|
||||
await cache.updateAll();
|
||||
verifyNever(artifact1.update());
|
||||
verify(artifact2.update());
|
||||
});
|
||||
testUsingContext('failed storage.googleapis.com download shows China warning', () async {
|
||||
final CachedArtifact artifact1 = MockCachedArtifact();
|
||||
final CachedArtifact artifact2 = MockCachedArtifact();
|
||||
when(artifact1.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(false);
|
||||
when(artifact2.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(false);
|
||||
when(artifact1.isUpToDate()).thenReturn(false);
|
||||
when(artifact2.isUpToDate()).thenReturn(false);
|
||||
final MockInternetAddress address = MockInternetAddress();
|
||||
when(address.host).thenReturn('storage.googleapis.com');
|
||||
when(artifact1.update()).thenThrow(SocketException(
|
||||
@@ -120,7 +120,7 @@ void main() {
|
||||
));
|
||||
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
|
||||
try {
|
||||
await cache.updateAll(const <DevelopmentArtifact>{});
|
||||
await cache.updateAll();
|
||||
fail('Mock thrown exception expected');
|
||||
} catch (e) {
|
||||
verify(artifact1.update());
|
||||
|
||||
@@ -42,7 +42,7 @@ void main() {
|
||||
testUsingContext('honors shouldUpdateCache true', () async {
|
||||
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: true);
|
||||
await flutterCommand.run();
|
||||
verify(cache.updateAll(any)).called(1);
|
||||
verify(cache.updateAll()).called(1);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
Cache: () => cache,
|
||||
|
||||
Reference in New Issue
Block a user