Unverified Commit b7773da3 authored by Ryan Macnak's avatar Ryan Macnak Committed by GitHub

Pass build mode-specific bytecode generation options to frontend_server. (#42471)

Fixes various Flutter framework test failures when bytecode is enabled.
parent 163be41d
...@@ -12,6 +12,7 @@ import 'package:flutter_tools/src/base/context.dart'; ...@@ -12,6 +12,7 @@ import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart'; import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/dart/package_map.dart'; import 'package:flutter_tools/src/dart/package_map.dart';
...@@ -146,6 +147,7 @@ Future<void> run(List<String> args) async { ...@@ -146,6 +147,7 @@ Future<void> run(List<String> args) async {
watcher: collector, watcher: collector,
ipv6: false, ipv6: false,
enableObservatory: collector != null, enableObservatory: collector != null,
buildMode: BuildMode.debug,
precompiledDillFiles: tests, precompiledDillFiles: tests,
concurrency: math.max(1, platform.numberOfProcessors - 2), concurrency: math.max(1, platform.numberOfProcessors - 2),
icudtlPath: fs.path.absolute(argResults[_kOptionIcudtl]), icudtlPath: fs.path.absolute(argResults[_kOptionIcudtl]),
......
...@@ -308,9 +308,8 @@ class AOTSnapshotter { ...@@ -308,9 +308,8 @@ class AOTSnapshotter {
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
linkPlatformKernelIn: true, linkPlatformKernelIn: true,
aot: true, aot: true,
enableAsserts: buildMode == BuildMode.debug, buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
targetProductVm: buildMode == BuildMode.release,
)); ));
// Write path to frontend_server, since things need to be re-generated when that changes. // Write path to frontend_server, since things need to be re-generated when that changes.
......
...@@ -139,7 +139,6 @@ class BuildRunner extends CodeGenerator { ...@@ -139,7 +139,6 @@ class BuildRunner extends CodeGenerator {
FlutterProject flutterProject, { FlutterProject flutterProject, {
String mainPath, String mainPath,
bool linkPlatformKernelIn = false, bool linkPlatformKernelIn = false,
bool targetProductVm = false,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
List<String> extraFrontEndOptions = const <String> [], List<String> extraFrontEndOptions = const <String> [],
}) async { }) async {
......
...@@ -212,10 +212,9 @@ class KernelSnapshot extends Target { ...@@ -212,10 +212,9 @@ class KernelSnapshot extends Target {
final CompilerOutput output = await compiler.compile( final CompilerOutput output = await compiler.compile(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
aot: buildMode != BuildMode.debug, aot: buildMode != BuildMode.debug,
enableAsserts: buildMode == BuildMode.debug, buildMode: buildMode,
trackWidgetCreation: buildMode == BuildMode.debug, trackWidgetCreation: buildMode == BuildMode.debug,
targetModel: TargetModel.flutter, targetModel: TargetModel.flutter,
targetProductVm: buildMode == BuildMode.release,
outputFilePath: environment.buildDir.childFile('app.dill').path, outputFilePath: environment.buildDir.childFile('app.dill').path,
packagesPath: packagesPath, packagesPath: packagesPath,
linkPlatformKernelIn: buildMode == BuildMode.release, linkPlatformKernelIn: buildMode == BuildMode.release,
......
...@@ -106,7 +106,7 @@ class BundleBuilder { ...@@ -106,7 +106,7 @@ class BundleBuilder {
mainPath: fs.file(mainPath).absolute.path, mainPath: fs.file(mainPath).absolute.path,
outputFilePath: applicationKernelFilePath, outputFilePath: applicationKernelFilePath,
depFilePath: depfilePath, depFilePath: depfilePath,
enableAsserts: buildMode == BuildMode.debug, buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
fileSystemRoots: fileSystemRoots, fileSystemRoots: fileSystemRoots,
......
...@@ -8,6 +8,7 @@ import 'artifacts.dart'; ...@@ -8,6 +8,7 @@ import 'artifacts.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/platform.dart'; import 'base/platform.dart';
import 'build_info.dart';
import 'compile.dart'; import 'compile.dart';
import 'dart/package_map.dart'; import 'dart/package_map.dart';
import 'globals.dart'; import 'globals.dart';
...@@ -95,11 +96,10 @@ class CodeGeneratingKernelCompiler implements KernelCompiler { ...@@ -95,11 +96,10 @@ class CodeGeneratingKernelCompiler implements KernelCompiler {
String outputFilePath, String outputFilePath,
bool linkPlatformKernelIn = false, bool linkPlatformKernelIn = false,
bool aot = false, bool aot = false,
bool enableAsserts = false, @required BuildMode buildMode,
bool causalAsyncStacks = true, bool causalAsyncStacks = true,
bool trackWidgetCreation, bool trackWidgetCreation,
List<String> extraFrontEndOptions, List<String> extraFrontEndOptions,
bool targetProductVm = false,
// These arguments are currently unused. // These arguments are currently unused.
String sdkRoot, String sdkRoot,
String packagesPath, String packagesPath,
...@@ -133,11 +133,10 @@ class CodeGeneratingKernelCompiler implements KernelCompiler { ...@@ -133,11 +133,10 @@ class CodeGeneratingKernelCompiler implements KernelCompiler {
outputFilePath: outputFilePath, outputFilePath: outputFilePath,
linkPlatformKernelIn: linkPlatformKernelIn, linkPlatformKernelIn: linkPlatformKernelIn,
aot: aot, aot: aot,
enableAsserts: enableAsserts, buildMode: buildMode,
causalAsyncStacks: causalAsyncStacks, causalAsyncStacks: causalAsyncStacks,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
targetProductVm: targetProductVm,
sdkRoot: sdkRoot, sdkRoot: sdkRoot,
packagesPath: PackageMap.globalGeneratedPackagesPath, packagesPath: PackageMap.globalGeneratedPackagesPath,
fileSystemRoots: <String>[ fileSystemRoots: <String>[
...@@ -165,7 +164,7 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler { ...@@ -165,7 +164,7 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler {
/// codegen mode. /// codegen mode.
static Future<ResidentCompiler> create({ static Future<ResidentCompiler> create({
@required FlutterProject flutterProject, @required FlutterProject flutterProject,
bool enableAsserts = false, @required BuildMode buildMode,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
CompilerMessageConsumer compilerMessageConsumer = printError, CompilerMessageConsumer compilerMessageConsumer = printError,
bool unsafePackageSerialization = false, bool unsafePackageSerialization = false,
...@@ -176,7 +175,7 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler { ...@@ -176,7 +175,7 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler {
codeGenerator.updatePackages(flutterProject); codeGenerator.updatePackages(flutterProject);
final ResidentCompiler residentCompiler = ResidentCompiler( final ResidentCompiler residentCompiler = ResidentCompiler(
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
enableAsserts: enableAsserts, buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
packagesPath: PackageMap.globalGeneratedPackagesPath, packagesPath: PackageMap.globalGeneratedPackagesPath,
fileSystemRoots: <String>[ fileSystemRoots: <String>[
......
...@@ -9,6 +9,7 @@ import '../asset.dart'; ...@@ -9,6 +9,7 @@ import '../asset.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../build_info.dart';
import '../bundle.dart'; import '../bundle.dart';
import '../cache.dart'; import '../cache.dart';
import '../codegen.dart'; import '../codegen.dart';
...@@ -234,7 +235,7 @@ class TestCommand extends FastFlutterCommand { ...@@ -234,7 +235,7 @@ class TestCommand extends FastFlutterCommand {
disableServiceAuthCodes: disableServiceAuthCodes, disableServiceAuthCodes: disableServiceAuthCodes,
ipv6: argResults['ipv6'], ipv6: argResults['ipv6'],
machine: machine, machine: machine,
enableAsserts: true, buildMode: BuildMode.debug,
trackWidgetCreation: argResults['track-widget-creation'], trackWidgetCreation: argResults['track-widget-creation'],
updateGoldens: argResults['update-goldens'], updateGoldens: argResults['update-goldens'],
concurrency: jobs, concurrency: jobs,
......
...@@ -15,6 +15,7 @@ import 'base/io.dart'; ...@@ -15,6 +15,7 @@ import 'base/io.dart';
import 'base/platform.dart'; import 'base/platform.dart';
import 'base/process_manager.dart'; import 'base/process_manager.dart';
import 'base/terminal.dart'; import 'base/terminal.dart';
import 'build_info.dart';
import 'codegen.dart'; import 'codegen.dart';
import 'convert.dart'; import 'convert.dart';
import 'dart/package_map.dart'; import 'dart/package_map.dart';
...@@ -238,6 +239,31 @@ class PackageUriMapper { ...@@ -238,6 +239,31 @@ class PackageUriMapper {
} }
} }
List<String> _buildModeOptions(BuildMode mode) {
switch (mode) {
case BuildMode.debug:
return <String>[
'-Ddart.vm.profile=false',
'-Ddart.vm.product=false',
'--bytecode-options=source-positions,local-var-info,debugger-stops,instance-field-initializers,keep-unreachable-code,avoid-closure-call-instructions',
'--enable-asserts',
];
case BuildMode.profile:
return <String>[
'-Ddart.vm.profile=true',
'-Ddart.vm.product=false',
'--bytecode-options=source-positions',
];
case BuildMode.release:
return <String>[
'-Ddart.vm.profile=false',
'-Ddart.vm.product=true',
'--bytecode-options=source-positions',
];
}
throw Exception('Unknown BuildMode: $mode');
}
class KernelCompiler { class KernelCompiler {
const KernelCompiler(); const KernelCompiler();
...@@ -247,16 +273,15 @@ class KernelCompiler { ...@@ -247,16 +273,15 @@ class KernelCompiler {
String outputFilePath, String outputFilePath,
String depFilePath, String depFilePath,
TargetModel targetModel = TargetModel.flutter, TargetModel targetModel = TargetModel.flutter,
@required BuildMode buildMode,
bool linkPlatformKernelIn = false, bool linkPlatformKernelIn = false,
bool aot = false, bool aot = false,
bool enableAsserts = false,
bool causalAsyncStacks = true, bool causalAsyncStacks = true,
@required bool trackWidgetCreation, @required bool trackWidgetCreation,
List<String> extraFrontEndOptions, List<String> extraFrontEndOptions,
String packagesPath, String packagesPath,
List<String> fileSystemRoots, List<String> fileSystemRoots,
String fileSystemScheme, String fileSystemScheme,
bool targetProductVm = false,
String initializeFromDill, String initializeFromDill,
String platformDill, String platformDill,
}) async { }) async {
...@@ -288,19 +313,13 @@ class KernelCompiler { ...@@ -288,19 +313,13 @@ class KernelCompiler {
'--strong', '--strong',
'--target=$targetModel', '--target=$targetModel',
'-Ddart.developer.causal_async_stacks=$causalAsyncStacks', '-Ddart.developer.causal_async_stacks=$causalAsyncStacks',
if (enableAsserts) '--enable-asserts', ..._buildModeOptions(buildMode),
if (trackWidgetCreation) '--track-widget-creation', if (trackWidgetCreation) '--track-widget-creation',
if (!linkPlatformKernelIn) '--no-link-platform', if (!linkPlatformKernelIn) '--no-link-platform',
if (aot) ...<String>[ if (aot) ...<String>[
'--aot', '--aot',
'--tfa', '--tfa',
], ],
// If we're not targeting product (release) mode and we're still aot, then
// target profile mode.
if (targetProductVm)
'-Ddart.vm.product=true'
else if (aot)
'-Ddart.vm.profile=true',
if (packagesPath != null) ...<String>[ if (packagesPath != null) ...<String>[
'--packages', '--packages',
packagesPath, packagesPath,
...@@ -429,7 +448,7 @@ class _RejectRequest extends _CompilationRequest { ...@@ -429,7 +448,7 @@ class _RejectRequest extends _CompilationRequest {
class ResidentCompiler { class ResidentCompiler {
ResidentCompiler( ResidentCompiler(
this._sdkRoot, { this._sdkRoot, {
bool enableAsserts = false, @required BuildMode buildMode,
bool causalAsyncStacks = true, bool causalAsyncStacks = true,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
String packagesPath, String packagesPath,
...@@ -441,7 +460,7 @@ class ResidentCompiler { ...@@ -441,7 +460,7 @@ class ResidentCompiler {
bool unsafePackageSerialization, bool unsafePackageSerialization,
List<String> experimentalFlags, List<String> experimentalFlags,
}) : assert(_sdkRoot != null), }) : assert(_sdkRoot != null),
_enableAsserts = enableAsserts, _buildMode = buildMode,
_causalAsyncStacks = causalAsyncStacks, _causalAsyncStacks = causalAsyncStacks,
_trackWidgetCreation = trackWidgetCreation, _trackWidgetCreation = trackWidgetCreation,
_packagesPath = packagesPath, _packagesPath = packagesPath,
...@@ -459,7 +478,7 @@ class ResidentCompiler { ...@@ -459,7 +478,7 @@ class ResidentCompiler {
} }
} }
final bool _enableAsserts; final BuildMode _buildMode;
final bool _causalAsyncStacks; final bool _causalAsyncStacks;
final bool _trackWidgetCreation; final bool _trackWidgetCreation;
final String _packagesPath; final String _packagesPath;
...@@ -586,7 +605,7 @@ class ResidentCompiler { ...@@ -586,7 +605,7 @@ class ResidentCompiler {
'--packages', '--packages',
_packagesPath, _packagesPath,
], ],
if (_enableAsserts) '--enable-asserts', ..._buildModeOptions(_buildMode),
if (_trackWidgetCreation) '--track-widget-creation', if (_trackWidgetCreation) '--track-widget-creation',
if (_fileSystemRoots != null) if (_fileSystemRoots != null)
for (String root in _fileSystemRoots) ...<String>[ for (String root in _fileSystemRoots) ...<String>[
......
...@@ -453,6 +453,7 @@ class IOSSimulator extends Device { ...@@ -453,6 +453,7 @@ class IOSSimulator extends Device {
return BundleBuilder().build( return BundleBuilder().build(
mainPath: mainPath, mainPath: mainPath,
precompiledSnapshot: false, precompiledSnapshot: false,
buildMode: buildInfo.mode,
trackWidgetCreation: buildInfo.trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
); );
} }
......
...@@ -42,7 +42,7 @@ class FlutterDevice { ...@@ -42,7 +42,7 @@ class FlutterDevice {
}) : assert(trackWidgetCreation != null), }) : assert(trackWidgetCreation != null),
generator = generator ?? ResidentCompiler( generator = generator ?? ResidentCompiler(
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
enableAsserts: buildMode == BuildMode.debug, buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
fileSystemRoots: fileSystemRoots, fileSystemRoots: fileSystemRoots,
fileSystemScheme: fileSystemScheme, fileSystemScheme: fileSystemScheme,
...@@ -67,11 +67,13 @@ class FlutterDevice { ...@@ -67,11 +67,13 @@ class FlutterDevice {
ResidentCompiler generator; ResidentCompiler generator;
if (flutterProject.hasBuilders) { if (flutterProject.hasBuilders) {
generator = await CodeGeneratingResidentCompiler.create( generator = await CodeGeneratingResidentCompiler.create(
buildMode: buildMode,
flutterProject: flutterProject, flutterProject: flutterProject,
); );
} else { } else {
generator = ResidentCompiler( generator = ResidentCompiler(
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
fileSystemRoots: fileSystemRoots, fileSystemRoots: fileSystemRoots,
fileSystemScheme: fileSystemScheme, fileSystemScheme: fileSystemScheme,
......
...@@ -21,6 +21,7 @@ import '../base/file_system.dart'; ...@@ -21,6 +21,7 @@ import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../build_info.dart';
import '../compile.dart'; import '../compile.dart';
import '../convert.dart'; import '../convert.dart';
import '../dart/package_map.dart'; import '../dart/package_map.dart';
...@@ -86,7 +87,7 @@ FlutterPlatform installHook({ ...@@ -86,7 +87,7 @@ FlutterPlatform installHook({
int port = 0, int port = 0,
String precompiledDillPath, String precompiledDillPath,
Map<String, String> precompiledDillFiles, Map<String, String> precompiledDillFiles,
bool enableAsserts = false, @required BuildMode buildMode,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
bool updateGoldens = false, bool updateGoldens = false,
bool buildTestAssets = false, bool buildTestAssets = false,
...@@ -120,7 +121,7 @@ FlutterPlatform installHook({ ...@@ -120,7 +121,7 @@ FlutterPlatform installHook({
port: port, port: port,
precompiledDillPath: precompiledDillPath, precompiledDillPath: precompiledDillPath,
precompiledDillFiles: precompiledDillFiles, precompiledDillFiles: precompiledDillFiles,
enableAsserts: enableAsserts, buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
buildTestAssets: buildTestAssets, buildTestAssets: buildTestAssets,
...@@ -260,7 +261,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -260,7 +261,7 @@ class FlutterPlatform extends PlatformPlugin {
this.port, this.port,
this.precompiledDillPath, this.precompiledDillPath,
this.precompiledDillFiles, this.precompiledDillFiles,
this.enableAsserts, @required this.buildMode,
this.trackWidgetCreation, this.trackWidgetCreation,
this.updateGoldens, this.updateGoldens,
this.buildTestAssets, this.buildTestAssets,
...@@ -280,7 +281,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -280,7 +281,7 @@ class FlutterPlatform extends PlatformPlugin {
final int port; final int port;
final String precompiledDillPath; final String precompiledDillPath;
final Map<String, String> precompiledDillFiles; final Map<String, String> precompiledDillFiles;
final bool enableAsserts; final BuildMode buildMode;
final bool trackWidgetCreation; final bool trackWidgetCreation;
final bool updateGoldens; final bool updateGoldens;
final bool buildTestAssets; final bool buildTestAssets;
...@@ -455,7 +456,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -455,7 +456,7 @@ class FlutterPlatform extends PlatformPlugin {
if (precompiledDillPath == null && precompiledDillFiles == null) { if (precompiledDillPath == null && precompiledDillFiles == null) {
// Lazily instantiate compiler so it is built only if it is actually used. // Lazily instantiate compiler so it is built only if it is actually used.
compiler ??= TestCompiler(enableAsserts, trackWidgetCreation, flutterProject); compiler ??= TestCompiler(buildMode, trackWidgetCreation, flutterProject);
mainDart = await compiler.compile(mainDart); mainDart = await compiler.compile(mainDart);
if (mainDart == null) { if (mainDart == null) {
......
...@@ -15,6 +15,7 @@ import '../base/file_system.dart'; ...@@ -15,6 +15,7 @@ import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../base/terminal.dart'; import '../base/terminal.dart';
import '../build_info.dart';
import '../dart/package_map.dart'; import '../dart/package_map.dart';
import '../globals.dart'; import '../globals.dart';
import '../project.dart'; import '../project.dart';
...@@ -36,7 +37,7 @@ Future<int> runTests( ...@@ -36,7 +37,7 @@ Future<int> runTests(
bool machine = false, bool machine = false,
String precompiledDillPath, String precompiledDillPath,
Map<String, String> precompiledDillFiles, Map<String, String> precompiledDillFiles,
bool enableAsserts = false, @required BuildMode buildMode,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
bool updateGoldens = false, bool updateGoldens = false,
TestWatcher watcher, TestWatcher watcher,
...@@ -114,7 +115,7 @@ Future<int> runTests( ...@@ -114,7 +115,7 @@ Future<int> runTests(
serverType: serverType, serverType: serverType,
precompiledDillPath: precompiledDillPath, precompiledDillPath: precompiledDillPath,
precompiledDillFiles: precompiledDillFiles, precompiledDillFiles: precompiledDillFiles,
enableAsserts: enableAsserts, buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
buildTestAssets: buildTestAssets, buildTestAssets: buildTestAssets,
......
...@@ -37,7 +37,7 @@ class TestCompiler { ...@@ -37,7 +37,7 @@ class TestCompiler {
/// ///
/// [flutterProject] is the project for which we are running tests. /// [flutterProject] is the project for which we are running tests.
TestCompiler( TestCompiler(
this.enableAsserts, this.buildMode,
this.trackWidgetCreation, this.trackWidgetCreation,
this.flutterProject, this.flutterProject,
) : testFilePath = getKernelPathForTransformerOptions( ) : testFilePath = getKernelPathForTransformerOptions(
...@@ -60,7 +60,7 @@ class TestCompiler { ...@@ -60,7 +60,7 @@ class TestCompiler {
final StreamController<_CompilationRequest> compilerController = StreamController<_CompilationRequest>(); final StreamController<_CompilationRequest> compilerController = StreamController<_CompilationRequest>();
final List<_CompilationRequest> compilationQueue = <_CompilationRequest>[]; final List<_CompilationRequest> compilationQueue = <_CompilationRequest>[];
final FlutterProject flutterProject; final FlutterProject flutterProject;
final bool enableAsserts; final BuildMode buildMode;
final bool trackWidgetCreation; final bool trackWidgetCreation;
final String testFilePath; final String testFilePath;
...@@ -96,7 +96,7 @@ class TestCompiler { ...@@ -96,7 +96,7 @@ class TestCompiler {
if (flutterProject.hasBuilders) { if (flutterProject.hasBuilders) {
return CodeGeneratingResidentCompiler.create( return CodeGeneratingResidentCompiler.create(
flutterProject: flutterProject, flutterProject: flutterProject,
enableAsserts: enableAsserts, buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
compilerMessageConsumer: _reportCompilerMessage, compilerMessageConsumer: _reportCompilerMessage,
initializeFromDill: testFilePath, initializeFromDill: testFilePath,
...@@ -108,7 +108,7 @@ class TestCompiler { ...@@ -108,7 +108,7 @@ class TestCompiler {
return ResidentCompiler( return ResidentCompiler(
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
packagesPath: PackageMap.globalPackagesPath, packagesPath: PackageMap.globalPackagesPath,
enableAsserts: enableAsserts, buildMode: buildMode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
compilerMessageConsumer: _reportCompilerMessage, compilerMessageConsumer: _reportCompilerMessage,
initializeFromDill: testFilePath, initializeFromDill: testFilePath,
......
...@@ -149,6 +149,7 @@ class FlutterTesterDevice extends Device { ...@@ -149,6 +149,7 @@ class FlutterTesterDevice extends Device {
assetDirPath: assetDirPath, assetDirPath: assetDirPath,
applicationKernelFilePath: applicationKernelFilePath, applicationKernelFilePath: applicationKernelFilePath,
precompiledSnapshot: false, precompiledSnapshot: false,
buildMode: buildInfo.mode,
trackWidgetCreation: buildInfo.trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
); );
command.add('--flutter-assets-dir=$assetDirPath'); command.add('--flutter-assets-dir=$assetDirPath');
......
...@@ -128,13 +128,12 @@ flutter_tools:lib/'''); ...@@ -128,13 +128,12 @@ flutter_tools:lib/''');
targetModel: anyNamed('targetModel'), targetModel: anyNamed('targetModel'),
linkPlatformKernelIn: anyNamed('linkPlatformKernelIn'), linkPlatformKernelIn: anyNamed('linkPlatformKernelIn'),
aot: anyNamed('aot'), aot: anyNamed('aot'),
enableAsserts: anyNamed('enableAsserts'), buildMode: anyNamed('buildMode'),
trackWidgetCreation: anyNamed('trackWidgetCreation'), trackWidgetCreation: anyNamed('trackWidgetCreation'),
extraFrontEndOptions: anyNamed('extraFrontEndOptions'), extraFrontEndOptions: anyNamed('extraFrontEndOptions'),
packagesPath: anyNamed('packagesPath'), packagesPath: anyNamed('packagesPath'),
fileSystemRoots: anyNamed('fileSystemRoots'), fileSystemRoots: anyNamed('fileSystemRoots'),
fileSystemScheme: anyNamed('fileSystemScheme'), fileSystemScheme: anyNamed('fileSystemScheme'),
targetProductVm: anyNamed('targetProductVm'),
platformDill: anyNamed('platformDill'), platformDill: anyNamed('platformDill'),
initializeFromDill: anyNamed('initializeFromDill'), initializeFromDill: anyNamed('initializeFromDill'),
)).thenAnswer((Invocation invocation) async { )).thenAnswer((Invocation invocation) async {
...@@ -153,10 +152,9 @@ flutter_tools:lib/'''); ...@@ -153,10 +152,9 @@ flutter_tools:lib/''');
when(mockKernelCompiler.compile( when(mockKernelCompiler.compile(
sdkRoot: anyNamed('sdkRoot'), sdkRoot: anyNamed('sdkRoot'),
aot: anyNamed('aot'), aot: anyNamed('aot'),
enableAsserts: anyNamed('enableAsserts'), buildMode: anyNamed('buildMode'),
trackWidgetCreation: false, trackWidgetCreation: false,
targetModel: anyNamed('targetModel'), targetModel: anyNamed('targetModel'),
targetProductVm: anyNamed('targetProductVm'),
outputFilePath: anyNamed('outputFilePath'), outputFilePath: anyNamed('outputFilePath'),
depFilePath: anyNamed('depFilePath'), depFilePath: anyNamed('depFilePath'),
packagesPath: anyNamed('packagesPath'), packagesPath: anyNamed('packagesPath'),
...@@ -178,10 +176,9 @@ flutter_tools:lib/'''); ...@@ -178,10 +176,9 @@ flutter_tools:lib/''');
when(mockKernelCompiler.compile( when(mockKernelCompiler.compile(
sdkRoot: anyNamed('sdkRoot'), sdkRoot: anyNamed('sdkRoot'),
aot: anyNamed('aot'), aot: anyNamed('aot'),
enableAsserts: anyNamed('enableAsserts'), buildMode: anyNamed('buildMode'),
trackWidgetCreation: true, trackWidgetCreation: true,
targetModel: anyNamed('targetModel'), targetModel: anyNamed('targetModel'),
targetProductVm: anyNamed('targetProductVm'),
outputFilePath: anyNamed('outputFilePath'), outputFilePath: anyNamed('outputFilePath'),
depFilePath: anyNamed('depFilePath'), depFilePath: anyNamed('depFilePath'),
packagesPath: anyNamed('packagesPath'), packagesPath: anyNamed('packagesPath'),
...@@ -391,14 +388,13 @@ class FakeKernelCompiler implements KernelCompiler { ...@@ -391,14 +388,13 @@ class FakeKernelCompiler implements KernelCompiler {
TargetModel targetModel = TargetModel.flutter, TargetModel targetModel = TargetModel.flutter,
bool linkPlatformKernelIn = false, bool linkPlatformKernelIn = false,
bool aot = false, bool aot = false,
bool enableAsserts = false, BuildMode buildMode,
bool causalAsyncStacks = true, bool causalAsyncStacks = true,
bool trackWidgetCreation, bool trackWidgetCreation,
List<String> extraFrontEndOptions, List<String> extraFrontEndOptions,
String packagesPath, String packagesPath,
List<String> fileSystemRoots, List<String> fileSystemRoots,
String fileSystemScheme, String fileSystemScheme,
bool targetProductVm = false,
String platformDill, String platformDill,
String initializeFromDill, String initializeFromDill,
}) async { }) async {
......
...@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/io.dart'; ...@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart'; import 'package:flutter_tools/src/globals.dart';
...@@ -52,7 +53,7 @@ void main() { ...@@ -52,7 +53,7 @@ void main() {
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null); final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart', mainPath: '/path/to/main.dart',
enableAsserts: true, buildMode: BuildMode.debug,
trackWidgetCreation: false, trackWidgetCreation: false,
); );
...@@ -76,7 +77,7 @@ void main() { ...@@ -76,7 +77,7 @@ void main() {
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null); final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot', final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart', mainPath: '/path/to/main.dart',
enableAsserts: true, buildMode: BuildMode.debug,
trackWidgetCreation: false, trackWidgetCreation: false,
); );
...@@ -103,7 +104,7 @@ void main() { ...@@ -103,7 +104,7 @@ void main() {
final CompilerOutput output = await kernelCompiler.compile( final CompilerOutput output = await kernelCompiler.compile(
sdkRoot: '/path/to/sdkroot', sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart', mainPath: '/path/to/main.dart',
enableAsserts: true, buildMode: BuildMode.debug,
trackWidgetCreation: false, trackWidgetCreation: false,
); );
expect(mockFrontendServerStdIn.getAndClear(), isEmpty); expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
......
...@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/base/io.dart'; ...@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart'; import 'package:flutter_tools/src/globals.dart';
...@@ -28,7 +29,7 @@ void main() { ...@@ -28,7 +29,7 @@ void main() {
StreamController<String> stdErrStreamController; StreamController<String> stdErrStreamController;
setUp(() { setUp(() {
generator = ResidentCompiler('sdkroot'); generator = ResidentCompiler('sdkroot', buildMode: BuildMode.debug);
mockProcessManager = MockProcessManager(); mockProcessManager = MockProcessManager();
mockFrontendServer = MockProcess(); mockFrontendServer = MockProcess();
mockFrontendServerStdIn = MockStdIn(); mockFrontendServerStdIn = MockStdIn();
......
...@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/io.dart'; ...@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart'; import 'package:flutter_tools/src/globals.dart';
...@@ -29,7 +30,7 @@ void main() { ...@@ -29,7 +30,7 @@ void main() {
StreamController<String> stdErrStreamController; StreamController<String> stdErrStreamController;
setUp(() { setUp(() {
generator = ResidentCompiler('sdkroot'); generator = ResidentCompiler('sdkroot', buildMode: BuildMode.debug);
mockProcessManager = MockProcessManager(); mockProcessManager = MockProcessManager();
mockFrontendServer = MockProcess(); mockFrontendServer = MockProcess();
mockFrontendServerStdIn = MockStdIn(); mockFrontendServerStdIn = MockStdIn();
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
...@@ -18,13 +19,13 @@ import '../src/context.dart'; ...@@ -18,13 +19,13 @@ import '../src/context.dart';
void main() { void main() {
group('FlutterPlatform', () { group('FlutterPlatform', () {
testUsingContext('ensureConfiguration throws an error if an explicitObservatoryPort is specified and more than one test file', () async { testUsingContext('ensureConfiguration throws an error if an explicitObservatoryPort is specified and more than one test file', () async {
final FlutterPlatform flutterPlatform = FlutterPlatform(shellPath: '/', explicitObservatoryPort: 1234); final FlutterPlatform flutterPlatform = FlutterPlatform(buildMode: BuildMode.debug, shellPath: '/', explicitObservatoryPort: 1234);
flutterPlatform.loadChannel('test1.dart', MockSuitePlatform()); flutterPlatform.loadChannel('test1.dart', MockSuitePlatform());
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA<ToolExit>())); expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA<ToolExit>()));
}); });
testUsingContext('ensureConfiguration throws an error if a precompiled entrypoint is specified and more that one test file', () { testUsingContext('ensureConfiguration throws an error if a precompiled entrypoint is specified and more that one test file', () {
final FlutterPlatform flutterPlatform = FlutterPlatform(shellPath: '/', precompiledDillPath: 'example.dill'); final FlutterPlatform flutterPlatform = FlutterPlatform(buildMode: BuildMode.debug, shellPath: '/', precompiledDillPath: 'example.dill');
flutterPlatform.loadChannel('test1.dart', MockSuitePlatform()); flutterPlatform.loadChannel('test1.dart', MockSuitePlatform());
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA<ToolExit>())); expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA<ToolExit>()));
}); });
...@@ -86,12 +87,14 @@ void main() { ...@@ -86,12 +87,14 @@ void main() {
testUsingContext('installHook creates a FlutterPlatform', () { testUsingContext('installHook creates a FlutterPlatform', () {
expect(() => installHook( expect(() => installHook(
buildMode: BuildMode.debug,
shellPath: 'abc', shellPath: 'abc',
enableObservatory: false, enableObservatory: false,
startPaused: true, startPaused: true,
), throwsA(isA<AssertionError>())); ), throwsA(isA<AssertionError>()));
expect(() => installHook( expect(() => installHook(
buildMode: BuildMode.debug,
shellPath: 'abc', shellPath: 'abc',
enableObservatory: false, enableObservatory: false,
startPaused: false, startPaused: false,
...@@ -109,7 +112,7 @@ void main() { ...@@ -109,7 +112,7 @@ void main() {
port: 100, port: 100,
precompiledDillPath: 'def', precompiledDillPath: 'def',
precompiledDillFiles: expectedPrecompiledDillFiles, precompiledDillFiles: expectedPrecompiledDillFiles,
enableAsserts: true, buildMode: BuildMode.debug,
trackWidgetCreation: true, trackWidgetCreation: true,
updateGoldens: true, updateGoldens: true,
buildTestAssets: true, buildTestAssets: true,
...@@ -131,7 +134,7 @@ void main() { ...@@ -131,7 +134,7 @@ void main() {
expect(flutterPlatform.explicitObservatoryPort, equals(200)); expect(flutterPlatform.explicitObservatoryPort, equals(200));
expect(flutterPlatform.precompiledDillPath, equals('def')); expect(flutterPlatform.precompiledDillPath, equals('def'));
expect(flutterPlatform.precompiledDillFiles, expectedPrecompiledDillFiles); expect(flutterPlatform.precompiledDillFiles, expectedPrecompiledDillFiles);
expect(flutterPlatform.enableAsserts, equals(true)); expect(flutterPlatform.buildMode, equals(BuildMode.debug));
expect(flutterPlatform.trackWidgetCreation, equals(true)); expect(flutterPlatform.trackWidgetCreation, equals(true));
expect(flutterPlatform.updateGoldens, equals(true)); expect(flutterPlatform.updateGoldens, equals(true));
expect(flutterPlatform.buildTestAssets, equals(true)); expect(flutterPlatform.buildTestAssets, equals(true));
...@@ -153,6 +156,7 @@ class MockHttpServer extends Mock implements HttpServer {} ...@@ -153,6 +156,7 @@ class MockHttpServer extends Mock implements HttpServer {}
// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts. // Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
class TestFlutterPlatform extends FlutterPlatform { class TestFlutterPlatform extends FlutterPlatform {
TestFlutterPlatform() : super( TestFlutterPlatform() : super(
buildMode: BuildMode.debug,
shellPath: '/', shellPath: '/',
precompiledDillPath: 'example.dill', precompiledDillPath: 'example.dill',
host: InternetAddress.loopbackIPv6, host: InternetAddress.loopbackIPv6,
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/test/test_compiler.dart'; import 'package:flutter_tools/src/test/test_compiler.dart';
...@@ -25,7 +26,7 @@ void main() { ...@@ -25,7 +26,7 @@ void main() {
fs.file('test/foo.dart').createSync(recursive: true); fs.file('test/foo.dart').createSync(recursive: true);
residentCompiler = MockResidentCompiler(); residentCompiler = MockResidentCompiler();
testCompiler = FakeTestCompiler( testCompiler = FakeTestCompiler(
true, BuildMode.debug,
false, false,
FlutterProject.current(), FlutterProject.current(),
residentCompiler, residentCompiler,
...@@ -76,11 +77,11 @@ void main() { ...@@ -76,11 +77,11 @@ void main() {
/// Override the creation of the Resident Compiler to simplify testing. /// Override the creation of the Resident Compiler to simplify testing.
class FakeTestCompiler extends TestCompiler { class FakeTestCompiler extends TestCompiler {
FakeTestCompiler( FakeTestCompiler(
bool enableAsserts, BuildMode buildMode,
bool trackWidgetCreation, bool trackWidgetCreation,
FlutterProject flutterProject, FlutterProject flutterProject,
this.residentCompiler, this.residentCompiler,
) : super(enableAsserts, trackWidgetCreation, flutterProject); ) : super(buildMode, trackWidgetCreation, flutterProject);
final MockResidentCompiler residentCompiler; final MockResidentCompiler residentCompiler;
......
...@@ -134,7 +134,10 @@ void main() { ...@@ -134,7 +134,10 @@ void main() {
mockArtifacts = MockArtifacts(); mockArtifacts = MockArtifacts();
final String artifactPath = fs.path.join(flutterRoot, 'artifact'); final String artifactPath = fs.path.join(flutterRoot, 'artifact');
fs.file(artifactPath).createSync(recursive: true); fs.file(artifactPath).createSync(recursive: true);
when(mockArtifacts.getArtifactPath(any)).thenReturn(artifactPath); when(mockArtifacts.getArtifactPath(
any,
mode: anyNamed('mode')
)).thenReturn(artifactPath);
mockKernelCompiler = MockKernelCompiler(); mockKernelCompiler = MockKernelCompiler();
}); });
...@@ -170,7 +173,7 @@ Hello! ...@@ -170,7 +173,7 @@ Hello!
mainPath: anyNamed('mainPath'), mainPath: anyNamed('mainPath'),
outputFilePath: anyNamed('outputFilePath'), outputFilePath: anyNamed('outputFilePath'),
depFilePath: anyNamed('depFilePath'), depFilePath: anyNamed('depFilePath'),
enableAsserts: anyNamed('enableAsserts'), buildMode: BuildMode.debug,
trackWidgetCreation: anyNamed('trackWidgetCreation'), trackWidgetCreation: anyNamed('trackWidgetCreation'),
extraFrontEndOptions: anyNamed('extraFrontEndOptions'), extraFrontEndOptions: anyNamed('extraFrontEndOptions'),
fileSystemRoots: anyNamed('fileSystemRoots'), fileSystemRoots: anyNamed('fileSystemRoots'),
......
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