Unverified Commit 7cdb30fb authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Lazily download artifacts (#27374)" (#27705)

This reverts commit 98971f3c.
parent 98971f3c
......@@ -134,7 +134,4 @@ class _FuchsiaAttachCommand extends AttachCommand {
Cache.flutterRoot = '$originalWorkingDirectory/third_party/dart-pkg/git/flutter';
return super.runCommand();
}
@override
Future<void> updateCache() async {}
}
......@@ -84,6 +84,7 @@ BuildApp() {
local framework_path="${FLUTTER_ROOT}/bin/cache/artifacts/engine/${artifact_variant}"
AssertExists "${framework_path}"
AssertExists "${project_path}"
local derived_dir="${SOURCE_ROOT}/Flutter"
......@@ -117,11 +118,6 @@ BuildApp() {
flutter_podspec="${LOCAL_ENGINE}/Flutter.podspec"
fi
# If the framework path does not exist, ensure that it is downloaded.
if [[ ! -e "$1" ]]; then
RunCommand "${FLUTTER_ROOT}/bin/flutter" precache --suppress-analytics
fi
if [[ -e "${project_path}/.ios" ]]; then
RunCommand rm -rf -- "${derived_dir}/engine"
mkdir "${derived_dir}/engine"
......
......@@ -37,8 +37,7 @@ Future<List<int>> _attempt(Uri url, {bool onlyHeaders = false}) async {
printTrace('Downloading: $url');
HttpClient httpClient;
if (context[HttpClientFactory] != null) {
final HttpClientFactory httpClientFactory = context[HttpClientFactory];
httpClient = httpClientFactory();
httpClient = (context[HttpClientFactory] as HttpClientFactory)(); // ignore: avoid_as
} else {
httpClient = HttpClient();
}
......@@ -65,9 +64,9 @@ Future<List<int>> _attempt(Uri url, {bool onlyHeaders = false}) async {
// If we're making a HEAD request, we're only checking to see if the URL is
// valid.
if (onlyHeaders) {
return (response.statusCode == HttpStatus.ok) ? <int>[] : null;
return (response.statusCode == 200) ? <int>[] : null;
}
if (response.statusCode != HttpStatus.ok) {
if (response.statusCode != 200) {
if (response.statusCode > 0 && response.statusCode < 500) {
throwToolExit(
'Download failed.\n'
......
This diff is collapsed.
......@@ -4,8 +4,6 @@
import 'dart:async';
import '../build_info.dart';
import '../globals.dart';
import '../runner/flutter_command.dart';
import 'build_aot.dart';
import 'build_apk.dart';
......@@ -38,19 +36,4 @@ abstract class BuildSubCommand extends FlutterCommand {
BuildSubCommand() {
requiresPubspecYaml();
}
@override
Future<void> updateCache() async {
final BuildInfo buildInfo = getBuildInfo();
bool skipUnknown = false;
if (buildInfo.mode == null || buildInfo.targetPlatform == null) {
skipUnknown = true;
}
await cache.updateAll(
buildMode: buildInfo.mode,
targetPlatform: buildInfo.targetPlatform,
clobber: false,
skipUnknown: skipUnknown,
);
}
}
......@@ -5,8 +5,6 @@
import 'dart:async';
import '../android/apk.dart';
import '../build_info.dart';
import '../globals.dart';
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
import 'build.dart';
......@@ -51,17 +49,4 @@ class BuildApkCommand extends BuildSubCommand {
);
return null;
}
@override
Future<void> updateCache() async {
// Due to logic of flutter.gradle, we require every release mode and every android target architecture.
for (TargetPlatform targetPlatform in <TargetPlatform>[TargetPlatform.android_arm, TargetPlatform.android_arm64]) {
await cache.updateAll(
buildMode: null,
targetPlatform: targetPlatform,
clobber: false,
skipUnknown: true,
);
}
}
}
......@@ -5,8 +5,6 @@
import 'dart:async';
import '../android/app_bundle.dart';
import '../build_info.dart';
import '../globals.dart';
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
import 'build.dart';
......@@ -49,17 +47,4 @@ class BuildAppBundleCommand extends BuildSubCommand {
);
return null;
}
@override
Future<void> updateCache() async {
// Due to logic of flutter.gradle, we require every release mode and every android target architecture.
for (TargetPlatform targetPlatform in <TargetPlatform>[TargetPlatform.android_arm, TargetPlatform.android_arm64]) {
await cache.updateAll(
buildMode: null,
targetPlatform: targetPlatform,
clobber: false,
skipUnknown: true,
);
}
}
}
......@@ -48,16 +48,10 @@ class BuildIOSCommand extends BuildSubCommand {
@override
final String description = 'Build an iOS application bundle (Mac OS X host only).';
@override
Future<void> validateCommand() async {
defaultBuildMode = forSimulator ? BuildMode.debug : BuildMode.release;
return super.validateCommand();
}
bool get forSimulator => argResults['simulator'];
@override
Future<FlutterCommandResult> runCommand() async {
final bool forSimulator = argResults['simulator'];
defaultBuildMode = forSimulator ? BuildMode.debug : BuildMode.release;
if (getCurrentHostPlatform() != HostPlatform.darwin_x64)
throwToolExit('Building for iOS is only supported on the Mac.');
......
......@@ -211,7 +211,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(buildMode: null, targetPlatform: null, skipUnknown: true, clobber: false);
await Cache.instance.updateAll();
final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
......
......@@ -6,7 +6,6 @@ import 'dart:async';
import '../base/common.dart';
import '../doctor.dart';
import '../globals.dart';
import '../runner/flutter_command.dart';
class DoctorCommand extends FlutterCommand {
......@@ -49,14 +48,4 @@ class DoctorCommand extends FlutterCommand {
final bool success = await doctor.diagnose(androidLicenses: argResults['android-licenses'], verbose: verbose);
return FlutterCommandResult(success ? ExitStatus.success : ExitStatus.warning);
}
@override
Future<void> updateCache() async {
await cache.updateAll(
buildMode: null,
targetPlatform: null,
clobber: false,
skipUnknown: true,
);
}
}
......@@ -223,6 +223,8 @@ class IdeConfigCommand extends FlutterCommand {
throwToolExit('Currently, the only supported IDE is IntelliJ\n$usage', exitCode: 2);
}
await Cache.instance.updateAll();
if (argResults['update-templates']) {
_handleTemplateUpdate();
return null;
......
......@@ -4,7 +4,6 @@
import 'dart:async';
import '../cache.dart';
import '../globals.dart';
import '../runner/flutter_command.dart';
......@@ -12,8 +11,6 @@ class PrecacheCommand extends FlutterCommand {
PrecacheCommand() {
argParser.addFlag('all-platforms', abbr: 'a', negatable: false,
help: 'Precache artifacts for all platforms.');
argParser.addFlag('force', abbr: 'f', negatable: false,
help: 'Force download of new cached artifacts');
}
@override
......@@ -27,21 +24,14 @@ class PrecacheCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> runCommand() async {
if (argResults['all-platforms']) {
if (argResults['all-platforms'])
cache.includeAllPlatforms = true;
}
// Intentionally set to null to download all artifacts.
final UpdateResult result = cache.isUpToDate(buildMode: null, targetPlatform: null, skipUnknown: false);
if (result.isUpToDate && !result.clobber && !argResults['force']) {
if (cache.isUpToDate())
printStatus('Already up-to-date.');
} else {
await cache.updateAll(
buildMode: null,
targetPlatform: null,
skipUnknown: false,
clobber: argResults['force'] || result.clobber,
);
}
return const FlutterCommandResult(ExitStatus.success);
else
await cache.updateAll();
return null;
}
}
......@@ -260,36 +260,6 @@ class RunCommand extends RunCommandBase {
}
}
@override
Future<void> updateCache() async {
final BuildInfo buildInfo = getBuildInfo();
final BuildMode buildMode = buildInfo.mode ?? BuildMode.debug;
final List<TargetPlatform> targetPlatforms = <TargetPlatform>[];
if (buildInfo.targetPlatform != null) {
targetPlatforms.add(buildInfo.targetPlatform);
}
await for (Device device in deviceManager.getAllConnectedDevices()) {
targetPlatforms.add(await device.targetPlatform);
}
if (targetPlatforms.isEmpty) {
await cache.updateAll(
buildMode: buildMode,
targetPlatform: buildInfo.targetPlatform,
clobber: false,
skipUnknown: false,
);
} else {
for (TargetPlatform targetPlatform in targetPlatforms) {
await cache.updateAll(
buildMode: buildMode,
targetPlatform: targetPlatform,
clobber: false,
skipUnknown: true,
);
}
}
}
@override
Future<FlutterCommandResult> runCommand() async {
Cache.releaseLockEarly();
......
......@@ -323,43 +323,30 @@ abstract class FlutterCommand extends Command<void> {
}
BuildMode getBuildMode() {
bool debug;
bool profile;
bool release;
if (argParser.options.containsKey('debug')) {
debug = argResults['debug'];
} else {
debug = _defaultBuildMode == BuildMode.debug;
}
if (argParser.options.containsKey('profile')) {
profile = argResults['profile'];
} else {
profile = _defaultBuildMode == BuildMode.profile;
}
if (argParser.options.containsKey('release')) {
release = argResults['release'];
} else {
release = _defaultBuildMode == BuildMode.release;
}
if (debug && profile || debug && release || release && profile) {
final List<bool> modeFlags = <bool>[argResults['debug'], argResults['profile'], argResults['release']];
if (modeFlags.where((bool flag) => flag).length > 1)
throw UsageException('Only one of --debug, --profile, or --release can be specified.', null);
}
final bool dynamicFlag = argParser.options.containsKey('dynamic')
? argResults['dynamic']
: false;
if (debug) {
if (dynamicFlag) {
if (argResults['debug']) {
if (dynamicFlag)
throw ToolExit('Error: --dynamic requires --release or --profile.');
}
return BuildMode.debug;
}
if (profile) {
if (argResults['profile'])
return dynamicFlag ? BuildMode.dynamicProfile : BuildMode.profile;
}
if (release) {
if (argResults['release'])
return dynamicFlag ? BuildMode.dynamicRelease : BuildMode.release;
}
if (_defaultBuildMode == BuildMode.debug && dynamicFlag)
throw ToolExit('Error: --dynamic requires --release or --profile.');
if (_defaultBuildMode == BuildMode.release && dynamicFlag)
return BuildMode.dynamicRelease;
if (_defaultBuildMode == BuildMode.profile && dynamicFlag)
return BuildMode.dynamicProfile;
return _defaultBuildMode;
}
......@@ -403,7 +390,7 @@ abstract class FlutterCommand extends Command<void> {
'--patch-number (${argResults['patch-number']}) must be an int.', null);
}
List<String> extraFrontEndOptions =
String extraFrontEndOptions =
argParser.options.containsKey(FlutterOptions.kExtraFrontEndOptions)
? argResults[FlutterOptions.kExtraFrontEndOptions]
: null;
......@@ -412,9 +399,9 @@ abstract class FlutterCommand extends Command<void> {
for (String expFlag in argResults[FlutterOptions.kEnableExperiment]) {
final String flag = '--enable-experiment=' + expFlag;
if (extraFrontEndOptions != null) {
extraFrontEndOptions.add(flag);
extraFrontEndOptions += ',' + flag;
} else {
extraFrontEndOptions = <String>[flag];
extraFrontEndOptions = flag;
}
}
}
......@@ -440,9 +427,9 @@ abstract class FlutterCommand extends Command<void> {
baselineDir: argParser.options.containsKey('baseline-dir')
? argResults['baseline-dir']
: null,
extraFrontEndOptions: extraFrontEndOptions?.join(', '),
extraFrontEndOptions: extraFrontEndOptions,
extraGenSnapshotOptions: argParser.options.containsKey(FlutterOptions.kExtraGenSnapshotOptions)
? argResults[FlutterOptions.kExtraGenSnapshotOptions]?.join(', ')
? argResults[FlutterOptions.kExtraGenSnapshotOptions]
: null,
buildSharedLibrary: argParser.options.containsKey('build-shared-library')
? argResults['build-shared-library']
......@@ -532,19 +519,6 @@ abstract class FlutterCommand extends Command<void> {
);
}
/// A hook called to populate the cache with a particular target platform
/// or build mode.
///
/// If a command requires specific artifacts, it is it's responsibility to
/// request them here.
Future<void> updateCache() async {
// Only download the minimum set of binaries.
await cache.updateAll(
clobber: false,
skipUnknown: true,
);
}
/// Perform validation then call [runCommand] to execute the command.
/// Return a [Future] that completes with an exit code
/// indicating whether execution was successful.
......@@ -555,11 +529,11 @@ abstract class FlutterCommand extends Command<void> {
@mustCallSuper
Future<FlutterCommandResult> verifyThenRunCommand(String commandPath) async {
await validateCommand();
// 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 updateCache();
}
if (shouldUpdateCache)
await cache.updateAll();
if (shouldRunPub) {
await pubGet(context: PubContext.getVerifyContext(name));
......
This diff is collapsed.
......@@ -44,12 +44,7 @@ void main() {
testUsingContext('honors shouldUpdateCache true', () async {
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: true);
await flutterCommand.run();
verify(cache.updateAll(
buildMode: anyNamed('buildMode'),
clobber: anyNamed('clobber'),
skipUnknown: anyNamed('skipUnknown'),
targetPlatform: anyNamed('targetPlatform')
)).called(1);
verify(cache.updateAll()).called(1);
},
overrides: <Type, Generator>{
Cache: () => cache,
......
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