Expose extra frontend options through build apk/ios/macOS (#53273)
This will allow experimenting with the remove to string transformer before we're ready to turn it on by default. This doesn't work for web yet since we use dart2js instead of the frontend_server for producing kernel
This commit is contained in:
@@ -130,6 +130,68 @@ void main() {
|
||||
expect(processManager.hasRemainingExpectations, false);
|
||||
}));
|
||||
|
||||
test('KernelSnapshot correctly handles an empty string in ExtraFrontEndOptions', () => testbed.run(() async {
|
||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
||||
final String build = androidEnvironment.buildDir.path;
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
|
||||
'--sdk-root',
|
||||
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/',
|
||||
'--target=flutter',
|
||||
'-Ddart.developer.causal_async_stacks=false',
|
||||
...buildModeOptions(BuildMode.profile),
|
||||
'--aot',
|
||||
'--tfa',
|
||||
'--packages',
|
||||
'/.packages',
|
||||
'--output-dill',
|
||||
'$build/app.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'/lib/main.dart',
|
||||
], stdout: 'result $kBoundaryKey\n$kBoundaryKey\n$kBoundaryKey $build/app.dill 0\n'),
|
||||
]);
|
||||
|
||||
await const KernelSnapshot()
|
||||
.build(androidEnvironment..defines[kExtraFrontEndOptions] = '');
|
||||
|
||||
expect(processManager.hasRemainingExpectations, false);
|
||||
}));
|
||||
|
||||
test('KernelSnapshot correctly forwards ExtraFrontEndOptions', () => testbed.run(() async {
|
||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
||||
final String build = androidEnvironment.buildDir.path;
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
|
||||
'--sdk-root',
|
||||
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/',
|
||||
'--target=flutter',
|
||||
'-Ddart.developer.causal_async_stacks=false',
|
||||
...buildModeOptions(BuildMode.profile),
|
||||
'--aot',
|
||||
'--tfa',
|
||||
'--packages',
|
||||
'/.packages',
|
||||
'--output-dill',
|
||||
'$build/app.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'foo',
|
||||
'bar',
|
||||
'/lib/main.dart',
|
||||
], stdout: 'result $kBoundaryKey\n$kBoundaryKey\n$kBoundaryKey $build/app.dill 0\n'),
|
||||
]);
|
||||
|
||||
await const KernelSnapshot()
|
||||
.build(androidEnvironment..defines[kExtraFrontEndOptions] = 'foo,bar');
|
||||
|
||||
expect(processManager.hasRemainingExpectations, false);
|
||||
}));
|
||||
|
||||
test('KernelSnapshot can disable track-widget-creation on debug builds', () => testbed.run(() async {
|
||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
||||
final String build = androidEnvironment.buildDir.path;
|
||||
|
||||
@@ -279,6 +279,38 @@ void main() {
|
||||
ProcessManager: () => mockProcessManager,
|
||||
});
|
||||
|
||||
testUsingContext('--extra-front-end-options are provided to gradle project', () async {
|
||||
final String projectPath = await createProject(tempDir,
|
||||
arguments: <String>['--no-pub', '--template=app']);
|
||||
|
||||
await expectLater(() async {
|
||||
await runBuildApkCommand(projectPath, arguments: <String>[
|
||||
'--extra-front-end-options=foo',
|
||||
'--extra-front-end-options=bar',
|
||||
]);
|
||||
}, throwsToolExit(message: 'Gradle task assembleRelease failed with exit code 1'));
|
||||
|
||||
verify(mockProcessManager.start(
|
||||
<String>[
|
||||
gradlew,
|
||||
'-q',
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pextra-front-end-options=foo,bar',
|
||||
'-Pshrink=true',
|
||||
'assembleRelease',
|
||||
],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
|
||||
ProcessManager: () => mockProcessManager,
|
||||
});
|
||||
|
||||
testUsingContext('shrinking is disabled when --no-shrink is passed', () async {
|
||||
final String projectPath = await createProject(tempDir,
|
||||
arguments: <String>['--no-pub', '--template=app']);
|
||||
|
||||
Reference in New Issue
Block a user