Unverified Commit 164dae3b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Lazy cache 4 (#29785)" (#29985)

parent f652f018
...@@ -85,6 +85,7 @@ class AOTSnapshotter { ...@@ -85,6 +85,7 @@ class AOTSnapshotter {
if (fs.file('pubspec.yaml').existsSync()) { if (fs.file('pubspec.yaml').existsSync()) {
flutterProject = await FlutterProject.current(); flutterProject = await FlutterProject.current();
} }
final FlutterEngine engine = FlutterEngine(cache);
if (!_isValidAotPlatform(platform, buildMode)) { if (!_isValidAotPlatform(platform, buildMode)) {
printError('${getNameForTargetPlatform(platform)} does not support AOT compilation.'); printError('${getNameForTargetPlatform(platform)} does not support AOT compilation.');
return 1; return 1;
...@@ -186,7 +187,7 @@ class AOTSnapshotter { ...@@ -186,7 +187,7 @@ class AOTSnapshotter {
'entryPoint': mainPath, 'entryPoint': mainPath,
'sharedLib': buildSharedLibrary.toString(), 'sharedLib': buildSharedLibrary.toString(),
'extraGenSnapshotOptions': extraGenSnapshotOptions.join(' '), 'extraGenSnapshotOptions': extraGenSnapshotOptions.join(' '),
'engineHash': Cache.instance.engineRevision, 'engineHash': engine.version,
'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}', 'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}',
}, },
depfilePaths: <String>[], depfilePaths: <String>[],
......
This diff is collapsed.
...@@ -64,11 +64,6 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -64,11 +64,6 @@ class AnalyzeCommand extends FlutterCommand {
@override @override
String get description => "Analyze the project's Dart code."; String get description => "Analyze the project's Dart code.";
@override
Set<DevelopmentArtifact> get requiredArtifacts => const <DevelopmentArtifact>{
DevelopmentArtifact.universal,
};
@override @override
bool get shouldRunPub { bool get shouldRunPub {
// If they're not analyzing the current project. // If they're not analyzing the current project.
......
...@@ -8,7 +8,7 @@ import '../base/common.dart'; ...@@ -8,7 +8,7 @@ import '../base/common.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../globals.dart'; import '../globals.dart';
import '../runner/flutter_command.dart' show DevelopmentArtifact, FlutterCommandResult; import '../runner/flutter_command.dart' show FlutterCommandResult;
import '../web/compile.dart'; import '../web/compile.dart';
import 'build.dart'; import 'build.dart';
...@@ -19,12 +19,6 @@ class BuildWebCommand extends BuildSubCommand { ...@@ -19,12 +19,6 @@ class BuildWebCommand extends BuildSubCommand {
defaultBuildMode = BuildMode.release; defaultBuildMode = BuildMode.release;
} }
@override
Set<DevelopmentArtifact> get requiredArtifacts => const <DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.web,
};
@override @override
final String name = 'web'; final String name = 'web';
......
...@@ -245,7 +245,7 @@ class CreateCommand extends FlutterCommand { ...@@ -245,7 +245,7 @@ class CreateCommand extends FlutterCommand {
throwToolExit('Neither the --flutter-root command line flag nor the FLUTTER_ROOT environment ' throwToolExit('Neither the --flutter-root command line flag nor the FLUTTER_ROOT environment '
'variable was specified. Unable to find package:flutter.', exitCode: 2); 'variable was specified. Unable to find package:flutter.', exitCode: 2);
await Cache.instance.updateAll(<DevelopmentArtifact>{ DevelopmentArtifact.universal }); await Cache.instance.updateAll();
final String flutterRoot = fs.path.absolute(Cache.flutterRoot); final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
......
...@@ -223,7 +223,7 @@ class IdeConfigCommand extends FlutterCommand { ...@@ -223,7 +223,7 @@ class IdeConfigCommand extends FlutterCommand {
throwToolExit('Currently, the only supported IDE is IntelliJ\n$usage', exitCode: 2); throwToolExit('Currently, the only supported IDE is IntelliJ\n$usage', exitCode: 2);
} }
await Cache.instance.updateAll(<DevelopmentArtifact>{ DevelopmentArtifact.universal }); await Cache.instance.updateAll();
if (argResults['update-templates']) { if (argResults['update-templates']) {
_handleTemplateUpdate(); _handleTemplateUpdate();
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'dart:async'; import 'dart:async';
import '../cache.dart';
import '../globals.dart'; import '../globals.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
...@@ -12,12 +11,6 @@ class PrecacheCommand extends FlutterCommand { ...@@ -12,12 +11,6 @@ class PrecacheCommand extends FlutterCommand {
PrecacheCommand() { PrecacheCommand() {
argParser.addFlag('all-platforms', abbr: 'a', negatable: false, argParser.addFlag('all-platforms', abbr: 'a', negatable: false,
help: 'Precache artifacts for all platforms.'); help: 'Precache artifacts for all platforms.');
argParser.addFlag('android', negatable: true, defaultsTo: true,
help: 'Precache artifacts for Android development');
argParser.addFlag('ios', negatable: true, defaultsTo: true,
help: 'Precache artifacts for iOS developemnt');
argParser.addFlag('web', negatable: true, defaultsTo: false,
help: 'Precache artifacts for web development');
} }
@override @override
...@@ -31,25 +24,14 @@ class PrecacheCommand extends FlutterCommand { ...@@ -31,25 +24,14 @@ class PrecacheCommand extends FlutterCommand {
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
if (argResults['all-platforms']) { if (argResults['all-platforms'])
cache.includeAllPlatforms = true; cache.includeAllPlatforms = true;
}
final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{ DevelopmentArtifact.universal }; if (cache.isUpToDate())
if (argResults['android']) {
requiredArtifacts.add(DevelopmentArtifact.android);
}
if (argResults['ios']) {
requiredArtifacts.add(DevelopmentArtifact.iOS);
}
if (argResults['web']) {
requiredArtifacts.add(DevelopmentArtifact.web);
}
if (cache.isUpToDate(requiredArtifacts)) {
printStatus('Already up-to-date.'); printStatus('Already up-to-date.');
} else { else
await cache.updateAll(requiredArtifacts); await cache.updateAll();
}
return null; return null;
} }
} }
...@@ -232,6 +232,7 @@ class KernelCompiler { ...@@ -232,6 +232,7 @@ class KernelCompiler {
if (fs.file('pubspec.yaml').existsSync()) { if (fs.file('pubspec.yaml').existsSync()) {
flutterProject = await FlutterProject.current(); flutterProject = await FlutterProject.current();
} }
final FlutterEngine engine = FlutterEngine(cache);
// TODO(cbracken): eliminate pathFilter. // TODO(cbracken): eliminate pathFilter.
// Currently the compiler emits buildbot paths for the core libs in the // Currently the compiler emits buildbot paths for the core libs in the
...@@ -245,7 +246,7 @@ class KernelCompiler { ...@@ -245,7 +246,7 @@ class KernelCompiler {
'entryPoint': mainPath, 'entryPoint': mainPath,
'trackWidgetCreation': trackWidgetCreation.toString(), 'trackWidgetCreation': trackWidgetCreation.toString(),
'linkPlatformKernelIn': linkPlatformKernelIn.toString(), 'linkPlatformKernelIn': linkPlatformKernelIn.toString(),
'engineHash': Cache.instance.engineRevision, 'engineHash': engine.version,
'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}', 'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}',
}, },
depfilePaths: <String>[depFilePath], depfilePaths: <String>[depFilePath],
......
...@@ -170,7 +170,9 @@ class Doctor { ...@@ -170,7 +170,9 @@ class Doctor {
} }
Future<bool> checkRemoteArtifacts(String engineRevision) async { Future<bool> checkRemoteArtifacts(String engineRevision) async {
return Cache.instance.areRemoteArtifactsAvailable(engineVersion: engineRevision); final Cache cache = Cache();
final FlutterEngine engine = FlutterEngine(cache);
return await engine.areRemoteArtifactsAvailable(engineVersion: engineRevision);
} }
/// Print information about the state of installed tooling. /// Print information about the state of installed tooling.
......
...@@ -19,7 +19,6 @@ import '../base/user_messages.dart'; ...@@ -19,7 +19,6 @@ import '../base/user_messages.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../bundle.dart' as bundle; import '../bundle.dart' as bundle;
import '../cache.dart';
import '../dart/package_map.dart'; import '../dart/package_map.dart';
import '../dart/pub.dart'; import '../dart/pub.dart';
import '../device.dart'; import '../device.dart';
...@@ -29,8 +28,6 @@ import '../project.dart'; ...@@ -29,8 +28,6 @@ import '../project.dart';
import '../usage.dart'; import '../usage.dart';
import 'flutter_command_runner.dart'; import 'flutter_command_runner.dart';
export '../cache.dart' show DevelopmentArtifact;
enum ExitStatus { enum ExitStatus {
success, success,
warning, warning,
...@@ -533,9 +530,8 @@ abstract class FlutterCommand extends Command<void> { ...@@ -533,9 +530,8 @@ abstract class FlutterCommand extends Command<void> {
// Populate the cache. We call this before pub get below so that the sky_engine // 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. // package is available in the flutter cache for pub to find.
if (shouldUpdateCache) { if (shouldUpdateCache)
await cache.updateAll(requiredArtifacts); await cache.updateAll();
}
if (shouldRunPub) { if (shouldRunPub) {
await pubGet(context: PubContext.getVerifyContext(name)); await pubGet(context: PubContext.getVerifyContext(name));
...@@ -553,16 +549,6 @@ abstract class FlutterCommand extends Command<void> { ...@@ -553,16 +549,6 @@ abstract class FlutterCommand extends Command<void> {
return await runCommand(); return await runCommand();
} }
/// The set of development artifacts required for this command.
///
/// Defaults to [DevelopmentArtifact.universal],
/// [DevelopmentArtifact.android], and [DevelopmentArtifact.iOS].
Set<DevelopmentArtifact> get requiredArtifacts => const <DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.iOS,
DevelopmentArtifact.android,
};
/// Subclasses must implement this to execute the command. /// Subclasses must implement this to execute the command.
/// Optionally provide a [FlutterCommandResult] to send more details about the /// Optionally provide a [FlutterCommandResult] to send more details about the
/// execution for analytics. /// execution for analytics.
......
...@@ -84,34 +84,34 @@ void main() { ...@@ -84,34 +84,34 @@ void main() {
test('should not be up to date, if some cached artifact is not', () { test('should not be up to date, if some cached artifact is not', () {
final CachedArtifact artifact1 = MockCachedArtifact(); final CachedArtifact artifact1 = MockCachedArtifact();
final CachedArtifact artifact2 = MockCachedArtifact(); final CachedArtifact artifact2 = MockCachedArtifact();
when(artifact1.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(true); when(artifact1.isUpToDate()).thenReturn(true);
when(artifact2.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(false); when(artifact2.isUpToDate()).thenReturn(false);
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]); final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
expect(cache.isUpToDate(const <DevelopmentArtifact>{}), isFalse); expect(cache.isUpToDate(), isFalse);
}); });
test('should be up to date, if all cached artifacts are', () { test('should be up to date, if all cached artifacts are', () {
final CachedArtifact artifact1 = MockCachedArtifact(); final CachedArtifact artifact1 = MockCachedArtifact();
final CachedArtifact artifact2 = MockCachedArtifact(); final CachedArtifact artifact2 = MockCachedArtifact();
when(artifact1.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(true); when(artifact1.isUpToDate()).thenReturn(true);
when(artifact2.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(true); when(artifact2.isUpToDate()).thenReturn(true);
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]); final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
expect(cache.isUpToDate(const <DevelopmentArtifact>{}), isTrue); expect(cache.isUpToDate(), isTrue);
}); });
test('should update cached artifacts which are not up to date', () async { test('should update cached artifacts which are not up to date', () async {
final CachedArtifact artifact1 = MockCachedArtifact(); final CachedArtifact artifact1 = MockCachedArtifact();
final CachedArtifact artifact2 = MockCachedArtifact(); final CachedArtifact artifact2 = MockCachedArtifact();
when(artifact1.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(true); when(artifact1.isUpToDate()).thenReturn(true);
when(artifact2.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(false); when(artifact2.isUpToDate()).thenReturn(false);
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]); final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
await cache.updateAll(const <DevelopmentArtifact>{}); await cache.updateAll();
verifyNever(artifact1.update()); verifyNever(artifact1.update());
verify(artifact2.update()); verify(artifact2.update());
}); });
testUsingContext('failed storage.googleapis.com download shows China warning', () async { testUsingContext('failed storage.googleapis.com download shows China warning', () async {
final CachedArtifact artifact1 = MockCachedArtifact(); final CachedArtifact artifact1 = MockCachedArtifact();
final CachedArtifact artifact2 = MockCachedArtifact(); final CachedArtifact artifact2 = MockCachedArtifact();
when(artifact1.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(false); when(artifact1.isUpToDate()).thenReturn(false);
when(artifact2.isUpToDate(const <DevelopmentArtifact>{})).thenReturn(false); when(artifact2.isUpToDate()).thenReturn(false);
final MockInternetAddress address = MockInternetAddress(); final MockInternetAddress address = MockInternetAddress();
when(address.host).thenReturn('storage.googleapis.com'); when(address.host).thenReturn('storage.googleapis.com');
when(artifact1.update()).thenThrow(SocketException( when(artifact1.update()).thenThrow(SocketException(
...@@ -120,7 +120,7 @@ void main() { ...@@ -120,7 +120,7 @@ void main() {
)); ));
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]); final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
try { try {
await cache.updateAll(const <DevelopmentArtifact>{}); await cache.updateAll();
fail('Mock thrown exception expected'); fail('Mock thrown exception expected');
} catch (e) { } catch (e) {
verify(artifact1.update()); verify(artifact1.update());
......
...@@ -42,7 +42,7 @@ void main() { ...@@ -42,7 +42,7 @@ void main() {
testUsingContext('honors shouldUpdateCache true', () async { testUsingContext('honors shouldUpdateCache true', () async {
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: true); final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: true);
await flutterCommand.run(); await flutterCommand.run();
verify(cache.updateAll(any)).called(1); verify(cache.updateAll()).called(1);
}, },
overrides: <Type, Generator>{ overrides: <Type, Generator>{
Cache: () => cache, 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