Unverified Commit 3d276cc6 authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Pull the right Fuchsia SDK for the platform (#31998)

parent a40e5c90
-F-MfCBXXKddVWXabbdfQ1im71SzFu9dqYMTJs7TmqoC
Hc4DxFUkoHicT-ytOLaxzkT4QYS5uiMXXcZO6s9C1qcC
mfXzGfxNWcf6BHsv083b56vQcj96yCo0exBFBdjE4gMC
...@@ -81,7 +81,8 @@ class Cache { ...@@ -81,7 +81,8 @@ class Cache {
_artifacts.add(WindowsEngineArtifacts(this)); _artifacts.add(WindowsEngineArtifacts(this));
_artifacts.add(MacOSEngineArtifacts(this)); _artifacts.add(MacOSEngineArtifacts(this));
_artifacts.add(LinuxEngineArtifacts(this)); _artifacts.add(LinuxEngineArtifacts(this));
_artifacts.add(FuchsiaCacheArtifacts(this)); _artifacts.add(LinuxFuchsiaSDKArtifacts(this));
_artifacts.add(MacOSFuchsiaSDKArtifacts(this));
} else { } else {
_artifacts.addAll(artifacts); _artifacts.addAll(artifacts);
} }
...@@ -190,13 +191,6 @@ class Cache { ...@@ -190,13 +191,6 @@ class Cache {
} }
String _engineRevision; String _engineRevision;
/// The current version of the Fuchsia SDK the flutter tool will download.
String get fuchsiaRevision {
_fuchsiaRevision ??= getVersionFor('fuchsia');
return _fuchsiaRevision;
}
String _fuchsiaRevision;
static Cache get instance => context.get<Cache>(); static Cache get instance => context.get<Cache>();
/// Return the top-level directory in the cache; this is `bin/cache`. /// Return the top-level directory in the cache; this is `bin/cache`.
...@@ -234,7 +228,9 @@ class Cache { ...@@ -234,7 +228,9 @@ class Cache {
} }
String getVersionFor(String artifactName) { String getVersionFor(String artifactName) {
final File versionFile = fs.file(fs.path.join(_rootOverride?.path ?? flutterRoot, 'bin', 'internal', '$artifactName.version')); final File versionFile = fs.file(fs.path.join(
_rootOverride?.path ?? flutterRoot, 'bin', 'internal',
'$artifactName.version'));
return versionFile.existsSync() ? versionFile.readAsStringSync().trim() : null; return versionFile.existsSync() ? versionFile.readAsStringSync().trim() : null;
} }
...@@ -851,30 +847,52 @@ class GradleWrapper extends CachedArtifact { ...@@ -851,30 +847,52 @@ class GradleWrapper extends CachedArtifact {
} }
} }
/// The Fuchsia core SDK. /// Common functionality for pulling Fuchsia SDKs.
class FuchsiaCacheArtifacts extends CachedArtifact { abstract class _FuchsiaSDKArtifacts extends CachedArtifact {
FuchsiaCacheArtifacts(Cache cache) : super('fuchsia', cache, const <DevelopmentArtifact> { _FuchsiaSDKArtifacts(Cache cache, String platform)
:_path = 'fuchsia/sdk/core/$platform-amd64',
super('fuchsia-$platform', cache, const <DevelopmentArtifact> {
DevelopmentArtifact.fuchsia, DevelopmentArtifact.fuchsia,
}); });
static const String _cipdBaseUrl = 'https://chrome-infra-packages.appspot.com/dl'; static const String _cipdBaseUrl =
static const String _macOSSdk = 'fuchsia/sdk/core/mac-amd64'; 'https://chrome-infra-packages.appspot.com/dl';
static const String _linuxSdk = 'fuchsia/sdk/core/linux-amd64';
final String _path;
@override @override
Directory get location => cache.getArtifactDirectory('fuchsia');
Future<void> _doUpdate() {
final String url = '$_cipdBaseUrl/$_path/+/$version';
return _downloadZipArchive('Downloading package fuchsia SDK...',
Uri.parse(url), location);
}
}
/// The Fuchsia core SDK for Linux.
class LinuxFuchsiaSDKArtifacts extends _FuchsiaSDKArtifacts {
LinuxFuchsiaSDKArtifacts(Cache cache) : super(cache, 'linux');
@override
Future<void> updateInner() {
if (!platform.isLinux) {
return Future<void>.value();
}
return _doUpdate();
}
}
/// The Fuchsia core SDK for MacOS.
class MacOSFuchsiaSDKArtifacts extends _FuchsiaSDKArtifacts {
MacOSFuchsiaSDKArtifacts(Cache cache) : super(cache, 'mac');
@override
Future<void> updateInner() async { Future<void> updateInner() async {
// Step 1: Determine variant of Fuchsia SDK to download. if (!platform.isMacOS) {
String packageName; return Future<void>.value();
if (platform.isLinux) {
packageName = _linuxSdk;
} else if (platform.isMacOS) {
packageName = _macOSSdk;
} else {
// Unsupported.
return;
} }
final String url = '$_cipdBaseUrl/$packageName/+/$version'; return _doUpdate();
await _downloadZipArchive('Downloading package fuchsia SDK...', Uri.parse(url), location);
} }
} }
......
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