Unverified Commit 70c651b0 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Move BuildSystem to globals (#53139)

parent 0b321e67
......@@ -97,7 +97,7 @@ class AotBuilder {
kIosArchs: iosBuildArchs.map(getNameForDarwinArch).join(' ')
}
);
final BuildResult result = await buildSystem.build(target, environment);
final BuildResult result = await globals.buildSystem.build(target, environment);
status?.stop();
if (!result.success) {
......
......@@ -10,7 +10,6 @@ import 'package:crypto/crypto.dart';
import 'package:meta/meta.dart';
import 'package:pool/pool.dart';
import '../base/context.dart';
import '../base/file_system.dart';
import '../base/utils.dart';
import '../cache.dart';
......@@ -22,9 +21,6 @@ import 'source.dart';
export 'source.dart';
/// The [BuildSystem] instance.
BuildSystem get buildSystem => context.get<BuildSystem>();
/// A reasonable amount of files to open at the same time.
///
/// This number is somewhat arbitrary - it is difficult to detect whether
......
......@@ -136,7 +136,7 @@ Future<void> buildWithAssemble({
final Target target = buildMode == BuildMode.debug
? const CopyFlutterBundle()
: const ReleaseCopyFlutterBundle();
final BuildResult result = await buildSystem.build(target, environment);
final BuildResult result = await globals.buildSystem.build(target, environment);
if (!result.success) {
for (final ExceptionMeasurement measurement in result.exceptions.values) {
......
......@@ -177,7 +177,7 @@ class AssembleCommand extends FlutterCommand {
Future<FlutterCommandResult> runCommand() async {
final List<Target> targets = this.targets;
final Target target = targets.length == 1 ? targets.single : _CompositeTarget(targets);
final BuildResult result = await buildSystem.build(target, environment, buildSystemConfig: BuildSystemConfig(
final BuildResult result = await globals.buildSystem.build(target, environment, buildSystemConfig: BuildSystemConfig(
resourcePoolSize: argResults.wasParsed('resource-pool-size')
? int.tryParse(stringArg('resource-pool-size'))
: null,
......
......@@ -20,6 +20,7 @@ import 'base/os.dart';
import 'base/template.dart';
import 'base/terminal.dart';
import 'base/user_messages.dart';
import 'build_system/build_system.dart';
import 'cache.dart';
import 'fuchsia/fuchsia_sdk.dart';
import 'ios/ios_deploy.dart';
......@@ -34,6 +35,7 @@ import 'version.dart';
import 'web/chrome.dart';
Artifacts get artifacts => context.get<Artifacts>();
BuildSystem get buildSystem => context.get<BuildSystem>();
Cache get cache => context.get<Cache>();
Config get config => context.get<Config>();
Logger get logger => context.get<Logger>();
......
......@@ -38,7 +38,7 @@ Future<void> buildWeb(
final Status status = globals.logger.startProgress('Compiling $target for the Web...', timeout: null);
final Stopwatch sw = Stopwatch()..start();
try {
final BuildResult result = await buildSystem.build(const WebServiceWorker(), Environment.test(
final BuildResult result = await globals.buildSystem.build(const WebServiceWorker(), Environment.test(
globals.fs.currentDirectory,
outputDir: globals.fs.directory(getWebBuildDirectory()),
buildDir: flutterProject.directory
......
......@@ -24,7 +24,7 @@ void main() {
});
testbed.test('Can run a build', () async {
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
when(globals.buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
return BuildResult(success: true);
});
......@@ -35,7 +35,7 @@ void main() {
});
testbed.test('Can parse defines whose values contain =', () async {
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
when(globals.buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
expect((invocation.positionalArguments[1] as Environment).defines, containsPair('FooBar', 'fizz=2'));
return BuildResult(success: true);
......@@ -47,7 +47,7 @@ void main() {
});
testbed.test('Throws ToolExit if not provided with output', () async {
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
when(globals.buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
return BuildResult(success: true);
});
......@@ -58,7 +58,7 @@ void main() {
});
testbed.test('Throws ToolExit if called with non-existent rule', () async {
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
when(globals.buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
return BuildResult(success: true);
});
......@@ -70,7 +70,7 @@ void main() {
testbed.test('Does not log stack traces during build failure', () async {
final StackTrace testStackTrace = StackTrace.current;
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
when(globals.buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
return BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
'hello': ExceptionMeasurement('hello', 'bar', testStackTrace),
......@@ -85,7 +85,7 @@ void main() {
});
testbed.test('Only writes input and output files when the values change', () async {
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
when(globals.buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
return BuildResult(
success: true,
......@@ -122,7 +122,7 @@ void main() {
expect(inputs.lastModifiedSync(), theDistantPast);
expect(outputs.lastModifiedSync(), theDistantPast);
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
when(globals.buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
return BuildResult(
success: true,
......
......@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/commands/build_web.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/build_runner/resident_web_runner.dart';
import 'package:flutter_tools/src/web/compile.dart';
......@@ -169,7 +170,7 @@ class UrlLauncherPlugin {}
// Process calls. We're not testing that these invocations are correct because
// that is covered in targets/web_test.dart.
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
when(globals.buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
return BuildResult(success: true);
});
await runner.run(<String>['build', 'web']);
......
......@@ -212,7 +212,7 @@ void main() {
globals.fs.file('pubspec.yaml').createSync();
globals.fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand());
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
when(globals.buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
final Environment environment = invocation.positionalArguments[1] as Environment;
expect(environment.defines, <String, String>{
kTargetFile: globals.fs.path.join('lib', 'main.dart'),
......
......@@ -23,7 +23,7 @@ void main() {
});
test('Copies assets to expected directory after building', () => testbed.run(() async {
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
when(globals.buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
final Environment environment = invocation.positionalArguments[1] as Environment;
environment.outputDir.childFile('kernel_blob.bin').createSync(recursive: true);
environment.outputDir.childFile('isolate_snapshot_data').createSync();
......@@ -47,7 +47,7 @@ void main() {
}));
test('Handles build system failure', () => testbed.run(() {
when(buildSystem.build(any, any)).thenAnswer((Invocation _) async {
when(globals.buildSystem.build(any, any)).thenAnswer((Invocation _) async {
return BuildResult(
success: false,
exceptions: <String, ExceptionMeasurement>{},
......
......@@ -111,7 +111,7 @@ void main() {
testUsingContext('build aot outputs timing info', () async {
globals.fs.file('.dart_tool/flutter_build/cce09742720db17ffec62331bd7e42d5/app.so')
.createSync(recursive: true);
when(buildSystem.build(any, any))
when(globals.buildSystem.build(any, any))
.thenAnswer((Invocation invocation) async {
return BuildResult(success: true, performance: <String, PerformanceMeasurement>{
'kernel_snapshot': PerformanceMeasurement(
......
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