Unverified Commit d081364d authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove indirection around App.framework production (#53853)

parent 7ceed973
......@@ -4,11 +4,11 @@
import 'dart:async';
import '../aot.dart';
import '../bundle.dart';
import '../commands/build_linux.dart';
import '../commands/build_macos.dart';
import '../commands/build_windows.dart';
import '../globals.dart' as globals;
import '../runner/flutter_command.dart';
import 'build_aar.dart';
import 'build_aot.dart';
......@@ -28,7 +28,7 @@ class BuildCommand extends FlutterCommand {
addSubcommand(BuildAotCommand());
addSubcommand(BuildIOSCommand());
addSubcommand(BuildIOSFrameworkCommand(
aotBuilder: AotBuilder(),
buildSystem: globals.buildSystem,
bundleBuilder: BundleBuilder(),
));
addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp));
......
......@@ -8,7 +8,6 @@ import 'package:file/file.dart';
import 'package:meta/meta.dart';
import 'package:platform/platform.dart';
import '../aot.dart';
import '../artifacts.dart';
import '../base/common.dart';
import '../base/file_system.dart';
......@@ -16,9 +15,13 @@ import '../base/logger.dart';
import '../base/process.dart';
import '../base/utils.dart';
import '../build_info.dart';
import '../build_system/build_system.dart';
import '../build_system/targets/dart.dart';
import '../build_system/targets/icon_tree_shaker.dart';
import '../build_system/targets/ios.dart';
import '../bundle.dart';
import '../cache.dart';
import '../convert.dart';
import '../globals.dart' as globals;
import '../macos/cocoapod_utils.dart';
import '../macos/xcode.dart';
......@@ -35,12 +38,12 @@ import 'build.dart';
class BuildIOSFrameworkCommand extends BuildSubCommand {
BuildIOSFrameworkCommand({
FlutterVersion flutterVersion, // Instantiating FlutterVersion kicks off networking, so delay until it's needed, but allow test injection.
@required AotBuilder aotBuilder,
@required BundleBuilder bundleBuilder,
@required BuildSystem buildSystem,
Cache cache,
Platform platform
}) : _flutterVersion = flutterVersion,
_aotBuilder = aotBuilder,
_buildSystem = buildSystem,
_bundleBuilder = bundleBuilder,
_injectedCache = cache,
_injectedPlatform = platform {
......@@ -95,8 +98,9 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
);
}
final AotBuilder _aotBuilder;
final BundleBuilder _bundleBuilder;
final BuildSystem _buildSystem;
BuildSystem get buildSystem => _buildSystem ?? globals.buildSystem;
Cache get _cache => _injectedCache ?? globals.cache;
final Cache _injectedCache;
......@@ -367,15 +371,17 @@ end
final Status status = globals.logger.startProgress(
' ├─Assembling Flutter resources for App.framework...', timeout: timeoutConfiguration.slowOperation);
try {
if (buildInfo.mode == BuildMode.debug) {
await _bundleBuilder.build(
platform: TargetPlatform.ios,
buildInfo: buildInfo,
// Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
mainPath: globals.fs.path.absolute(targetFile),
assetDirPath: destinationAppFrameworkDirectory.childDirectory('flutter_assets').path,
precompiledSnapshot: buildInfo.mode != BuildMode.debug,
treeShakeIcons: boolArg('tree-shake-icons')
);
platform: TargetPlatform.ios,
buildInfo: buildInfo,
// Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
mainPath: globals.fs.path.absolute(targetFile),
assetDirPath: destinationAppFrameworkDirectory.childDirectory('flutter_assets').path,
precompiledSnapshot: buildInfo.mode != BuildMode.debug,
treeShakeIcons: boolArg('tree-shake-icons')
);
}
} finally {
status.stop();
}
......@@ -429,16 +435,41 @@ end
timeout: timeoutConfiguration.slowOperation,
);
try {
await _aotBuilder.build(
platform: TargetPlatform.ios,
outputPath: destinationDirectory.path,
buildInfo: buildInfo,
// Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
mainDartFile: globals.fs.path.absolute(targetFile),
quiet: true,
bitcode: true,
iosBuildArchs: <DarwinArch>[DarwinArch.armv7, DarwinArch.arm64],
final Target target = buildInfo.isRelease
? const ReleaseIosApplicationBundle()
: const ProfileIosApplicationBundle();
final Environment environment = Environment(
projectDir: globals.fs.currentDirectory,
outputDir: destinationDirectory,
buildDir: _project.dartTool.childDirectory('flutter_build'),
cacheDir: null,
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
defines: <String, String>{
kTargetFile: targetFile,
kBuildMode: getNameForBuildMode(buildInfo.mode),
kTargetPlatform: getNameForTargetPlatform(TargetPlatform.ios),
kIconTreeShakerFlag: buildInfo.treeShakeIcons.toString(),
kDartDefines: jsonEncode(buildInfo.dartDefines),
kBitcodeFlag: 'true',
if (buildInfo?.extraGenSnapshotOptions?.isNotEmpty ?? false)
kExtraGenSnapshotOptions: buildInfo.extraGenSnapshotOptions.join(','),
if (buildInfo?.extraFrontEndOptions?.isNotEmpty ?? false)
kExtraFrontEndOptions: buildInfo.extraFrontEndOptions.join(','),
kIosArchs: <DarwinArch>[DarwinArch.armv7, DarwinArch.arm64]
.map(getNameForDarwinArch).join(' '),
},
artifacts: globals.artifacts,
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
);
final BuildResult result = await buildSystem.build(target, environment);
if (!result.success) {
for (final ExceptionMeasurement measurement in result.exceptions.values) {
globals.printError(measurement.exception.toString());
}
throwToolExit('The aot build failed.');
}
} finally {
status.stop();
}
......
......@@ -5,8 +5,8 @@
import 'dart:io';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/aot.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/bundle.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_ios_framework.dart';
......@@ -64,7 +64,7 @@ void main() {
when(mockFlutterVersion.frameworkVersion).thenReturn(frameworkVersion);
final BuildIOSFrameworkCommand command = BuildIOSFrameworkCommand(
aotBuilder: MockAotBuilder(),
buildSystem: MockBuildSystem(),
bundleBuilder: MockBundleBuilder(),
platform: fakePlatform,
flutterVersion: mockFlutterVersion,
......@@ -89,7 +89,7 @@ void main() {
when(mockGitTagVersion.commits).thenReturn(2);
final BuildIOSFrameworkCommand command = BuildIOSFrameworkCommand(
aotBuilder: MockAotBuilder(),
buildSystem: MockBuildSystem(),
bundleBuilder: MockBundleBuilder(),
platform: fakePlatform,
flutterVersion: mockFlutterVersion,
......@@ -111,7 +111,7 @@ void main() {
when(mockGitTagVersion.commits).thenReturn(0);
final BuildIOSFrameworkCommand command = BuildIOSFrameworkCommand(
aotBuilder: MockAotBuilder(),
buildSystem: MockBuildSystem(),
bundleBuilder: MockBundleBuilder(),
platform: fakePlatform,
flutterVersion: mockFlutterVersion,
......@@ -149,7 +149,7 @@ void main() {
testUsingContext('created when forced', () async {
final BuildIOSFrameworkCommand command = BuildIOSFrameworkCommand(
aotBuilder: MockAotBuilder(),
buildSystem: MockBuildSystem(),
bundleBuilder: MockBundleBuilder(),
platform: fakePlatform,
flutterVersion: mockFlutterVersion,
......@@ -172,7 +172,7 @@ void main() {
testUsingContext('contains license and version', () async {
final BuildIOSFrameworkCommand command = BuildIOSFrameworkCommand(
aotBuilder: MockAotBuilder(),
buildSystem: MockBuildSystem(),
bundleBuilder: MockBundleBuilder(),
platform: fakePlatform,
flutterVersion: mockFlutterVersion,
......@@ -192,7 +192,7 @@ void main() {
testUsingContext('debug URL', () async {
final BuildIOSFrameworkCommand command = BuildIOSFrameworkCommand(
aotBuilder: MockAotBuilder(),
buildSystem: MockBuildSystem(),
bundleBuilder: MockBundleBuilder(),
platform: fakePlatform,
flutterVersion: mockFlutterVersion,
......@@ -210,7 +210,7 @@ void main() {
testUsingContext('profile URL', () async {
final BuildIOSFrameworkCommand command = BuildIOSFrameworkCommand(
aotBuilder: MockAotBuilder(),
buildSystem: MockBuildSystem(),
bundleBuilder: MockBundleBuilder(),
platform: fakePlatform,
flutterVersion: mockFlutterVersion,
......@@ -228,7 +228,7 @@ void main() {
testUsingContext('release URL', () async {
final BuildIOSFrameworkCommand command = BuildIOSFrameworkCommand(
aotBuilder: MockAotBuilder(),
buildSystem: MockBuildSystem(),
bundleBuilder: MockBundleBuilder(),
platform: fakePlatform,
flutterVersion: mockFlutterVersion,
......@@ -252,5 +252,5 @@ void main() {
class MockFlutterVersion extends Mock implements FlutterVersion {}
class MockGitTagVersion extends Mock implements GitTagVersion {}
class MockCache extends Mock implements Cache {}
class MockAotBuilder extends Mock implements AotBuilder {}
class MockBuildSystem extends Mock implements BuildSystem {}
class MockBundleBuilder extends Mock implements BundleBuilder {}
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