Unverified Commit 5228a785 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Fuchsia step 1: add SDK version file and artifact download (#31073)

parent 96e1fc9c
Ow5Xdviq7OwKr7XNuf-Bw0nBMeAr849mFn7gc_RUpzUC
...@@ -16,27 +16,53 @@ import 'base/platform.dart'; ...@@ -16,27 +16,53 @@ import 'base/platform.dart';
import 'globals.dart'; import 'globals.dart';
/// A tag for a set of development artifacts that need to be cached. /// A tag for a set of development artifacts that need to be cached.
enum DevelopmentArtifact { class DevelopmentArtifact {
const DevelopmentArtifact._(this.name, {this.unstable = false});
/// The name of the artifact.
///
/// This should match the flag name in precache.dart
final String name;
/// Whether this artifact should not be usable on stable branches.
final bool unstable;
/// Artifacts required for Android development. /// Artifacts required for Android development.
android, static const DevelopmentArtifact android = DevelopmentArtifact._('android');
/// Artifacts required for iOS development. /// Artifacts required for iOS development.
iOS, static const DevelopmentArtifact iOS = DevelopmentArtifact._('ios');
/// Artifacts required for web development, /// Artifacts required for web development,
web, static const DevelopmentArtifact web = DevelopmentArtifact._('web', unstable: true);
/// Artifacts required for desktop macOS. /// Artifacts required for desktop macOS.
macOS, static const DevelopmentArtifact macOS = DevelopmentArtifact._('macos', unstable: true);
/// Artifacts required for desktop Windows. /// Artifacts required for desktop Windows.
windows, static const DevelopmentArtifact windows = DevelopmentArtifact._('windows', unstable: true);
/// Artifacts required for desktop linux. /// Artifacts required for desktop linux.
linux, static const DevelopmentArtifact linux = DevelopmentArtifact._('linux', unstable: true);
/// Artifacts required for Fuchsia.
static const DevelopmentArtifact fuchsia = DevelopmentArtifact._('fuchsia', unstable: true);
/// Artifacts required by all developments. /// Artifacts required by all developments.
universal, static const DevelopmentArtifact universal = DevelopmentArtifact._('universal');
/// The vaulues of DevelopmentArtifacts.
static final List<DevelopmentArtifact> values = <DevelopmentArtifact>[
android,
iOS,
web,
macOS,
windows,
linux,
fuchsia,
universal,
];
} }
/// A wrapper around the `bin/cache/` directory. /// A wrapper around the `bin/cache/` directory.
...@@ -54,6 +80,7 @@ class Cache { ...@@ -54,6 +80,7 @@ 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));
} else { } else {
_artifacts.addAll(artifacts); _artifacts.addAll(artifacts);
} }
...@@ -155,12 +182,19 @@ class Cache { ...@@ -155,12 +182,19 @@ class Cache {
return _dartSdkVersion; return _dartSdkVersion;
} }
String _engineRevision; /// The current version of the Flutter engine the flutter tool will download.
String get engineRevision { String get engineRevision {
_engineRevision ??= getVersionFor('engine'); _engineRevision ??= getVersionFor('engine');
return _engineRevision; return _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[Cache]; static Cache get instance => context[Cache];
...@@ -817,6 +851,33 @@ class GradleWrapper extends CachedArtifact { ...@@ -817,6 +851,33 @@ class GradleWrapper extends CachedArtifact {
} }
} }
/// The Fuchsia core SDK.
class FuchsiaCacheArtifacts extends CachedArtifact {
FuchsiaCacheArtifacts(Cache cache) : super('fuchsia', cache, const <DevelopmentArtifact> {
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';
@override
Future<void> 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 url = '$_cipdBaseUrl/$packageName/+/$version';
await _downloadZipArchive('Downloading package fuchsia SDK...', Uri.parse(url), location);
}
}
// Many characters are problematic in filenames, especially on Windows. // Many characters are problematic in filenames, especially on Windows.
final Map<int, List<int>> _flattenNameSubstitutions = <int, List<int>>{ final Map<int, List<int>> _flattenNameSubstitutions = <int, List<int>>{
r'@'.codeUnitAt(0): '@@'.codeUnits, r'@'.codeUnitAt(0): '@@'.codeUnits,
......
...@@ -25,6 +25,10 @@ class PrecacheCommand extends FlutterCommand { ...@@ -25,6 +25,10 @@ class PrecacheCommand extends FlutterCommand {
help: 'Precache artifacts for windows desktop development'); help: 'Precache artifacts for windows desktop development');
argParser.addFlag('macos', negatable: true, defaultsTo: false, argParser.addFlag('macos', negatable: true, defaultsTo: false,
help: 'Precache artifacts for macOS desktop development'); help: 'Precache artifacts for macOS desktop development');
argParser.addFlag('fuchsia', negatable: true, defaultsTo: false,
help: 'Precache artifacts for Fuchsia development');
argParser.addFlag('universal', negatable: true, defaultsTo: true,
help: 'Precache artifacts required for all developments');
} }
@override @override
...@@ -41,28 +45,16 @@ class PrecacheCommand extends FlutterCommand { ...@@ -41,28 +45,16 @@ class PrecacheCommand extends FlutterCommand {
if (argResults['all-platforms']) { if (argResults['all-platforms']) {
cache.includeAllPlatforms = true; cache.includeAllPlatforms = true;
} }
final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{ DevelopmentArtifact.universal }; final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{};
if (argResults['android']) { for (DevelopmentArtifact artifact in DevelopmentArtifact.values) {
requiredArtifacts.add(DevelopmentArtifact.android); // Don't include unstable artifacts on stable branches.
} if (FlutterVersion.instance.isStable && artifact.unstable) {
if (argResults['ios']) { continue;
requiredArtifacts.add(DevelopmentArtifact.iOS);
}
if (!FlutterVersion.instance.isStable) {
if (argResults['web']) {
requiredArtifacts.add(DevelopmentArtifact.web);
}
if (argResults['linux']) {
requiredArtifacts.add(DevelopmentArtifact.linux);
} }
if (argResults['windows']) { if (argResults[artifact.name]) {
requiredArtifacts.add(DevelopmentArtifact.windows); requiredArtifacts.add(artifact);
}
if (argResults['macos']) {
requiredArtifacts.add(DevelopmentArtifact.macOS);
} }
} }
if (cache.isUpToDate()) { if (cache.isUpToDate()) {
printStatus('Already up-to-date.'); printStatus('Already up-to-date.');
} else { } else {
......
...@@ -27,7 +27,7 @@ void main() { ...@@ -27,7 +27,7 @@ void main() {
final PrecacheCommand command = PrecacheCommand(); final PrecacheCommand command = PrecacheCommand();
applyMocksToCommand(command); applyMocksToCommand(command);
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['precache', '--ios', '--android', '--web', '--macos', '--linux', '--windows'] const <String>['precache', '--ios', '--android', '--web', '--macos', '--linux', '--windows', '--fuchsia']
); );
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{ expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal, DevelopmentArtifact.universal,
...@@ -37,6 +37,7 @@ void main() { ...@@ -37,6 +37,7 @@ void main() {
DevelopmentArtifact.macOS, DevelopmentArtifact.macOS,
DevelopmentArtifact.linux, DevelopmentArtifact.linux,
DevelopmentArtifact.windows, DevelopmentArtifact.windows,
DevelopmentArtifact.fuchsia,
})); }));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Cache: () => cache, Cache: () => cache,
...@@ -51,7 +52,7 @@ void main() { ...@@ -51,7 +52,7 @@ void main() {
final PrecacheCommand command = PrecacheCommand(); final PrecacheCommand command = PrecacheCommand();
applyMocksToCommand(command); applyMocksToCommand(command);
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['precache', '--ios', '--android', '--web', '--macos', '--linux', '--windows'] const <String>['precache', '--ios', '--android', '--web', '--macos', '--linux', '--windows', '--fuchsia']
); );
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{ expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal, DevelopmentArtifact.universal,
......
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