Extract kernel compile from buildAotSnapshot (#17062)
Moves the kernel compile step to the beginning of the AOT build in a
separate method. This is pre-factoring for iOS universal builds where
the kernel build happens once, but we then snapshot twice: once for
armv7 and once for arm64.
This also writes dependencies to build/kernel_compile.d rather than
build/aot/snapshot.d, since that is immediately overwritten by
gen_snapshot.
diff --git a/packages/flutter_tools/test/base/build_test.dart b/packages/flutter_tools/test/base/build_test.dart
index 294e485..ca5e764 100644
--- a/packages/flutter_tools/test/base/build_test.dart
+++ b/packages/flutter_tools/test/base/build_test.dart
@@ -9,7 +9,6 @@
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/build_info.dart';
-import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/base/build.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
@@ -70,29 +69,6 @@
}
}
-class _FakeKernelCompiler implements KernelCompiler {
- CompilerOutput output;
-
- @override
- Future<CompilerOutput> compile({
- String sdkRoot,
- String mainPath,
- String outputFilePath,
- String depFilePath,
- bool linkPlatformKernelIn: false,
- bool aot: false,
- List<String> entryPointsJsonFiles,
- bool trackWidgetCreation: false,
- List<String> extraFrontEndOptions,
- String incrementalCompilerByteStorePath,
- String packagesPath,
- List<String> fileSystemRoots,
- String fileSystemScheme,
- }) async {
- return output;
- }
-}
-
void main() {
group('SnapshotType', () {
test('throws, if build mode is null', () {
@@ -606,7 +582,6 @@
String skyEnginePath;
_FakeGenSnapshot genSnapshot;
- _FakeKernelCompiler kernelCompiler;
MemoryFileSystem fs;
Snapshotter snapshotter;
MockArtifacts mockArtifacts;
@@ -630,7 +605,6 @@
fs.file(fs.path.join(skyEnginePath, 'sdk_ext', 'vmservice_io.dart')).createSync();
genSnapshot = new _FakeGenSnapshot();
- kernelCompiler = new _FakeKernelCompiler();
snapshotter = new Snapshotter();
mockArtifacts = new MockArtifacts();
mockXcode = new MockXcode();
@@ -648,18 +622,16 @@
Artifacts: () => mockArtifacts,
FileSystem: () => fs,
GenSnapshot: () => genSnapshot,
- KernelCompiler: () => kernelCompiler,
Xcode: () => mockXcode,
Xxd: () => mockXxd,
};
testUsingContext('builds iOS debug AOT snapshot', () async {
- fs.file('main.dart').writeAsStringSync('void main() {}');
+ fs.file('main.dill').writeAsStringSync('binary magic');
final String outputPath = fs.path.join('build', 'foo');
fs.directory(outputPath).createSync(recursive: true);
- kernelCompiler.output = const CompilerOutput('main.dill', 0);
genSnapshot.outputs = <String, String>{
fs.path.join(outputPath, 'vm_snapshot_data'): '',
fs.path.join(outputPath, 'vm_snapshot_instr'): '',
@@ -672,7 +644,7 @@
final int genSnapshotExitCode = await snapshotter.buildAotSnapshot(
platform: TargetPlatform.ios,
buildMode: BuildMode.debug,
- mainPath: 'main.dart',
+ mainPath: 'main.dill',
packagesPath: '.packages',
outputPath: outputPath,
preferSharedLibrary: false,
@@ -701,12 +673,11 @@
}, overrides: contextOverrides);
testUsingContext('builds iOS profile AOT snapshot', () async {
- fs.file('main.dart').writeAsStringSync('void main() {}');
+ fs.file('main.dill').writeAsStringSync('binary magic');
final String outputPath = fs.path.join('build', 'foo');
fs.directory(outputPath).createSync(recursive: true);
- kernelCompiler.output = const CompilerOutput('main.dill', 0);
genSnapshot.outputs = <String, String>{
fs.path.join(outputPath, 'snapshot_assembly.S'): '',
fs.path.join(outputPath, 'snapshot.d'): '',
@@ -715,7 +686,7 @@
final int genSnapshotExitCode = await snapshotter.buildAotSnapshot(
platform: TargetPlatform.ios,
buildMode: BuildMode.profile,
- mainPath: 'main.dart',
+ mainPath: 'main.dill',
packagesPath: '.packages',
outputPath: outputPath,
preferSharedLibrary: false,
@@ -746,12 +717,11 @@
}, overrides: contextOverrides);
testUsingContext('builds iOS release AOT snapshot', () async {
- fs.file('main.dart').writeAsStringSync('void main() {}');
+ fs.file('main.dill').writeAsStringSync('binary magic');
final String outputPath = fs.path.join('build', 'foo');
fs.directory(outputPath).createSync(recursive: true);
- kernelCompiler.output = const CompilerOutput('main.dill', 0);
genSnapshot.outputs = <String, String>{
fs.path.join(outputPath, 'snapshot_assembly.S'): '',
fs.path.join(outputPath, 'snapshot.d'): '',
@@ -760,7 +730,7 @@
final int genSnapshotExitCode = await snapshotter.buildAotSnapshot(
platform: TargetPlatform.ios,
buildMode: BuildMode.release,
- mainPath: 'main.dart',
+ mainPath: 'main.dill',
packagesPath: '.packages',
outputPath: outputPath,
preferSharedLibrary: false,