diff --git a/bin/internal/fuchsia-linux.version b/bin/internal/fuchsia-linux.version new file mode 100644 index 0000000000..bf3b7b9441 --- /dev/null +++ b/bin/internal/fuchsia-linux.version @@ -0,0 +1 @@ +-F-MfCBXXKddVWXabbdfQ1im71SzFu9dqYMTJs7TmqoC diff --git a/bin/internal/fuchsia-mac.version b/bin/internal/fuchsia-mac.version new file mode 100644 index 0000000000..bd18570d66 --- /dev/null +++ b/bin/internal/fuchsia-mac.version @@ -0,0 +1 @@ +Hc4DxFUkoHicT-ytOLaxzkT4QYS5uiMXXcZO6s9C1qcC diff --git a/bin/internal/fuchsia.version b/bin/internal/fuchsia.version deleted file mode 100644 index 8e9ecb9697..0000000000 --- a/bin/internal/fuchsia.version +++ /dev/null @@ -1 +0,0 @@ -mfXzGfxNWcf6BHsv083b56vQcj96yCo0exBFBdjE4gMC diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index a71be8ef75..52e1ca72fb 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -81,7 +81,8 @@ class Cache { _artifacts.add(WindowsEngineArtifacts(this)); _artifacts.add(MacOSEngineArtifacts(this)); _artifacts.add(LinuxEngineArtifacts(this)); - _artifacts.add(FuchsiaCacheArtifacts(this)); + _artifacts.add(LinuxFuchsiaSDKArtifacts(this)); + _artifacts.add(MacOSFuchsiaSDKArtifacts(this)); } else { _artifacts.addAll(artifacts); } @@ -190,13 +191,6 @@ class Cache { } 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(); /// Return the top-level directory in the cache; this is `bin/cache`. @@ -234,7 +228,9 @@ class Cache { } 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; } @@ -851,30 +847,52 @@ class GradleWrapper extends CachedArtifact { } } -/// The Fuchsia core SDK. -class FuchsiaCacheArtifacts extends CachedArtifact { - FuchsiaCacheArtifacts(Cache cache) : super('fuchsia', cache, const { +/// Common functionality for pulling Fuchsia SDKs. +abstract class _FuchsiaSDKArtifacts extends CachedArtifact { + _FuchsiaSDKArtifacts(Cache cache, String platform) + :_path = 'fuchsia/sdk/core/$platform-amd64', + super('fuchsia-$platform', cache, const { DevelopmentArtifact.fuchsia, }); - static const String _cipdBaseUrl = 'https://chrome-infra-packages.appspot.com/dl'; - static const String _macOSSdk = 'fuchsia/sdk/core/mac-amd64'; - static const String _linuxSdk = 'fuchsia/sdk/core/linux-amd64'; + static const String _cipdBaseUrl = + 'https://chrome-infra-packages.appspot.com/dl'; - @override - Future updateInner() async { - // Step 1: Determine variant of Fuchsia SDK to download. - String packageName; - if (platform.isLinux) { - packageName = _linuxSdk; - } else if (platform.isMacOS) { - packageName = _macOSSdk; - } else { - // Unsupported. - return; + final String _path; + + @override + Directory get location => cache.getArtifactDirectory('fuchsia'); + + Future _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 updateInner() { + if (!platform.isLinux) { + return Future.value(); } - final String url = '$_cipdBaseUrl/$packageName/+/$version'; - await _downloadZipArchive('Downloading package fuchsia SDK...', Uri.parse(url), location); + return _doUpdate(); + } +} + +/// The Fuchsia core SDK for MacOS. +class MacOSFuchsiaSDKArtifacts extends _FuchsiaSDKArtifacts { + MacOSFuchsiaSDKArtifacts(Cache cache) : super(cache, 'mac'); + + @override + Future updateInner() async { + if (!platform.isMacOS) { + return Future.value(); + } + return _doUpdate(); } }