Download secondary SDK (#29633)

This commit is contained in:
Jonah Williams 2019-03-20 15:41:45 -07:00 committed by GitHub
parent c72f18fcd5
commit 5f727126ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,7 @@ class Cache {
_artifacts.add(MaterialFonts(this));
_artifacts.add(FlutterEngine(this));
_artifacts.add(GradleWrapper(this));
_artifacts.add(FlutterWebSdk(this));
} else {
_artifacts.addAll(artifacts);
}
@ -162,6 +163,12 @@ class Cache {
return getCacheArtifacts().childDirectory(name);
}
/// The web sdk has to be co-located with the dart-sdk so that they can share source
/// code.
Directory getWebSdkDirectory() {
return getRoot().childDirectory('flutter_web_sdk');
}
String getVersionFor(String artifactName) {
final File versionFile = fs.file(fs.path.join(_rootOverride?.path ?? flutterRoot, 'bin', 'internal', '$artifactName.version'));
return versionFile.existsSync() ? versionFile.readAsStringSync().trim() : null;
@ -357,6 +364,34 @@ class MaterialFonts extends CachedArtifact {
}
}
/// A cached artifact containing the web dart:ui sources, platform dill files,
/// and libraries.json.
///
/// 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);
@override
Directory get location => cache.getWebSdkDirectory();
@override
String get version => cache.getVersionFor('engine');
@override
Future<void> updateInner() {
String platformName = 'flutter-web-sdk-';
if (platform.isMacOS) {
platformName += 'darwin-x64';
} else if (platform.isLinux) {
platformName += 'linux-x64';
} else if (platform.isWindows) {
platformName += 'windows-x64';
}
final Uri url = Uri.parse('$_storageBaseUrl/flutter_infra/flutter/$version/$platformName.zip');
return _downloadZipArchive('Downloading Web SDK...', url, location);
}
}
/// A cached artifact containing the Flutter engine binaries.
class FlutterEngine extends CachedArtifact {
FlutterEngine(Cache cache) : super('engine', cache);