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

[flutter_tools] Allow providing dart-defines to Android, iOS, macOS builds (#51714)

parent aed96199
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/framework/adb.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/tasks/defines_task.dart';
/// Verify that dart defines work on Android.
Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android;
await task(runDartDefinesTask);
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/framework/adb.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/tasks/defines_task.dart';
/// Verify that dart defines work on iOS.
Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.ios;
await task(runDartDefinesTask);
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import '../framework/adb.dart';
import '../framework/framework.dart';
import '../framework/utils.dart';
Future<TaskResult> runDartDefinesTask() async {
final Device device = await devices.workingDevice;
await device.unlock();
final String deviceId = device.deviceId;
final Directory testDirectory = dir('${flutterDirectory.path}/dev/integration_tests/ui');
await inDirectory<void>(testDirectory, () async {
await flutter('packages', options: <String>['get']);
await flutter('drive', options: <String>[
'--verbose',
'-d',
deviceId,
'--dart-define=test.value=ExampleValue',
'lib/defines.dart',
]);
});
return TaskResult.success(<String, dynamic>{});
}
...@@ -323,6 +323,13 @@ tasks: ...@@ -323,6 +323,13 @@ tasks:
stage: devicelab stage: devicelab
required_agent_capabilities: ["mac/android"] required_agent_capabilities: ["mac/android"]
android_defines_test:
description: >
Builds an APK with a --dart-define and verifies it can be used as a constant
stage: devicelab
flaky: true
required_agent_capabilities: ["linux/android"]
android_obfuscate_test: android_obfuscate_test:
description: > description: >
Builds an obfuscated APK and verifies a dart identifier cannot be found Builds an obfuscated APK and verifies a dart identifier cannot be found
...@@ -400,6 +407,13 @@ tasks: ...@@ -400,6 +407,13 @@ tasks:
# iOS on-device tests # iOS on-device tests
ios_defines_test:
description: >
Builds a Framework with a --dart-define and verifies it can be used as a constant
stage: devicelab
flaky: true
required_agent_capabilities: ["mac/ios"]
ios_content_validation_test: ios_content_validation_test:
description: > description: >
Builds an obfuscated app and verifies contents and structure Builds an obfuscated app and verifies contents and structure
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/widgets.dart';
import 'package:flutter_driver/driver_extension.dart';
/// This application displays text passed through a --dart-define.
void main() {
enableFlutterDriverExtension();
runApp(
const Center(
child: Text(
String.fromEnvironment('test.value'),
textDirection: TextDirection.ltr,
),
),
);
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() {
FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
});
tearDownAll(() async {
await driver.close();
});
test('Can run with --dart-deinfe', () async {
await driver.waitFor(find.text('ExampleValue'));
});
}
...@@ -83,6 +83,7 @@ RunCommand "${FLUTTER_ROOT}/bin/flutter" --suppress-analytics \ ...@@ -83,6 +83,7 @@ RunCommand "${FLUTTER_ROOT}/bin/flutter" --suppress-analytics \
-dTreeShakeIcons="${icon_tree_shaker_flag}" \ -dTreeShakeIcons="${icon_tree_shaker_flag}" \
-dDartObfuscation="${dart_obfuscation_flag}" \ -dDartObfuscation="${dart_obfuscation_flag}" \
-dSplitDebugInfo="${SPLIT_DEBUG_INFO}" \ -dSplitDebugInfo="${SPLIT_DEBUG_INFO}" \
-dDartDefines="${DART_DEFINES}" \
--build-inputs="${build_inputs_path}" \ --build-inputs="${build_inputs_path}" \
--build-outputs="${build_outputs_path}" \ --build-outputs="${build_outputs_path}" \
--output="${ephemeral_dir}" \ --output="${ephemeral_dir}" \
......
...@@ -186,6 +186,7 @@ BuildApp() { ...@@ -186,6 +186,7 @@ BuildApp() {
-dTrackWidgetCreation="${track_widget_creation_flag}" \ -dTrackWidgetCreation="${track_widget_creation_flag}" \
-dDartObfuscation="${dart_obfuscation_flag}" \ -dDartObfuscation="${dart_obfuscation_flag}" \
-dEnableBitcode="${bitcode_flag}" \ -dEnableBitcode="${bitcode_flag}" \
-dDartDefines="${DART_DEFINES}" \
"${build_mode}_ios_bundle_flutter_assets" "${build_mode}_ios_bundle_flutter_assets"
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
......
...@@ -615,6 +615,10 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -615,6 +615,10 @@ class FlutterPlugin implements Plugin<Project> {
if (project.hasProperty('tree-shake-icons')) { if (project.hasProperty('tree-shake-icons')) {
treeShakeIconsOptionsValue = project.property('tree-shake-icons').toBoolean() treeShakeIconsOptionsValue = project.property('tree-shake-icons').toBoolean()
} }
String dartDefinesValue = null
if (project.hasProperty('dart-defines')) {
dartDefinesValue = project.property('dart-defines')
}
def targetPlatforms = getTargetPlatforms() def targetPlatforms = getTargetPlatforms()
def addFlutterDeps = { variant -> def addFlutterDeps = { variant ->
if (shouldSplitPerAbi()) { if (shouldSplitPerAbi()) {
...@@ -652,6 +656,7 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -652,6 +656,7 @@ class FlutterPlugin implements Plugin<Project> {
splitDebugInfo splitDebugInfoValue splitDebugInfo splitDebugInfoValue
treeShakeIcons treeShakeIconsOptionsValue treeShakeIcons treeShakeIconsOptionsValue
dartObfuscation dartObfuscationValue dartObfuscation dartObfuscationValue
dartDefines dartDefinesValue
doLast { doLast {
project.exec { project.exec {
if (Os.isFamily(Os.FAMILY_WINDOWS)) { if (Os.isFamily(Os.FAMILY_WINDOWS)) {
...@@ -799,6 +804,8 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -799,6 +804,8 @@ abstract class BaseFlutterTask extends DefaultTask {
Boolean treeShakeIcons Boolean treeShakeIcons
@Optional @Input @Optional @Input
Boolean dartObfuscation Boolean dartObfuscation
@Optional @Input
String dartDefines
@OutputFiles @OutputFiles
FileCollection getDependenciesFiles() { FileCollection getDependenciesFiles() {
...@@ -864,6 +871,9 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -864,6 +871,9 @@ abstract class BaseFlutterTask extends DefaultTask {
if (dartObfuscation == true) { if (dartObfuscation == true) {
args "-dDartObfuscation=true" args "-dDartObfuscation=true"
} }
if (dartDefines != null) {
args "-dDartDefines=${dartDefines}"
}
if (extraGenSnapshotOptions != null) { if (extraGenSnapshotOptions != null) {
args "--ExtraGenSnapshotOptions=${extraGenSnapshotOptions}" args "--ExtraGenSnapshotOptions=${extraGenSnapshotOptions}"
} }
......
...@@ -19,6 +19,7 @@ import '../base/terminal.dart'; ...@@ -19,6 +19,7 @@ import '../base/terminal.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../cache.dart'; import '../cache.dart';
import '../convert.dart';
import '../flutter_manifest.dart'; import '../flutter_manifest.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
...@@ -329,6 +330,9 @@ Future<void> buildGradleApp({ ...@@ -329,6 +330,9 @@ Future<void> buildGradleApp({
if (androidBuildInfo.shrink) { if (androidBuildInfo.shrink) {
command.add('-Pshrink=true'); command.add('-Pshrink=true');
} }
if (androidBuildInfo.buildInfo.dartDefines?.isNotEmpty ?? false) {
command.add('-Pdart-defines=${jsonEncode(androidBuildInfo.buildInfo.dartDefines)}');
}
if (shouldBuildPluginAsAar) { if (shouldBuildPluginAsAar) {
// Pass a system flag instead of a project flag, so this flag can be // Pass a system flag instead of a project flag, so this flag can be
// read from include_flutter.groovy. // read from include_flutter.groovy.
......
...@@ -22,7 +22,7 @@ class AotBuilder { ...@@ -22,7 +22,7 @@ class AotBuilder {
Future<void> build({ Future<void> build({
@required TargetPlatform platform, @required TargetPlatform platform,
@required String outputPath, @required String outputPath,
@required BuildMode buildMode, @required BuildInfo buildInfo,
@required String mainDartFile, @required String mainDartFile,
bool bitcode = kBitcodeEnabledDefault, bool bitcode = kBitcodeEnabledDefault,
bool quiet = true, bool quiet = true,
...@@ -30,8 +30,6 @@ class AotBuilder { ...@@ -30,8 +30,6 @@ class AotBuilder {
Iterable<DarwinArch> iosBuildArchs = defaultIOSArchs, Iterable<DarwinArch> iosBuildArchs = defaultIOSArchs,
List<String> extraFrontEndOptions, List<String> extraFrontEndOptions,
List<String> extraGenSnapshotOptions, List<String> extraGenSnapshotOptions,
@required List<String> dartDefines,
@required bool treeShakeIcons,
}) async { }) async {
if (platform == null) { if (platform == null) {
throwToolExit('No AOT build platform specified'); throwToolExit('No AOT build platform specified');
...@@ -41,14 +39,14 @@ class AotBuilder { ...@@ -41,14 +39,14 @@ class AotBuilder {
if (platform != TargetPlatform.ios) { if (platform != TargetPlatform.ios) {
throwToolExit('Bitcode is only supported on iOS (TargetPlatform is $platform).'); throwToolExit('Bitcode is only supported on iOS (TargetPlatform is $platform).');
} }
await validateBitcode(buildMode, platform); await validateBitcode(buildInfo.mode, platform);
} }
Status status; Status status;
if (!quiet) { if (!quiet) {
final String typeName = globals.artifacts.getEngineType(platform, buildMode); final String typeName = globals.artifacts.getEngineType(platform, buildInfo.mode);
status = globals.logger.startProgress( status = globals.logger.startProgress(
'Building AOT snapshot in ${getFriendlyModeName(buildMode)} mode ($typeName)...', 'Building AOT snapshot in ${getFriendlyModeName(buildInfo.mode)} mode ($typeName)...',
timeout: timeoutConfiguration.slowOperation, timeout: timeoutConfiguration.slowOperation,
); );
} }
...@@ -58,13 +56,13 @@ class AotBuilder { ...@@ -58,13 +56,13 @@ class AotBuilder {
// Compile to kernel. // Compile to kernel.
final String kernelOut = await snapshotter.compileKernel( final String kernelOut = await snapshotter.compileKernel(
platform: platform, platform: platform,
buildMode: buildMode, buildMode: buildInfo.mode,
mainPath: mainDartFile, mainPath: mainDartFile,
packagesPath: PackageMap.globalPackagesPath, packagesPath: PackageMap.globalPackagesPath,
trackWidgetCreation: false, trackWidgetCreation: buildInfo.trackWidgetCreation,
outputPath: outputPath, outputPath: outputPath,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
dartDefines: dartDefines, dartDefines: buildInfo.dartDefines
); );
if (kernelOut == null) { if (kernelOut == null) {
throwToolExit('Compiler terminated unexpectedly.'); throwToolExit('Compiler terminated unexpectedly.');
...@@ -85,7 +83,7 @@ class AotBuilder { ...@@ -85,7 +83,7 @@ class AotBuilder {
exitCodes[iosArch] = snapshotter.build( exitCodes[iosArch] = snapshotter.build(
platform: platform, platform: platform,
darwinArch: iosArch, darwinArch: iosArch,
buildMode: buildMode, buildMode: buildInfo.mode,
mainPath: kernelOut, mainPath: kernelOut,
packagesPath: PackageMap.globalPackagesPath, packagesPath: PackageMap.globalPackagesPath,
outputPath: outputPath, outputPath: outputPath,
...@@ -124,7 +122,7 @@ class AotBuilder { ...@@ -124,7 +122,7 @@ class AotBuilder {
// Android AOT snapshot. // Android AOT snapshot.
final int snapshotExitCode = await snapshotter.build( final int snapshotExitCode = await snapshotter.build(
platform: platform, platform: platform,
buildMode: buildMode, buildMode: buildInfo.mode,
mainPath: kernelOut, mainPath: kernelOut,
packagesPath: PackageMap.globalPackagesPath, packagesPath: PackageMap.globalPackagesPath,
outputPath: outputPath, outputPath: outputPath,
......
...@@ -23,6 +23,7 @@ class BuildInfo { ...@@ -23,6 +23,7 @@ class BuildInfo {
this.buildName, this.buildName,
this.splitDebugInfoPath, this.splitDebugInfoPath,
this.dartObfuscation = false, this.dartObfuscation = false,
this.dartDefines = const <String>[],
@required this.treeShakeIcons, @required this.treeShakeIcons,
}); });
...@@ -46,10 +47,10 @@ class BuildInfo { ...@@ -46,10 +47,10 @@ class BuildInfo {
final bool trackWidgetCreation; final bool trackWidgetCreation;
/// Extra command-line options for front-end. /// Extra command-line options for front-end.
final String extraFrontEndOptions; final List<String> extraFrontEndOptions;
/// Extra command-line options for gen_snapshot. /// Extra command-line options for gen_snapshot.
final String extraGenSnapshotOptions; final List<String> extraGenSnapshotOptions;
/// Internal version number (not displayed to users). /// Internal version number (not displayed to users).
/// Each build must have a unique number to differentiate it from previous builds. /// Each build must have a unique number to differentiate it from previous builds.
...@@ -72,6 +73,12 @@ class BuildInfo { ...@@ -72,6 +73,12 @@ class BuildInfo {
/// Whether to apply dart source code obfuscation. /// Whether to apply dart source code obfuscation.
final bool dartObfuscation; final bool dartObfuscation;
/// Additional constant values to be made available in the Dart program.
///
/// These values can be used with the const `fromEnvironment` constructors of
/// [bool], [String], [int], and [double].
final List<String> dartDefines;
static const BuildInfo debug = BuildInfo(BuildMode.debug, null, treeShakeIcons: false); static const BuildInfo debug = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
static const BuildInfo profile = BuildInfo(BuildMode.profile, null, treeShakeIcons: kIconTreeShakerEnabledDefault); static const BuildInfo profile = BuildInfo(BuildMode.profile, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
static const BuildInfo jitRelease = BuildInfo(BuildMode.jitRelease, null, treeShakeIcons: kIconTreeShakerEnabledDefault); static const BuildInfo jitRelease = BuildInfo(BuildMode.jitRelease, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
......
...@@ -48,7 +48,6 @@ class DwdsWebRunnerFactory extends WebRunnerFactory { ...@@ -48,7 +48,6 @@ class DwdsWebRunnerFactory extends WebRunnerFactory {
@required FlutterProject flutterProject, @required FlutterProject flutterProject,
@required bool ipv6, @required bool ipv6,
@required DebuggingOptions debuggingOptions, @required DebuggingOptions debuggingOptions,
@required List<String> dartDefines,
@required UrlTunneller urlTunneller, @required UrlTunneller urlTunneller,
}) { }) {
return _ResidentWebRunner( return _ResidentWebRunner(
...@@ -58,7 +57,6 @@ class DwdsWebRunnerFactory extends WebRunnerFactory { ...@@ -58,7 +57,6 @@ class DwdsWebRunnerFactory extends WebRunnerFactory {
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
ipv6: ipv6, ipv6: ipv6,
stayResident: stayResident, stayResident: stayResident,
dartDefines: dartDefines,
urlTunneller: urlTunneller, urlTunneller: urlTunneller,
); );
} }
...@@ -77,7 +75,6 @@ abstract class ResidentWebRunner extends ResidentRunner { ...@@ -77,7 +75,6 @@ abstract class ResidentWebRunner extends ResidentRunner {
@required bool ipv6, @required bool ipv6,
@required DebuggingOptions debuggingOptions, @required DebuggingOptions debuggingOptions,
bool stayResident = true, bool stayResident = true,
@required this.dartDefines,
}) : super( }) : super(
<FlutterDevice>[device], <FlutterDevice>[device],
target: target ?? globals.fs.path.join('lib', 'main.dart'), target: target ?? globals.fs.path.join('lib', 'main.dart'),
...@@ -88,7 +85,6 @@ abstract class ResidentWebRunner extends ResidentRunner { ...@@ -88,7 +85,6 @@ abstract class ResidentWebRunner extends ResidentRunner {
FlutterDevice get device => flutterDevices.first; FlutterDevice get device => flutterDevices.first;
final FlutterProject flutterProject; final FlutterProject flutterProject;
final List<String> dartDefines;
DateTime firstBuildTime; DateTime firstBuildTime;
// Used with the new compiler to generate a bootstrap file containing plugins // Used with the new compiler to generate a bootstrap file containing plugins
...@@ -358,7 +354,6 @@ class _ResidentWebRunner extends ResidentWebRunner { ...@@ -358,7 +354,6 @@ class _ResidentWebRunner extends ResidentWebRunner {
@required bool ipv6, @required bool ipv6,
@required DebuggingOptions debuggingOptions, @required DebuggingOptions debuggingOptions,
bool stayResident = true, bool stayResident = true,
@required List<String> dartDefines,
@required this.urlTunneller, @required this.urlTunneller,
}) : super( }) : super(
device, device,
...@@ -367,7 +362,6 @@ class _ResidentWebRunner extends ResidentWebRunner { ...@@ -367,7 +362,6 @@ class _ResidentWebRunner extends ResidentWebRunner {
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
ipv6: ipv6, ipv6: ipv6,
stayResident: stayResident, stayResident: stayResident,
dartDefines: dartDefines,
); );
final UrlTunneller urlTunneller; final UrlTunneller urlTunneller;
...@@ -432,7 +426,6 @@ class _ResidentWebRunner extends ResidentWebRunner { ...@@ -432,7 +426,6 @@ class _ResidentWebRunner extends ResidentWebRunner {
target, target,
debuggingOptions.buildInfo, debuggingOptions.buildInfo,
debuggingOptions.initializePlatform, debuggingOptions.initializePlatform,
dartDefines,
false, false,
); );
} }
...@@ -498,7 +491,6 @@ class _ResidentWebRunner extends ResidentWebRunner { ...@@ -498,7 +491,6 @@ class _ResidentWebRunner extends ResidentWebRunner {
target, target,
debuggingOptions.buildInfo, debuggingOptions.buildInfo,
debuggingOptions.initializePlatform, debuggingOptions.initializePlatform,
dartDefines,
false, false,
); );
} on ToolExit { } on ToolExit {
......
...@@ -381,7 +381,7 @@ abstract class CopyFlutterAotBundle extends Target { ...@@ -381,7 +381,7 @@ abstract class CopyFlutterAotBundle extends Target {
/// Dart defines are encoded inside [Environment] as a JSON array. /// Dart defines are encoded inside [Environment] as a JSON array.
List<String> parseDartDefines(Environment environment) { List<String> parseDartDefines(Environment environment) {
if (!environment.defines.containsKey(kDartDefines)) { if (!environment.defines.containsKey(kDartDefines) || environment.defines[kDartDefines].isEmpty) {
return const <String>[]; return const <String>[];
} }
...@@ -389,7 +389,7 @@ List<String> parseDartDefines(Environment environment) { ...@@ -389,7 +389,7 @@ List<String> parseDartDefines(Environment environment) {
try { try {
final List<Object> parsedDefines = jsonDecode(dartDefinesJson) as List<Object>; final List<Object> parsedDefines = jsonDecode(dartDefinesJson) as List<Object>;
return parsedDefines.cast<String>(); return parsedDefines.cast<String>();
} on FormatException catch (_) { } on FormatException {
throw Exception( throw Exception(
'The value of -D$kDartDefines is not formatted correctly.\n' 'The value of -D$kDartDefines is not formatted correctly.\n'
'The value must be a JSON-encoded list of strings but was:\n' 'The value must be a JSON-encoded list of strings but was:\n'
......
...@@ -17,6 +17,7 @@ import 'build_system/depfile.dart'; ...@@ -17,6 +17,7 @@ import 'build_system/depfile.dart';
import 'build_system/targets/dart.dart'; import 'build_system/targets/dart.dart';
import 'build_system/targets/icon_tree_shaker.dart'; import 'build_system/targets/icon_tree_shaker.dart';
import 'cache.dart'; import 'cache.dart';
import 'convert.dart';
import 'dart/package_map.dart'; import 'dart/package_map.dart';
import 'devfs.dart'; import 'devfs.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
...@@ -54,7 +55,7 @@ class BundleBuilder { ...@@ -54,7 +55,7 @@ class BundleBuilder {
/// The default `manifestPath` is `pubspec.yaml` /// The default `manifestPath` is `pubspec.yaml`
Future<void> build({ Future<void> build({
@required TargetPlatform platform, @required TargetPlatform platform,
BuildMode buildMode, BuildInfo buildInfo,
String mainPath, String mainPath,
String manifestPath = defaultManifestPath, String manifestPath = defaultManifestPath,
String applicationKernelFilePath, String applicationKernelFilePath,
...@@ -77,7 +78,7 @@ class BundleBuilder { ...@@ -77,7 +78,7 @@ class BundleBuilder {
packagesPath ??= globals.fs.path.absolute(PackageMap.globalPackagesPath); packagesPath ??= globals.fs.path.absolute(PackageMap.globalPackagesPath);
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
await buildWithAssemble( await buildWithAssemble(
buildMode: buildMode ?? BuildMode.debug, buildMode: buildInfo.mode,
targetPlatform: platform, targetPlatform: platform,
mainPath: mainPath, mainPath: mainPath,
flutterProject: flutterProject, flutterProject: flutterProject,
...@@ -86,6 +87,7 @@ class BundleBuilder { ...@@ -86,6 +87,7 @@ class BundleBuilder {
precompiled: precompiledSnapshot, precompiled: precompiledSnapshot,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
treeShakeIcons: treeShakeIcons, treeShakeIcons: treeShakeIcons,
dartDefines: buildInfo.dartDefines,
); );
// Work around for flutter_tester placing kernel artifacts in odd places. // Work around for flutter_tester placing kernel artifacts in odd places.
if (applicationKernelFilePath != null) { if (applicationKernelFilePath != null) {
...@@ -111,6 +113,7 @@ Future<void> buildWithAssemble({ ...@@ -111,6 +113,7 @@ Future<void> buildWithAssemble({
@required bool precompiled, @required bool precompiled,
bool trackWidgetCreation, bool trackWidgetCreation,
@required bool treeShakeIcons, @required bool treeShakeIcons,
List<String> dartDefines,
}) async { }) async {
// If the precompiled flag was not passed, force us into debug mode. // If the precompiled flag was not passed, force us into debug mode.
buildMode = precompiled ? buildMode : BuildMode.debug; buildMode = precompiled ? buildMode : BuildMode.debug;
...@@ -126,6 +129,8 @@ Future<void> buildWithAssemble({ ...@@ -126,6 +129,8 @@ Future<void> buildWithAssemble({
kTargetPlatform: getNameForTargetPlatform(targetPlatform), kTargetPlatform: getNameForTargetPlatform(targetPlatform),
kTrackWidgetCreation: trackWidgetCreation?.toString(), kTrackWidgetCreation: trackWidgetCreation?.toString(),
kIconTreeShakerFlag: treeShakeIcons ? 'true' : null, kIconTreeShakerFlag: treeShakeIcons ? 'true' : null,
if (dartDefines != null && dartDefines.isNotEmpty)
kDartDefines: jsonEncode(dartDefines),
}, },
); );
final Target target = buildMode == BuildMode.debug final Target target = buildMode == BuildMode.debug
......
...@@ -61,7 +61,7 @@ class AttachCommand extends FlutterCommand { ...@@ -61,7 +61,7 @@ class AttachCommand extends FlutterCommand {
usesIpv6Flag(); usesIpv6Flag();
usesFilesystemOptions(hide: !verboseHelp); usesFilesystemOptions(hide: !verboseHelp);
usesFuchsiaOptions(hide: !verboseHelp); usesFuchsiaOptions(hide: !verboseHelp);
usesDartDefines(); usesDartDefineOption();
argParser argParser
..addOption( ..addOption(
'debug-port', 'debug-port',
...@@ -201,7 +201,6 @@ class AttachCommand extends FlutterCommand { ...@@ -201,7 +201,6 @@ class AttachCommand extends FlutterCommand {
stdoutCommandResponse, stdoutCommandResponse,
notifyingLogger: NotifyingLogger(), notifyingLogger: NotifyingLogger(),
logToStdout: true, logToStdout: true,
dartDefines: dartDefines,
) )
: null; : null;
...@@ -348,14 +347,12 @@ class AttachCommand extends FlutterCommand { ...@@ -348,14 +347,12 @@ class AttachCommand extends FlutterCommand {
final FlutterDevice flutterDevice = await FlutterDevice.create( final FlutterDevice flutterDevice = await FlutterDevice.create(
device, device,
flutterProject: flutterProject, flutterProject: flutterProject,
trackWidgetCreation: boolArg('track-widget-creation'),
fileSystemRoots: stringsArg('filesystem-root'), fileSystemRoots: stringsArg('filesystem-root'),
fileSystemScheme: stringArg('filesystem-scheme'), fileSystemScheme: stringArg('filesystem-scheme'),
viewFilter: stringArg('isolate-filter'), viewFilter: stringArg('isolate-filter'),
target: stringArg('target'), target: stringArg('target'),
targetModel: TargetModel(stringArg('target-model')), targetModel: TargetModel(stringArg('target-model')),
buildMode: getBuildMode(), buildInfo: getBuildInfo(),
dartDefines: dartDefines,
); );
flutterDevice.observatoryUris = observatoryUris; flutterDevice.observatoryUris = observatoryUris;
final List<FlutterDevice> flutterDevices = <FlutterDevice>[flutterDevice]; final List<FlutterDevice> flutterDevices = <FlutterDevice>[flutterDevice];
......
...@@ -19,7 +19,7 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen ...@@ -19,7 +19,7 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen
usesTargetOption(); usesTargetOption();
addBuildModeFlags(); addBuildModeFlags();
usesPubOption(); usesPubOption();
usesDartDefines(); usesDartDefineOption();
argParser argParser
..addOption('output-dir', defaultsTo: getAotBuildDirectory()) ..addOption('output-dir', defaultsTo: getAotBuildDirectory())
..addOption('target-platform', ..addOption('target-platform',
...@@ -42,10 +42,6 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen ...@@ -42,10 +42,6 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen
splitCommas: true, splitCommas: true,
hide: true, hide: true,
) )
..addMultiOption(FlutterOptions.kExtraGenSnapshotOptions,
splitCommas: true,
hide: true,
)
..addFlag('bitcode', ..addFlag('bitcode',
defaultsTo: kBitcodeEnabledDefault, defaultsTo: kBitcodeEnabledDefault,
help: 'Build the AOT bundle with bitcode. Requires a compatible bitcode engine.', help: 'Build the AOT bundle with bitcode. Requires a compatible bitcode engine.',
...@@ -70,7 +66,7 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen ...@@ -70,7 +66,7 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen
final String targetPlatform = stringArg('target-platform'); final String targetPlatform = stringArg('target-platform');
final TargetPlatform platform = getTargetPlatformForName(targetPlatform); final TargetPlatform platform = getTargetPlatformForName(targetPlatform);
final String outputPath = stringArg('output-dir') ?? getAotBuildDirectory(); final String outputPath = stringArg('output-dir') ?? getAotBuildDirectory();
final BuildMode buildMode = getBuildMode(); final BuildInfo buildInfo = getBuildInfo();
if (platform == null) { if (platform == null) {
throwToolExit('Unknown platform: $targetPlatform'); throwToolExit('Unknown platform: $targetPlatform');
} }
...@@ -80,16 +76,13 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen ...@@ -80,16 +76,13 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen
await aotBuilder.build( await aotBuilder.build(
platform: platform, platform: platform,
outputPath: outputPath, outputPath: outputPath,
buildMode: buildMode, buildInfo: buildInfo,
mainDartFile: findMainDartFile(targetFile), mainDartFile: findMainDartFile(targetFile),
bitcode: boolArg('bitcode'), bitcode: boolArg('bitcode'),
quiet: boolArg('quiet'), quiet: boolArg('quiet'),
reportTimings: boolArg('report-timings'), reportTimings: boolArg('report-timings'),
iosBuildArchs: stringsArg('ios-arch').map<DarwinArch>(getIOSArchForName), iosBuildArchs: stringsArg('ios-arch').map<DarwinArch>(getIOSArchForName),
extraFrontEndOptions: stringsArg(FlutterOptions.kExtraFrontEndOptions), extraFrontEndOptions: stringsArg(FlutterOptions.kExtraFrontEndOptions),
extraGenSnapshotOptions: stringsArg(FlutterOptions.kExtraGenSnapshotOptions),
dartDefines: dartDefines,
treeShakeIcons: boolArg('tree-shake-icons'),
); );
return FlutterCommandResult.success(); return FlutterCommandResult.success();
} }
......
...@@ -28,6 +28,7 @@ class BuildApkCommand extends BuildSubCommand { ...@@ -28,6 +28,7 @@ class BuildApkCommand extends BuildSubCommand {
addShrinkingFlag(); addShrinkingFlag();
addSplitDebugInfoOption(); addSplitDebugInfoOption();
addDartObfuscationOption(); addDartObfuscationOption();
usesDartDefineOption();
argParser argParser
..addFlag('split-per-abi', ..addFlag('split-per-abi',
negatable: false, negatable: false,
......
...@@ -26,7 +26,7 @@ class BuildAppBundleCommand extends BuildSubCommand { ...@@ -26,7 +26,7 @@ class BuildAppBundleCommand extends BuildSubCommand {
addShrinkingFlag(); addShrinkingFlag();
addSplitDebugInfoOption(); addSplitDebugInfoOption();
addDartObfuscationOption(); addDartObfuscationOption();
usesDartDefineOption();
argParser argParser
..addFlag('track-widget-creation', negatable: false, hide: !verboseHelp) ..addFlag('track-widget-creation', negatable: false, hide: !verboseHelp)
..addMultiOption('target-platform', ..addMultiOption('target-platform',
......
...@@ -53,11 +53,11 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -53,11 +53,11 @@ class BuildBundleCommand extends BuildSubCommand {
splitCommas: true, splitCommas: true,
hide: true, hide: true,
) )
..addOption('asset-dir', defaultsTo: getAssetBuildDirectory())
..addMultiOption(FlutterOptions.kExtraGenSnapshotOptions, ..addMultiOption(FlutterOptions.kExtraGenSnapshotOptions,
splitCommas: true, splitCommas: true,
hide: true, hide: true,
) )
..addOption('asset-dir', defaultsTo: getAssetBuildDirectory())
..addFlag('report-licensed-packages', ..addFlag('report-licensed-packages',
help: 'Whether to report the names of all the packages that are included ' help: 'Whether to report the names of all the packages that are included '
"in the application's LICENSE file.", "in the application's LICENSE file.",
...@@ -122,11 +122,11 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -122,11 +122,11 @@ class BuildBundleCommand extends BuildSubCommand {
break; break;
} }
final BuildMode buildMode = getBuildMode(); final BuildInfo buildInfo = getBuildInfo();
await bundleBuilder.build( await bundleBuilder.build(
platform: platform, platform: platform,
buildMode: buildMode, buildInfo: buildInfo,
mainPath: targetFile, mainPath: targetFile,
manifestPath: stringArg('manifest'), manifestPath: stringArg('manifest'),
depfilePath: stringArg('depfile'), depfilePath: stringArg('depfile'),
...@@ -135,8 +135,8 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -135,8 +135,8 @@ class BuildBundleCommand extends BuildSubCommand {
precompiledSnapshot: boolArg('precompiled'), precompiledSnapshot: boolArg('precompiled'),
reportLicensedPackages: boolArg('report-licensed-packages'), reportLicensedPackages: boolArg('report-licensed-packages'),
trackWidgetCreation: boolArg('track-widget-creation'), trackWidgetCreation: boolArg('track-widget-creation'),
extraFrontEndOptions: stringsArg(FlutterOptions.kExtraFrontEndOptions), extraFrontEndOptions: buildInfo.extraFrontEndOptions,
extraGenSnapshotOptions: stringsArg(FlutterOptions.kExtraGenSnapshotOptions), extraGenSnapshotOptions: buildInfo.extraGenSnapshotOptions,
fileSystemScheme: stringArg('filesystem-scheme'), fileSystemScheme: stringArg('filesystem-scheme'),
fileSystemRoots: stringsArg('filesystem-root'), fileSystemRoots: stringsArg('filesystem-root'),
treeShakeIcons: boolArg('tree-shake-icons'), treeShakeIcons: boolArg('tree-shake-icons'),
......
...@@ -27,6 +27,7 @@ class BuildIOSCommand extends BuildSubCommand { ...@@ -27,6 +27,7 @@ class BuildIOSCommand extends BuildSubCommand {
usesBuildNumberOption(); usesBuildNumberOption();
usesBuildNameOption(); usesBuildNameOption();
addDartObfuscationOption(); addDartObfuscationOption();
usesDartDefineOption();
argParser argParser
..addFlag('simulator', ..addFlag('simulator',
help: 'Build for the iOS simulator instead of the device.', help: 'Build for the iOS simulator instead of the device.',
......
...@@ -48,7 +48,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand { ...@@ -48,7 +48,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
usesTargetOption(); usesTargetOption();
usesFlavorOption(); usesFlavorOption();
usesPubOption(); usesPubOption();
usesDartDefines(); usesDartDefineOption();
addSplitDebugInfoOption(); addSplitDebugInfoOption();
addDartObfuscationOption(); addDartObfuscationOption();
argParser argParser
...@@ -120,17 +120,17 @@ class BuildIOSFrameworkCommand extends BuildSubCommand { ...@@ -120,17 +120,17 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
FlutterProject _project; FlutterProject _project;
List<BuildMode> get buildModes { List<BuildInfo> get buildInfos {
final List<BuildMode> buildModes = <BuildMode>[]; final List<BuildInfo> buildModes = <BuildInfo>[];
if (boolArg('debug')) { if (boolArg('debug')) {
buildModes.add(BuildMode.debug); buildModes.add(BuildInfo.debug);
} }
if (boolArg('profile')) { if (boolArg('profile')) {
buildModes.add(BuildMode.profile); buildModes.add(BuildInfo.profile);
} }
if (boolArg('release')) { if (boolArg('release')) {
buildModes.add(BuildMode.release); buildModes.add(BuildInfo.release);
} }
return buildModes; return buildModes;
...@@ -154,7 +154,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand { ...@@ -154,7 +154,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
if (boolArg('xcframework') && globals.xcode.majorVersion < 11) { if (boolArg('xcframework') && globals.xcode.majorVersion < 11) {
throwToolExit('--xcframework requires Xcode 11.'); throwToolExit('--xcframework requires Xcode 11.');
} }
if (buildModes.isEmpty) { if (buildInfos.isEmpty) {
throwToolExit('At least one of "--debug" or "--profile", or "--release" is required.'); throwToolExit('At least one of "--debug" or "--profile", or "--release" is required.');
} }
} }
...@@ -177,9 +177,9 @@ class BuildIOSFrameworkCommand extends BuildSubCommand { ...@@ -177,9 +177,9 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
final Directory outputDirectory = globals.fs.directory(globals.fs.path.absolute(globals.fs.path.normalize(outputArgument))); final Directory outputDirectory = globals.fs.directory(globals.fs.path.absolute(globals.fs.path.normalize(outputArgument)));
final String productBundleIdentifier = await _project.ios.productBundleIdentifier; final String productBundleIdentifier = await _project.ios.productBundleIdentifier;
for (final BuildMode mode in buildModes) { for (final BuildInfo buildInfo in buildInfos) {
globals.printStatus('Building frameworks for $productBundleIdentifier in ${getNameForBuildMode(mode)} mode...'); globals.printStatus('Building frameworks for $productBundleIdentifier in ${getNameForBuildMode(buildInfo.mode)} mode...');
final String xcodeBuildConfiguration = toTitleCase(getNameForBuildMode(mode)); final String xcodeBuildConfiguration = toTitleCase(getNameForBuildMode(buildInfo.mode));
final Directory modeDirectory = outputDirectory.childDirectory(xcodeBuildConfiguration); final Directory modeDirectory = outputDirectory.childDirectory(xcodeBuildConfiguration);
if (modeDirectory.existsSync()) { if (modeDirectory.existsSync()) {
...@@ -191,19 +191,19 @@ class BuildIOSFrameworkCommand extends BuildSubCommand { ...@@ -191,19 +191,19 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
if (boolArg('cocoapods')) { if (boolArg('cocoapods')) {
// FlutterVersion.instance kicks off git processing which can sometimes fail, so don't try it until needed. // FlutterVersion.instance kicks off git processing which can sometimes fail, so don't try it until needed.
_flutterVersion ??= globals.flutterVersion; _flutterVersion ??= globals.flutterVersion;
produceFlutterPodspec(mode, modeDirectory, force: boolArg('force')); produceFlutterPodspec(buildInfo.mode, modeDirectory, force: boolArg('force'));
} else { } else {
// Copy Flutter.framework. // Copy Flutter.framework.
await _produceFlutterFramework(mode, modeDirectory); await _produceFlutterFramework(buildInfo, modeDirectory);
} }
// Build aot, create module.framework and copy. // Build aot, create module.framework and copy.
await _produceAppFramework(mode, iPhoneBuildOutput, simulatorBuildOutput, modeDirectory); await _produceAppFramework(buildInfo, iPhoneBuildOutput, simulatorBuildOutput, modeDirectory);
// Build and copy plugins. // Build and copy plugins.
await processPodsIfNeeded(_project.ios, getIosBuildDirectory(), mode); await processPodsIfNeeded(_project.ios, getIosBuildDirectory(), buildInfo.mode);
if (hasPlugins(_project)) { if (hasPlugins(_project)) {
await _producePlugins(mode, xcodeBuildConfiguration, iPhoneBuildOutput, simulatorBuildOutput, modeDirectory, outputDirectory); await _producePlugins(buildInfo.mode, xcodeBuildConfiguration, iPhoneBuildOutput, simulatorBuildOutput, modeDirectory, outputDirectory);
} }
final Status status = globals.logger.startProgress( final Status status = globals.logger.startProgress(
...@@ -285,7 +285,7 @@ end ...@@ -285,7 +285,7 @@ end
} }
Future<void> _produceFlutterFramework( Future<void> _produceFlutterFramework(
BuildMode mode, BuildInfo buildInfo,
Directory modeDirectory, Directory modeDirectory,
) async { ) async {
final Status status = globals.logger.startProgress( final Status status = globals.logger.startProgress(
...@@ -295,7 +295,7 @@ end ...@@ -295,7 +295,7 @@ end
final String engineCacheFlutterFrameworkDirectory = globals.artifacts.getArtifactPath( final String engineCacheFlutterFrameworkDirectory = globals.artifacts.getArtifactPath(
Artifact.flutterFramework, Artifact.flutterFramework,
platform: TargetPlatform.ios, platform: TargetPlatform.ios,
mode: mode, mode: buildInfo.mode,
); );
final String flutterFrameworkFileName = globals.fs.path.basename( final String flutterFrameworkFileName = globals.fs.path.basename(
engineCacheFlutterFrameworkDirectory, engineCacheFlutterFrameworkDirectory,
...@@ -311,7 +311,7 @@ end ...@@ -311,7 +311,7 @@ end
fatFlutterFrameworkCopy, fatFlutterFrameworkCopy,
); );
if (mode != BuildMode.debug) { if (buildInfo.mode != BuildMode.debug) {
final File fatFlutterFrameworkBinary = fatFlutterFrameworkCopy.childFile('Flutter'); final File fatFlutterFrameworkBinary = fatFlutterFrameworkCopy.childFile('Flutter');
// Remove simulator architecture in profile and release mode. // Remove simulator architecture in profile and release mode.
...@@ -331,7 +331,7 @@ end ...@@ -331,7 +331,7 @@ end
if (lipoResult.exitCode != 0) { if (lipoResult.exitCode != 0) {
throwToolExit( throwToolExit(
'Unable to remove simulator architecture in $mode: ${lipoResult.stderr}', 'Unable to remove simulator architecture in ${buildInfo.mode}: ${lipoResult.stderr}',
); );
} }
} }
...@@ -339,23 +339,23 @@ end ...@@ -339,23 +339,23 @@ end
status.stop(); status.stop();
} }
await _produceXCFramework(mode, fatFlutterFrameworkCopy); await _produceXCFramework(buildInfo, fatFlutterFrameworkCopy);
} }
Future<void> _produceAppFramework(BuildMode mode, Directory iPhoneBuildOutput, Directory simulatorBuildOutput, Directory modeDirectory) async { Future<void> _produceAppFramework(BuildInfo buildInfo, Directory iPhoneBuildOutput, Directory simulatorBuildOutput, Directory modeDirectory) async {
const String appFrameworkName = 'App.framework'; const String appFrameworkName = 'App.framework';
final Directory destinationAppFrameworkDirectory = modeDirectory.childDirectory(appFrameworkName); final Directory destinationAppFrameworkDirectory = modeDirectory.childDirectory(appFrameworkName);
if (mode == BuildMode.debug) { if (buildInfo.mode == BuildMode.debug) {
final Status status = globals.logger.startProgress(' ├─Adding placeholder App.framework for debug...', timeout: timeoutConfiguration.fastOperation); final Status status = globals.logger.startProgress(' ├─Adding placeholder App.framework for debug...', timeout: timeoutConfiguration.fastOperation);
try { try {
destinationAppFrameworkDirectory.createSync(recursive: true); destinationAppFrameworkDirectory.createSync(recursive: true);
await _produceStubAppFrameworkIfNeeded(mode, iPhoneBuildOutput, simulatorBuildOutput, destinationAppFrameworkDirectory); await _produceStubAppFrameworkIfNeeded(buildInfo, iPhoneBuildOutput, simulatorBuildOutput, destinationAppFrameworkDirectory);
} finally { } finally {
status.stop(); status.stop();
} }
} else { } else {
await _produceAotAppFrameworkIfNeeded(mode, modeDirectory); await _produceAotAppFrameworkIfNeeded(buildInfo, modeDirectory);
} }
final File sourceInfoPlist = _project.ios.hostAppRoot.childDirectory('Flutter').childFile('AppFrameworkInfo.plist'); final File sourceInfoPlist = _project.ios.hostAppRoot.childDirectory('Flutter').childFile('AppFrameworkInfo.plist');
...@@ -368,21 +368,21 @@ end ...@@ -368,21 +368,21 @@ end
try { try {
await _bundleBuilder.build( await _bundleBuilder.build(
platform: TargetPlatform.ios, platform: TargetPlatform.ios,
buildMode: mode, buildInfo: buildInfo,
// Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978. // Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
mainPath: globals.fs.path.absolute(targetFile), mainPath: globals.fs.path.absolute(targetFile),
assetDirPath: destinationAppFrameworkDirectory.childDirectory('flutter_assets').path, assetDirPath: destinationAppFrameworkDirectory.childDirectory('flutter_assets').path,
precompiledSnapshot: mode != BuildMode.debug, precompiledSnapshot: buildInfo.mode != BuildMode.debug,
treeShakeIcons: boolArg('tree-shake-icons') treeShakeIcons: boolArg('tree-shake-icons')
); );
} finally { } finally {
status.stop(); status.stop();
} }
await _produceXCFramework(mode, destinationAppFrameworkDirectory); await _produceXCFramework(buildInfo, destinationAppFrameworkDirectory);
} }
Future<void> _produceStubAppFrameworkIfNeeded(BuildMode mode, Directory iPhoneBuildOutput, Directory simulatorBuildOutput, Directory destinationAppFrameworkDirectory) async { Future<void> _produceStubAppFrameworkIfNeeded(BuildInfo buildInfo, Directory iPhoneBuildOutput, Directory simulatorBuildOutput, Directory destinationAppFrameworkDirectory) async {
if (mode != BuildMode.debug) { if (buildInfo.mode != BuildMode.debug) {
return; return;
} }
const String appFrameworkName = 'App.framework'; const String appFrameworkName = 'App.framework';
...@@ -417,10 +417,10 @@ end ...@@ -417,10 +417,10 @@ end
} }
Future<void> _produceAotAppFrameworkIfNeeded( Future<void> _produceAotAppFrameworkIfNeeded(
BuildMode mode, BuildInfo buildInfo,
Directory destinationDirectory, Directory destinationDirectory,
) async { ) async {
if (mode == BuildMode.debug) { if (buildInfo.mode == BuildMode.debug) {
return; return;
} }
final Status status = globals.logger.startProgress( final Status status = globals.logger.startProgress(
...@@ -431,15 +431,13 @@ end ...@@ -431,15 +431,13 @@ end
await _aotBuilder.build( await _aotBuilder.build(
platform: TargetPlatform.ios, platform: TargetPlatform.ios,
outputPath: destinationDirectory.path, outputPath: destinationDirectory.path,
buildMode: mode, buildInfo: buildInfo,
// Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978. // Relative paths show noise in the compiler https://github.com/dart-lang/sdk/issues/37978.
mainDartFile: globals.fs.path.absolute(targetFile), mainDartFile: globals.fs.path.absolute(targetFile),
quiet: true, quiet: true,
bitcode: true, bitcode: true,
reportTimings: false, reportTimings: false,
iosBuildArchs: <DarwinArch>[DarwinArch.armv7, DarwinArch.arm64], iosBuildArchs: <DarwinArch>[DarwinArch.armv7, DarwinArch.arm64],
dartDefines: dartDefines,
treeShakeIcons: boolArg('tree-shake-icons'),
); );
} finally { } finally {
status.stop(); status.stop();
...@@ -609,7 +607,7 @@ end ...@@ -609,7 +607,7 @@ end
} }
} }
Future<void> _produceXCFramework(BuildMode mode, Directory fatFramework) async { Future<void> _produceXCFramework(BuildInfo buildInfo, Directory fatFramework) async {
if (boolArg('xcframework')) { if (boolArg('xcframework')) {
final String frameworkBinaryName = globals.fs.path.basenameWithoutExtension( final String frameworkBinaryName = globals.fs.path.basenameWithoutExtension(
fatFramework.basename); fatFramework.basename);
...@@ -619,10 +617,10 @@ end ...@@ -619,10 +617,10 @@ end
timeout: timeoutConfiguration.slowOperation, timeout: timeoutConfiguration.slowOperation,
); );
try { try {
if (mode == BuildMode.debug) { if (buildInfo.mode == BuildMode.debug) {
await _produceDebugXCFramework(fatFramework, frameworkBinaryName); await _produceDebugXCFramework(fatFramework, frameworkBinaryName);
} else { } else {
await _produceNonDebugXCFramework(mode, fatFramework, frameworkBinaryName); await _produceNonDebugXCFramework(buildInfo, fatFramework, frameworkBinaryName);
} }
} finally { } finally {
status.stop(); status.stop();
...@@ -731,7 +729,7 @@ end ...@@ -731,7 +729,7 @@ end
} }
Future<void> _produceNonDebugXCFramework( Future<void> _produceNonDebugXCFramework(
BuildMode mode, BuildInfo buildInfo,
Directory fatFramework, Directory fatFramework,
String frameworkBinaryName, String frameworkBinaryName,
) async { ) async {
......
...@@ -19,7 +19,7 @@ class BuildWebCommand extends BuildSubCommand { ...@@ -19,7 +19,7 @@ class BuildWebCommand extends BuildSubCommand {
usesTargetOption(); usesTargetOption();
usesPubOption(); usesPubOption();
addBuildModeFlags(excludeDebug: true); addBuildModeFlags(excludeDebug: true);
usesDartDefines(); usesDartDefineOption();
argParser.addFlag('web-initialize-platform', argParser.addFlag('web-initialize-platform',
defaultsTo: true, defaultsTo: true,
negatable: true, negatable: true,
...@@ -65,8 +65,7 @@ class BuildWebCommand extends BuildSubCommand { ...@@ -65,8 +65,7 @@ class BuildWebCommand extends BuildSubCommand {
target, target,
buildInfo, buildInfo,
boolArg('web-initialize-platform'), boolArg('web-initialize-platform'),
dartDefines, boolArg('csp'),
boolArg('csp')
); );
return FlutterCommandResult.success(); return FlutterCommandResult.success();
} }
......
...@@ -35,9 +35,7 @@ const String protocolVersion = '0.5.3'; ...@@ -35,9 +35,7 @@ const String protocolVersion = '0.5.3';
/// It can be shutdown with a `daemon.shutdown` command (or by killing the /// It can be shutdown with a `daemon.shutdown` command (or by killing the
/// process). /// process).
class DaemonCommand extends FlutterCommand { class DaemonCommand extends FlutterCommand {
DaemonCommand({ this.hidden = false }) { DaemonCommand({ this.hidden = false });
usesDartDefines();
}
@override @override
final String name = 'daemon'; final String name = 'daemon';
...@@ -62,7 +60,6 @@ class DaemonCommand extends FlutterCommand { ...@@ -62,7 +60,6 @@ class DaemonCommand extends FlutterCommand {
final Daemon daemon = Daemon( final Daemon daemon = Daemon(
stdinCommandStream, stdoutCommandResponse, stdinCommandStream, stdoutCommandResponse,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: dartDefines,
); );
final int code = await daemon.onExit; final int code = await daemon.onExit;
...@@ -88,15 +85,7 @@ class Daemon { ...@@ -88,15 +85,7 @@ class Daemon {
this.sendCommand, { this.sendCommand, {
this.notifyingLogger, this.notifyingLogger,
this.logToStdout = false, this.logToStdout = false,
@required this.dartDefines,
}) { }) {
if (dartDefines == null) {
throw Exception(
'dartDefines must not be null. This is a bug in Flutter.\n'
'Please file an issue at https://github.com/flutter/flutter/issues/new/choose',
);
}
// Set up domains. // Set up domains.
_registerDomain(daemonDomain = DaemonDomain(this)); _registerDomain(daemonDomain = DaemonDomain(this));
_registerDomain(appDomain = AppDomain(this)); _registerDomain(appDomain = AppDomain(this));
...@@ -125,7 +114,6 @@ class Daemon { ...@@ -125,7 +114,6 @@ class Daemon {
final DispatchCommand sendCommand; final DispatchCommand sendCommand;
final NotifyingLogger notifyingLogger; final NotifyingLogger notifyingLogger;
final bool logToStdout; final bool logToStdout;
final List<String> dartDefines;
final Completer<int> _onExitCompleter = Completer<int>(); final Completer<int> _onExitCompleter = Completer<int>();
final Map<String, Domain> _domainMap = <String, Domain>{}; final Map<String, Domain> _domainMap = <String, Domain>{};
...@@ -481,11 +469,9 @@ class AppDomain extends Domain { ...@@ -481,11 +469,9 @@ class AppDomain extends Domain {
final FlutterDevice flutterDevice = await FlutterDevice.create( final FlutterDevice flutterDevice = await FlutterDevice.create(
device, device,
flutterProject: flutterProject, flutterProject: flutterProject,
trackWidgetCreation: trackWidgetCreation,
viewFilter: isolateFilter, viewFilter: isolateFilter,
target: target, target: target,
buildMode: options.buildInfo.mode, buildInfo: options.buildInfo,
dartDefines: daemon.dartDefines,
); );
ResidentRunner runner; ResidentRunner runner;
...@@ -498,7 +484,6 @@ class AppDomain extends Domain { ...@@ -498,7 +484,6 @@ class AppDomain extends Domain {
debuggingOptions: options, debuggingOptions: options,
ipv6: ipv6, ipv6: ipv6,
stayResident: true, stayResident: true,
dartDefines: daemon.dartDefines,
urlTunneller: options.webEnableExposeUrl ? daemon.daemonDomain.exposeUrl : null, urlTunneller: options.webEnableExposeUrl ? daemon.daemonDomain.exposeUrl : null,
); );
} else if (enableHotReload) { } else if (enableHotReload) {
......
...@@ -144,11 +144,12 @@ class DriveCommand extends RunCommandBase { ...@@ -144,11 +144,12 @@ class DriveCommand extends RunCommandBase {
String observatoryUri; String observatoryUri;
ResidentRunner residentRunner; ResidentRunner residentRunner;
final BuildInfo buildInfo = getBuildInfo();
final bool isWebPlatform = await device.targetPlatform == TargetPlatform.web_javascript; final bool isWebPlatform = await device.targetPlatform == TargetPlatform.web_javascript;
if (argResults['use-existing-app'] == null) { if (argResults['use-existing-app'] == null) {
globals.printStatus('Starting application: $targetFile'); globals.printStatus('Starting application: $targetFile');
if (getBuildInfo().isRelease && !isWebPlatform) { if (buildInfo.isRelease && !isWebPlatform) {
// This is because we need VM service to be able to drive the app. // This is because we need VM service to be able to drive the app.
// For Flutter Web, testing in release mode is allowed. // For Flutter Web, testing in release mode is allowed.
throwToolExit( throwToolExit(
...@@ -159,7 +160,7 @@ class DriveCommand extends RunCommandBase { ...@@ -159,7 +160,7 @@ class DriveCommand extends RunCommandBase {
); );
} }
if (isWebPlatform && getBuildInfo().isDebug) { if (isWebPlatform && buildInfo.isDebug) {
// TODO(angjieli): remove this once running against // TODO(angjieli): remove this once running against
// target under test_driver in debug mode is supported // target under test_driver in debug mode is supported
throwToolExit( throwToolExit(
...@@ -178,18 +179,16 @@ class DriveCommand extends RunCommandBase { ...@@ -178,18 +179,16 @@ class DriveCommand extends RunCommandBase {
final FlutterDevice flutterDevice = await FlutterDevice.create( final FlutterDevice flutterDevice = await FlutterDevice.create(
device, device,
flutterProject: flutterProject, flutterProject: flutterProject,
trackWidgetCreation: boolArg('track-widget-creation'),
target: targetFile, target: targetFile,
buildMode: getBuildMode() buildInfo: buildInfo
); );
residentRunner = webRunnerFactory.createWebRunner( residentRunner = webRunnerFactory.createWebRunner(
flutterDevice, flutterDevice,
target: targetFile, target: targetFile,
flutterProject: flutterProject, flutterProject: flutterProject,
ipv6: ipv6, ipv6: ipv6,
debuggingOptions: DebuggingOptions.enabled(getBuildInfo()), debuggingOptions: DebuggingOptions.enabled(buildInfo),
stayResident: false, stayResident: false,
dartDefines: dartDefines,
urlTunneller: null, urlTunneller: null,
); );
final Completer<void> appStartedCompleter = Completer<void>.sync(); final Completer<void> appStartedCompleter = Completer<void>.sync();
......
...@@ -30,7 +30,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment ...@@ -30,7 +30,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
// Used by run and drive commands. // Used by run and drive commands.
RunCommandBase({ bool verboseHelp = false }) { RunCommandBase({ bool verboseHelp = false }) {
addBuildModeFlags(defaultToRelease: false, verboseHelp: verboseHelp); addBuildModeFlags(defaultToRelease: false, verboseHelp: verboseHelp);
usesDartDefines(); usesDartDefineOption();
usesFlavorOption(); usesFlavorOption();
argParser argParser
..addFlag('trace-startup', ..addFlag('trace-startup',
...@@ -204,7 +204,6 @@ class RunCommand extends RunCommandBase { ...@@ -204,7 +204,6 @@ class RunCommand extends RunCommandBase {
'cannot be paired with --use-application-binary.' 'cannot be paired with --use-application-binary.'
) )
..addOption(FlutterOptions.kExtraFrontEndOptions, hide: true) ..addOption(FlutterOptions.kExtraFrontEndOptions, hide: true)
..addOption(FlutterOptions.kExtraGenSnapshotOptions, hide: true)
..addMultiOption(FlutterOptions.kEnableExperiment, ..addMultiOption(FlutterOptions.kEnableExperiment,
splitCommas: true, splitCommas: true,
hide: true, hide: true,
...@@ -403,7 +402,6 @@ class RunCommand extends RunCommandBase { ...@@ -403,7 +402,6 @@ class RunCommand extends RunCommandBase {
stdoutCommandResponse, stdoutCommandResponse,
notifyingLogger: NotifyingLogger(), notifyingLogger: NotifyingLogger(),
logToStdout: true, logToStdout: true,
dartDefines: dartDefines,
); );
AppInstance app; AppInstance app;
try { try {
...@@ -483,14 +481,12 @@ class RunCommand extends RunCommandBase { ...@@ -483,14 +481,12 @@ class RunCommand extends RunCommandBase {
await FlutterDevice.create( await FlutterDevice.create(
device, device,
flutterProject: flutterProject, flutterProject: flutterProject,
trackWidgetCreation: boolArg('track-widget-creation'),
fileSystemRoots: stringsArg('filesystem-root'), fileSystemRoots: stringsArg('filesystem-root'),
fileSystemScheme: stringArg('filesystem-scheme'), fileSystemScheme: stringArg('filesystem-scheme'),
viewFilter: stringArg('isolate-filter'), viewFilter: stringArg('isolate-filter'),
experimentalFlags: expFlags, experimentalFlags: expFlags,
target: stringArg('target'), target: stringArg('target'),
buildMode: getBuildMode(), buildInfo: getBuildInfo(),
dartDefines: dartDefines,
), ),
]; ];
// Only support "web mode" with a single web device due to resident runner // Only support "web mode" with a single web device due to resident runner
...@@ -524,7 +520,6 @@ class RunCommand extends RunCommandBase { ...@@ -524,7 +520,6 @@ class RunCommand extends RunCommandBase {
ipv6: ipv6, ipv6: ipv6,
debuggingOptions: _createDebuggingOptions(), debuggingOptions: _createDebuggingOptions(),
stayResident: stayResident, stayResident: stayResident,
dartDefines: dartDefines,
urlTunneller: null, urlTunneller: null,
); );
} else { } else {
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:math' as math; import 'dart:math' as math;
import 'package:meta/meta.dart';
import '../application_package.dart'; import '../application_package.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/context.dart'; import '../base/context.dart';
...@@ -15,7 +13,6 @@ import '../base/io.dart'; ...@@ -15,7 +13,6 @@ import '../base/io.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../bundle.dart';
import '../convert.dart'; import '../convert.dart';
import '../device.dart'; import '../device.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
...@@ -420,20 +417,13 @@ class IOSSimulator extends Device { ...@@ -420,20 +417,13 @@ class IOSSimulator extends Device {
} }
Future<void> _setupUpdatedApplicationBundle(covariant BuildableIOSApp app, BuildInfo buildInfo, String mainPath) async { Future<void> _setupUpdatedApplicationBundle(covariant BuildableIOSApp app, BuildInfo buildInfo, String mainPath) async {
await sideloadUpdatedAssetsForInstalledApplicationBundle(buildInfo, mainPath);
// Step 1: Build the Xcode project. // Step 1: Build the Xcode project.
// The build mode for the simulator is always debug. // The build mode for the simulator is always debug.
assert(buildInfo.isDebug);
final BuildInfo debugBuildInfo = BuildInfo(BuildMode.debug, buildInfo.flavor,
trackWidgetCreation: buildInfo.trackWidgetCreation,
extraFrontEndOptions: buildInfo.extraFrontEndOptions,
extraGenSnapshotOptions: buildInfo.extraGenSnapshotOptions,
treeShakeIcons: buildInfo.treeShakeIcons);
final XcodeBuildResult buildResult = await buildXcodeProject( final XcodeBuildResult buildResult = await buildXcodeProject(
app: app, app: app,
buildInfo: debugBuildInfo, buildInfo: buildInfo,
targetOverride: mainPath, targetOverride: mainPath,
buildForDevice: false, buildForDevice: false,
); );
...@@ -452,19 +442,6 @@ class IOSSimulator extends Device { ...@@ -452,19 +442,6 @@ class IOSSimulator extends Device {
await SimControl.instance.install(id, globals.fs.path.absolute(bundle.path)); await SimControl.instance.install(id, globals.fs.path.absolute(bundle.path));
} }
@visibleForTesting
Future<void> sideloadUpdatedAssetsForInstalledApplicationBundle(BuildInfo buildInfo, String mainPath) {
// Run compiler to produce kernel file for the application.
return BundleBuilder().build(
platform: TargetPlatform.ios,
mainPath: mainPath,
precompiledSnapshot: false,
buildMode: buildInfo.mode,
trackWidgetCreation: buildInfo.trackWidgetCreation,
treeShakeIcons: false,
);
}
@override @override
Future<bool> stopApp(ApplicationPackage app) async { Future<bool> stopApp(ApplicationPackage app) async {
// Currently we don't have a way to stop an app running on iOS. // Currently we don't have a way to stop an app running on iOS.
......
...@@ -19,6 +19,7 @@ import '../base/terminal.dart'; ...@@ -19,6 +19,7 @@ import '../base/terminal.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../cache.dart'; import '../cache.dart';
import '../convert.dart';
import '../flutter_manifest.dart'; import '../flutter_manifest.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
...@@ -235,6 +236,10 @@ List<String> _xcodeBuildSettingsLines({ ...@@ -235,6 +236,10 @@ List<String> _xcodeBuildSettingsLines({
xcodeBuildSettings.add('TREE_SHAKE_ICONS=true'); xcodeBuildSettings.add('TREE_SHAKE_ICONS=true');
} }
if (buildInfo.dartDefines?.isNotEmpty ?? false) {
xcodeBuildSettings.add('DART_DEFINES=${jsonEncode(buildInfo.dartDefines)}');
}
return xcodeBuildSettings; return xcodeBuildSettings;
} }
......
...@@ -33,7 +33,7 @@ import 'vmservice.dart'; ...@@ -33,7 +33,7 @@ import 'vmservice.dart';
class FlutterDevice { class FlutterDevice {
FlutterDevice( FlutterDevice(
this.device, { this.device, {
@required this.trackWidgetCreation, @required this.buildInfo,
this.fileSystemRoots, this.fileSystemRoots,
this.fileSystemScheme, this.fileSystemScheme,
this.viewFilter, this.viewFilter,
...@@ -41,38 +41,34 @@ class FlutterDevice { ...@@ -41,38 +41,34 @@ class FlutterDevice {
TargetPlatform targetPlatform, TargetPlatform targetPlatform,
List<String> experimentalFlags, List<String> experimentalFlags,
ResidentCompiler generator, ResidentCompiler generator,
@required BuildMode buildMode, }) : assert(buildInfo.trackWidgetCreation != null),
List<String> dartDefines,
}) : assert(trackWidgetCreation != null),
generator = generator ?? ResidentCompiler( generator = generator ?? ResidentCompiler(
globals.artifacts.getArtifactPath( globals.artifacts.getArtifactPath(
Artifact.flutterPatchedSdkPath, Artifact.flutterPatchedSdkPath,
platform: targetPlatform, platform: targetPlatform,
mode: buildMode, mode: buildInfo.mode,
), ),
buildMode: buildMode, buildMode: buildInfo.mode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
fileSystemRoots: fileSystemRoots ?? <String>[], fileSystemRoots: fileSystemRoots ?? <String>[],
fileSystemScheme: fileSystemScheme, fileSystemScheme: fileSystemScheme,
targetModel: targetModel, targetModel: targetModel,
experimentalFlags: experimentalFlags, experimentalFlags: experimentalFlags,
dartDefines: dartDefines, dartDefines: buildInfo.dartDefines,
); );
/// Create a [FlutterDevice] with optional code generation enabled. /// Create a [FlutterDevice] with optional code generation enabled.
static Future<FlutterDevice> create( static Future<FlutterDevice> create(
Device device, { Device device, {
@required FlutterProject flutterProject, @required FlutterProject flutterProject,
@required bool trackWidgetCreation,
@required String target, @required String target,
@required BuildMode buildMode, @required BuildInfo buildInfo,
List<String> fileSystemRoots, List<String> fileSystemRoots,
String fileSystemScheme, String fileSystemScheme,
String viewFilter, String viewFilter,
TargetModel targetModel = TargetModel.flutter, TargetModel targetModel = TargetModel.flutter,
List<String> experimentalFlags, List<String> experimentalFlags,
ResidentCompiler generator, ResidentCompiler generator,
List<String> dartDefines,
}) async { }) async {
ResidentCompiler generator; ResidentCompiler generator;
final TargetPlatform targetPlatform = await device.targetPlatform; final TargetPlatform targetPlatform = await device.targetPlatform;
...@@ -81,9 +77,9 @@ class FlutterDevice { ...@@ -81,9 +77,9 @@ class FlutterDevice {
} }
if (targetPlatform == TargetPlatform.web_javascript) { if (targetPlatform == TargetPlatform.web_javascript) {
generator = ResidentCompiler( generator = ResidentCompiler(
globals.artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: buildMode), globals.artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: buildInfo.mode),
buildMode: buildMode, buildMode: buildInfo.mode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
fileSystemRoots: fileSystemRoots ?? <String>[], fileSystemRoots: fileSystemRoots ?? <String>[],
// Override the filesystem scheme so that the frontend_server can find // Override the filesystem scheme so that the frontend_server can find
// the generated entrypoint code. // the generated entrypoint code.
...@@ -91,9 +87,9 @@ class FlutterDevice { ...@@ -91,9 +87,9 @@ class FlutterDevice {
targetModel: TargetModel.dartdevc, targetModel: TargetModel.dartdevc,
experimentalFlags: experimentalFlags, experimentalFlags: experimentalFlags,
platformDill: globals.fs.file(globals.artifacts platformDill: globals.fs.file(globals.artifacts
.getArtifactPath(Artifact.webPlatformKernelDill, mode: buildMode)) .getArtifactPath(Artifact.webPlatformKernelDill, mode: buildInfo.mode))
.absolute.uri.toString(), .absolute.uri.toString(),
dartDefines: dartDefines, dartDefines: buildInfo.dartDefines,
librariesSpec: globals.fs.file(globals.artifacts librariesSpec: globals.fs.file(globals.artifacts
.getArtifactPath(Artifact.flutterWebLibrariesJson)).uri.toString() .getArtifactPath(Artifact.flutterWebLibrariesJson)).uri.toString()
); );
...@@ -102,15 +98,15 @@ class FlutterDevice { ...@@ -102,15 +98,15 @@ class FlutterDevice {
globals.artifacts.getArtifactPath( globals.artifacts.getArtifactPath(
Artifact.flutterPatchedSdkPath, Artifact.flutterPatchedSdkPath,
platform: targetPlatform, platform: targetPlatform,
mode: buildMode, mode: buildInfo.mode,
), ),
buildMode: buildMode, buildMode: buildInfo.mode,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
fileSystemRoots: fileSystemRoots, fileSystemRoots: fileSystemRoots,
fileSystemScheme: fileSystemScheme, fileSystemScheme: fileSystemScheme,
targetModel: targetModel, targetModel: targetModel,
experimentalFlags: experimentalFlags, experimentalFlags: experimentalFlags,
dartDefines: dartDefines, dartDefines: buildInfo.dartDefines,
); );
} }
...@@ -123,7 +119,6 @@ class FlutterDevice { ...@@ -123,7 +119,6 @@ class FlutterDevice {
return FlutterDevice( return FlutterDevice(
device, device,
trackWidgetCreation: trackWidgetCreation,
fileSystemRoots: fileSystemRoots, fileSystemRoots: fileSystemRoots,
fileSystemScheme:fileSystemScheme, fileSystemScheme:fileSystemScheme,
viewFilter: viewFilter, viewFilter: viewFilter,
...@@ -131,13 +126,13 @@ class FlutterDevice { ...@@ -131,13 +126,13 @@ class FlutterDevice {
targetModel: targetModel, targetModel: targetModel,
targetPlatform: targetPlatform, targetPlatform: targetPlatform,
generator: generator, generator: generator,
buildMode: buildMode, buildInfo: buildInfo,
dartDefines: dartDefines,
); );
} }
final Device device; final Device device;
final ResidentCompiler generator; final ResidentCompiler generator;
final BuildInfo buildInfo;
Stream<Uri> observatoryUris; Stream<Uri> observatoryUris;
VMService vmService; VMService vmService;
DevFS devFS; DevFS devFS;
...@@ -147,7 +142,6 @@ class FlutterDevice { ...@@ -147,7 +142,6 @@ class FlutterDevice {
StreamSubscription<String> _loggingSubscription; StreamSubscription<String> _loggingSubscription;
bool _isListeningForObservatoryUri; bool _isListeningForObservatoryUri;
final String viewFilter; final String viewFilter;
final bool trackWidgetCreation;
/// Whether the stream [observatoryUris] is still open. /// Whether the stream [observatoryUris] is still open.
bool get isWaitingForObservatory => _isListeningForObservatoryUri ?? false; bool get isWaitingForObservatory => _isListeningForObservatoryUri ?? false;
...@@ -562,7 +556,7 @@ class FlutterDevice { ...@@ -562,7 +556,7 @@ class FlutterDevice {
generator: generator, generator: generator,
fullRestart: fullRestart, fullRestart: fullRestart,
dillOutputPath: dillOutputPath, dillOutputPath: dillOutputPath,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
projectRootPath: projectRootPath, projectRootPath: projectRootPath,
pathToReload: pathToReload, pathToReload: pathToReload,
invalidatedFiles: invalidatedFiles, invalidatedFiles: invalidatedFiles,
......
...@@ -342,7 +342,7 @@ class HotRunner extends ResidentRunner { ...@@ -342,7 +342,7 @@ class HotRunner extends ResidentRunner {
mainPath, mainPath,
<Uri>[], <Uri>[],
outputPath: dillOutputPath ?? outputPath: dillOutputPath ??
getDefaultApplicationKernelPath(trackWidgetCreation: device.trackWidgetCreation), getDefaultApplicationKernelPath(trackWidgetCreation: debuggingOptions.buildInfo.trackWidgetCreation),
packagesFilePath : packagesFilePath, packagesFilePath : packagesFilePath,
).then((CompilerOutput output) => output?.errorCount == 0) ).then((CompilerOutput output) => output?.errorCount == 0)
); );
......
...@@ -109,6 +109,7 @@ class FlutterOptions { ...@@ -109,6 +109,7 @@ class FlutterOptions {
static const String kFileSystemScheme = 'filesystem-scheme'; static const String kFileSystemScheme = 'filesystem-scheme';
static const String kSplitDebugInfoOption = 'split-debug-info'; static const String kSplitDebugInfoOption = 'split-debug-info';
static const String kDartObfuscationOption = 'obfuscate'; static const String kDartObfuscationOption = 'obfuscate';
static const String kDartDefinesOption = 'dart-define';
} }
abstract class FlutterCommand extends Command<void> { abstract class FlutterCommand extends Command<void> {
...@@ -336,20 +337,17 @@ abstract class FlutterCommand extends Command<void> { ...@@ -336,20 +337,17 @@ abstract class FlutterCommand extends Command<void> {
valueHelp: 'x.y.z'); valueHelp: 'x.y.z');
} }
void usesDartDefines() { void usesDartDefineOption() {
argParser.addMultiOption( argParser.addMultiOption(
'dart-define', FlutterOptions.kDartDefinesOption,
help: 'Passed to the Dart compiler building this application as a -D flag.\n' help: 'Additional key-value pairs that will be available as constants '
'Values supported by this option are compiler implementation specific.\n' 'from the String.fromEnvironment, bool.fromEnvironment, int.fromEnvironment, '
'and double.fromEnvironment constructors.\n'
'Multiple defines can be passed by repeating --dart-define multiple times.', 'Multiple defines can be passed by repeating --dart-define multiple times.',
valueHelp: 'FOO=bar', valueHelp: 'foo=bar',
hide: true,
); );
} }
/// The values passed via the `--dart-define` option.
List<String> get dartDefines => stringsArg('dart-define');
void usesIsolateFilterOption({ @required bool hide }) { void usesIsolateFilterOption({ @required bool hide }) {
argParser.addOption('isolate-filter', argParser.addOption('isolate-filter',
defaultsTo: null, defaultsTo: null,
...@@ -508,19 +506,15 @@ abstract class FlutterCommand extends Command<void> { ...@@ -508,19 +506,15 @@ abstract class FlutterCommand extends Command<void> {
? stringArg('build-number') ? stringArg('build-number')
: null; : null;
String extraFrontEndOptions = final List<String> extraFrontEndOptions =
argParser.options.containsKey(FlutterOptions.kExtraFrontEndOptions) argParser.options.containsKey(FlutterOptions.kExtraFrontEndOptions)
? stringArg(FlutterOptions.kExtraFrontEndOptions) ? stringsArg(FlutterOptions.kExtraFrontEndOptions)
: null; : <String>[];
if (argParser.options.containsKey(FlutterOptions.kEnableExperiment) && if (argParser.options.containsKey(FlutterOptions.kEnableExperiment) &&
argResults[FlutterOptions.kEnableExperiment] != null) { argResults[FlutterOptions.kEnableExperiment] != null) {
for (final String expFlag in stringsArg(FlutterOptions.kEnableExperiment)) { for (final String expFlag in stringsArg(FlutterOptions.kEnableExperiment)) {
final String flag = '--enable-experiment=' + expFlag; final String flag = '--enable-experiment=' + expFlag;
if (extraFrontEndOptions != null) { extraFrontEndOptions.add(flag);
extraFrontEndOptions += ',' + flag;
} else {
extraFrontEndOptions = flag;
}
} }
} }
...@@ -543,10 +537,12 @@ abstract class FlutterCommand extends Command<void> { ...@@ -543,10 +537,12 @@ abstract class FlutterCommand extends Command<void> {
? stringArg('flavor') ? stringArg('flavor')
: null, : null,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions?.isNotEmpty ?? false
? extraFrontEndOptions
: null,
extraGenSnapshotOptions: argParser.options.containsKey(FlutterOptions.kExtraGenSnapshotOptions) extraGenSnapshotOptions: argParser.options.containsKey(FlutterOptions.kExtraGenSnapshotOptions)
? stringArg(FlutterOptions.kExtraGenSnapshotOptions) ? stringsArg(FlutterOptions.kExtraGenSnapshotOptions)
: null, : null,
fileSystemRoots: argParser.options.containsKey(FlutterOptions.kFileSystemRoot) fileSystemRoots: argParser.options.containsKey(FlutterOptions.kFileSystemRoot)
? stringsArg(FlutterOptions.kFileSystemRoot) ? stringsArg(FlutterOptions.kFileSystemRoot)
: null, : null,
...@@ -562,6 +558,9 @@ abstract class FlutterCommand extends Command<void> { ...@@ -562,6 +558,9 @@ abstract class FlutterCommand extends Command<void> {
: kIconTreeShakerEnabledDefault, : kIconTreeShakerEnabledDefault,
splitDebugInfoPath: splitDebugInfoPath, splitDebugInfoPath: splitDebugInfoPath,
dartObfuscation: dartObfuscation, dartObfuscation: dartObfuscation,
dartDefines: argParser.options.containsKey(FlutterOptions.kDartDefinesOption)
? stringsArg(FlutterOptions.kDartDefinesOption)
: const <String>[],
); );
} }
......
...@@ -144,7 +144,7 @@ class FlutterTesterDevice extends Device { ...@@ -144,7 +144,7 @@ class FlutterTesterDevice extends Device {
trackWidgetCreation: buildInfo.trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
); );
await BundleBuilder().build( await BundleBuilder().build(
buildMode: buildInfo.mode, buildInfo: buildInfo,
mainPath: mainPath, mainPath: mainPath,
assetDirPath: assetDirPath, assetDirPath: assetDirPath,
applicationKernelFilePath: applicationKernelFilePath, applicationKernelFilePath: applicationKernelFilePath,
......
...@@ -28,7 +28,6 @@ Future<void> buildWeb( ...@@ -28,7 +28,6 @@ Future<void> buildWeb(
String target, String target,
BuildInfo buildInfo, BuildInfo buildInfo,
bool initializePlatform, bool initializePlatform,
List<String> dartDefines,
bool csp, bool csp,
) async { ) async {
if (!flutterProject.web.existsSync()) { if (!flutterProject.web.existsSync()) {
...@@ -51,7 +50,7 @@ Future<void> buildWeb( ...@@ -51,7 +50,7 @@ Future<void> buildWeb(
kTargetFile: target, kTargetFile: target,
kInitializePlatform: initializePlatform.toString(), kInitializePlatform: initializePlatform.toString(),
kHasWebPlugins: hasWebPlugins.toString(), kHasWebPlugins: hasWebPlugins.toString(),
kDartDefines: jsonEncode(dartDefines), kDartDefines: jsonEncode(buildInfo.dartDefines),
kCspMode: csp.toString(), kCspMode: csp.toString(),
kIconTreeShakerFlag: buildInfo.treeShakeIcons.toString(), kIconTreeShakerFlag: buildInfo.treeShakeIcons.toString(),
}, },
......
...@@ -24,7 +24,6 @@ abstract class WebRunnerFactory { ...@@ -24,7 +24,6 @@ abstract class WebRunnerFactory {
@required FlutterProject flutterProject, @required FlutterProject flutterProject,
@required bool ipv6, @required bool ipv6,
@required DebuggingOptions debuggingOptions, @required DebuggingOptions debuggingOptions,
@required List<String> dartDefines,
@required UrlTunneller urlTunneller, @required UrlTunneller urlTunneller,
}); });
} }
...@@ -57,7 +57,6 @@ void main() { ...@@ -57,7 +57,6 @@ void main() {
fileSystem.path.join('lib', 'main.dart'), fileSystem.path.join('lib', 'main.dart'),
BuildInfo.debug, BuildInfo.debug,
false, false,
const <String>[],
false, false,
), throwsToolExit()); ), throwsToolExit());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -77,7 +76,6 @@ void main() { ...@@ -77,7 +76,6 @@ void main() {
ipv6: false, ipv6: false,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
stayResident: true, stayResident: true,
dartDefines: const <String>[],
urlTunneller: null, urlTunneller: null,
) as ResidentWebRunner; ) as ResidentWebRunner;
expect(await runner.run(), 1); expect(await runner.run(), 1);
......
...@@ -41,7 +41,6 @@ void main() { ...@@ -41,7 +41,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.version'}); commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.version'});
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent); final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
...@@ -59,7 +58,6 @@ void main() { ...@@ -59,7 +58,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
globals.printError('daemon.logMessage test'); globals.printError('daemon.logMessage test');
final Map<String, dynamic> response = await responses.stream.firstWhere((Map<String, dynamic> map) { final Map<String, dynamic> response = await responses.stream.firstWhere((Map<String, dynamic> map) {
...@@ -87,7 +85,6 @@ void main() { ...@@ -87,7 +85,6 @@ void main() {
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
logToStdout: true, logToStdout: true,
dartDefines: const <String>[],
); );
globals.printStatus('daemon.logMessage test'); globals.printStatus('daemon.logMessage test');
// Service the event loop. // Service the event loop.
...@@ -108,7 +105,6 @@ void main() { ...@@ -108,7 +105,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.shutdown'}); commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.shutdown'});
return daemon.onExit.then<void>((int code) async { return daemon.onExit.then<void>((int code) async {
...@@ -124,7 +120,6 @@ void main() { ...@@ -124,7 +120,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'app.restart'}); commands.add(<String, dynamic>{'id': 0, 'method': 'app.restart'});
...@@ -142,7 +137,6 @@ void main() { ...@@ -142,7 +137,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
commands.add(<String, dynamic>{ commands.add(<String, dynamic>{
...@@ -166,7 +160,6 @@ void main() { ...@@ -166,7 +160,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'app.stop'}); commands.add(<String, dynamic>{'id': 0, 'method': 'app.stop'});
...@@ -184,7 +177,6 @@ void main() { ...@@ -184,7 +177,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'device.getDevices'}); commands.add(<String, dynamic>{'id': 0, 'method': 'device.getDevices'});
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent); final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
...@@ -201,7 +193,6 @@ void main() { ...@@ -201,7 +193,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
final MockPollingDeviceDiscovery discoverer = MockPollingDeviceDiscovery(); final MockPollingDeviceDiscovery discoverer = MockPollingDeviceDiscovery();
daemon.deviceDomain.addDeviceDiscoverer(discoverer); daemon.deviceDomain.addDeviceDiscoverer(discoverer);
...@@ -223,7 +214,6 @@ void main() { ...@@ -223,7 +214,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
final MockPollingDeviceDiscovery discoverer = MockPollingDeviceDiscovery(); final MockPollingDeviceDiscovery discoverer = MockPollingDeviceDiscovery();
...@@ -253,7 +243,6 @@ void main() { ...@@ -253,7 +243,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'emulator.launch'}); commands.add(<String, dynamic>{'id': 0, 'method': 'emulator.launch'});
...@@ -271,7 +260,6 @@ void main() { ...@@ -271,7 +260,6 @@ void main() {
commands.stream, commands.stream,
responses.add, responses.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
commands.add(<String, dynamic>{'id': 0, 'method': 'emulator.getEmulators'}); commands.add(<String, dynamic>{'id': 0, 'method': 'emulator.getEmulators'});
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent); final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
...@@ -291,7 +279,6 @@ void main() { ...@@ -291,7 +279,6 @@ void main() {
input.stream, input.stream,
output.add, output.add,
notifyingLogger: notifyingLogger, notifyingLogger: notifyingLogger,
dartDefines: const <String>[],
); );
// Respond to any requests from the daemon to expose a URL. // Respond to any requests from the daemon to expose a URL.
......
...@@ -654,10 +654,9 @@ class MockWebRunnerFactory extends Mock implements WebRunnerFactory { ...@@ -654,10 +654,9 @@ class MockWebRunnerFactory extends Mock implements WebRunnerFactory {
FlutterProject flutterProject, FlutterProject flutterProject,
bool ipv6, bool ipv6,
DebuggingOptions debuggingOptions, DebuggingOptions debuggingOptions,
List<String> dartDefines,
UrlTunneller urlTunneller, UrlTunneller urlTunneller,
}) { }) {
_dartDefines = dartDefines; _dartDefines = debuggingOptions.buildInfo.dartDefines;
return MockWebRunner(); return MockWebRunner();
} }
} }
......
...@@ -33,7 +33,7 @@ void main() { ...@@ -33,7 +33,7 @@ void main() {
when( when(
mockBundleBuilder.build( mockBundleBuilder.build(
platform: anyNamed('platform'), platform: anyNamed('platform'),
buildMode: anyNamed('buildMode'), buildInfo: anyNamed('buildInfo'),
mainPath: anyNamed('mainPath'), mainPath: anyNamed('mainPath'),
manifestPath: anyNamed('manifestPath'), manifestPath: anyNamed('manifestPath'),
applicationKernelFilePath: anyNamed('applicationKernelFilePath'), applicationKernelFilePath: anyNamed('applicationKernelFilePath'),
......
...@@ -173,7 +173,7 @@ class TestFlutterDevice extends FlutterDevice { ...@@ -173,7 +173,7 @@ class TestFlutterDevice extends FlutterDevice {
@required this.exception, @required this.exception,
@required ResidentCompiler generator, @required ResidentCompiler generator,
}) : assert(exception != null), }) : assert(exception != null),
super(device, buildMode: BuildMode.debug, generator: generator, trackWidgetCreation: false); super(device, buildInfo: BuildInfo.debug, generator: generator);
/// The exception to throw when the connect method is called. /// The exception to throw when the connect method is called.
final Exception exception; final Exception exception;
......
...@@ -135,7 +135,7 @@ void main() { ...@@ -135,7 +135,7 @@ void main() {
when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester); when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
// Trigger hot restart. // Trigger hot restart.
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs,
]; ];
final OperationResult result = await HotRunner(devices).restart(fullRestart: true); final OperationResult result = await HotRunner(devices).restart(fullRestart: true);
// Expect hot restart failed. // Expect hot restart failed.
...@@ -156,8 +156,8 @@ void main() { ...@@ -156,8 +156,8 @@ void main() {
when(mockHotDevice.supportsHotRestart).thenReturn(true); when(mockHotDevice.supportsHotRestart).thenReturn(true);
// Trigger hot restart. // Trigger hot restart.
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs,
FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, FlutterDevice(mockHotDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs,
]; ];
final OperationResult result = await HotRunner(devices).restart(fullRestart: true); final OperationResult result = await HotRunner(devices).restart(fullRestart: true);
// Expect hot restart failed. // Expect hot restart failed.
...@@ -178,8 +178,8 @@ void main() { ...@@ -178,8 +178,8 @@ void main() {
when(mockHotDevice.supportsHotRestart).thenReturn(true); when(mockHotDevice.supportsHotRestart).thenReturn(true);
// Trigger a restart. // Trigger a restart.
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs,
FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, FlutterDevice(mockHotDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs,
]; ];
final HotRunner hotRunner = HotRunner(devices); final HotRunner hotRunner = HotRunner(devices);
final OperationResult result = await hotRunner.restart(fullRestart: true); final OperationResult result = await hotRunner.restart(fullRestart: true);
...@@ -198,7 +198,7 @@ void main() { ...@@ -198,7 +198,7 @@ void main() {
when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(true);
when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester); when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug), FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug),
]; ];
final OperationResult result = await HotRunner(devices).restart(fullRestart: true); final OperationResult result = await HotRunner(devices).restart(fullRestart: true);
expect(result.isOk, false); expect(result.isOk, false);
...@@ -216,7 +216,7 @@ void main() { ...@@ -216,7 +216,7 @@ void main() {
when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester); when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
// Trigger hot restart. // Trigger hot restart.
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs,
]; ];
final HotRunner hotRunner = HotRunner(devices); final HotRunner hotRunner = HotRunner(devices);
final OperationResult result = await hotRunner.restart(fullRestart: true); final OperationResult result = await hotRunner.restart(fullRestart: true);
...@@ -244,7 +244,7 @@ void main() { ...@@ -244,7 +244,7 @@ void main() {
when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(true);
when(mockDevice.supportsFlutterExit).thenReturn(false); when(mockDevice.supportsFlutterExit).thenReturn(false);
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug), FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug),
]; ];
await HotRunner(devices).cleanupAfterSignal(); await HotRunner(devices).cleanupAfterSignal();
expect(shutdownTestingConfig.shutdownHookCalled, true); expect(shutdownTestingConfig.shutdownHookCalled, true);
...@@ -259,7 +259,7 @@ void main() { ...@@ -259,7 +259,7 @@ void main() {
when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(true);
when(mockDevice.supportsFlutterExit).thenReturn(false); when(mockDevice.supportsFlutterExit).thenReturn(false);
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug), FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug),
]; ];
await HotRunner(devices).preExit(); await HotRunner(devices).preExit();
expect(shutdownTestingConfig.shutdownHookCalled, true); expect(shutdownTestingConfig.shutdownHookCalled, true);
...@@ -386,7 +386,7 @@ class TestFlutterDevice extends FlutterDevice { ...@@ -386,7 +386,7 @@ class TestFlutterDevice extends FlutterDevice {
@required this.exception, @required this.exception,
@required ResidentCompiler generator, @required ResidentCompiler generator,
}) : assert(exception != null), }) : assert(exception != null),
super(device, buildMode: BuildMode.debug, generator: generator, trackWidgetCreation: false); super(device, buildInfo: BuildInfo.debug, generator: generator);
/// The exception to throw when the connect method is called. /// The exception to throw when the connect method is called.
final Exception exception; final Exception exception;
......
...@@ -9,8 +9,6 @@ import 'package:file/file.dart'; ...@@ -9,8 +9,6 @@ import 'package:file/file.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/dart.dart';
import 'package:flutter_tools/src/build_system/targets/icon_tree_shaker.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -206,26 +204,6 @@ void main() { ...@@ -206,26 +204,6 @@ void main() {
}); });
}); });
testUsingContext('builds with targetPlatform', () async {
final IOSSimulator simulator = IOSSimulator('x', name: 'iPhone X');
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
return BuildResult(success: true);
});
await simulator.sideloadUpdatedAssetsForInstalledApplicationBundle(BuildInfo.debug, 'lib/main.dart');
final VerificationResult result = verify(buildSystem.build(any, captureAny));
final Environment environment = result.captured.single as Environment;
expect(environment.defines, <String, String>{
kTargetFile: 'lib/main.dart',
kTargetPlatform: 'ios',
kBuildMode: 'debug',
kTrackWidgetCreation: 'false',
kIconTreeShakerFlag: null,
});
}, overrides: <Type, Generator>{
BuildSystem: () => MockBuildSystem(),
});
group('Simulator screenshot', () { group('Simulator screenshot', () {
MockXcode mockXcode; MockXcode mockXcode;
MockProcessManager mockProcessManager; MockProcessManager mockProcessManager;
......
...@@ -559,7 +559,7 @@ Information about project "Runner": ...@@ -559,7 +559,7 @@ Information about project "Runner":
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, treeShakeIcons: false); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, treeShakeIcons: false, trackWidgetCreation: false);
final FlutterProject project = FlutterProject.fromPath('path/to/project'); final FlutterProject project = FlutterProject.fromPath('path/to/project');
await updateGeneratedXcodeProperties( await updateGeneratedXcodeProperties(
project: project, project: project,
......
...@@ -682,10 +682,9 @@ void main() { ...@@ -682,10 +682,9 @@ void main() {
final DefaultResidentCompiler residentCompiler = (await FlutterDevice.create( final DefaultResidentCompiler residentCompiler = (await FlutterDevice.create(
mockDevice, mockDevice,
buildMode: BuildMode.debug, buildInfo: BuildInfo.debug,
flutterProject: FlutterProject.current(), flutterProject: FlutterProject.current(),
target: null, target: null,
trackWidgetCreation: true,
)).generator as DefaultResidentCompiler; )).generator as DefaultResidentCompiler;
expect(residentCompiler.librariesSpec, expect(residentCompiler.librariesSpec,
...@@ -747,7 +746,7 @@ class MockProcessManager extends Mock implements ProcessManager {} ...@@ -747,7 +746,7 @@ class MockProcessManager extends Mock implements ProcessManager {}
class MockServiceEvent extends Mock implements ServiceEvent {} class MockServiceEvent extends Mock implements ServiceEvent {}
class TestFlutterDevice extends FlutterDevice { class TestFlutterDevice extends FlutterDevice {
TestFlutterDevice(Device device, this.views, { Stream<Uri> observatoryUris }) TestFlutterDevice(Device device, this.views, { Stream<Uri> observatoryUris })
: super(device, buildMode: BuildMode.debug, trackWidgetCreation: false) { : super(device, buildInfo: BuildInfo.debug) {
_observatoryUris = observatoryUris; _observatoryUris = observatoryUris;
} }
......
...@@ -52,7 +52,6 @@ void main() { ...@@ -52,7 +52,6 @@ void main() {
debuggingOptions: DebuggingOptions.disabled(BuildInfo.release), debuggingOptions: DebuggingOptions.disabled(BuildInfo.release),
ipv6: true, ipv6: true,
stayResident: true, stayResident: true,
dartDefines: const <String>[],
urlTunneller: null, urlTunneller: null,
) as ResidentWebRunner; ) as ResidentWebRunner;
}, },
......
...@@ -77,7 +77,6 @@ void main() { ...@@ -77,7 +77,6 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true, ipv6: true,
stayResident: true, stayResident: true,
dartDefines: const <String>[],
urlTunneller: null, urlTunneller: null,
) as ResidentWebRunner; ) as ResidentWebRunner;
globals.fs.currentDirectory.childFile('.packages') globals.fs.currentDirectory.childFile('.packages')
...@@ -139,7 +138,6 @@ void main() { ...@@ -139,7 +138,6 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true, ipv6: true,
stayResident: true, stayResident: true,
dartDefines: const <String>[],
urlTunneller: null, urlTunneller: null,
) as ResidentWebRunner; ) as ResidentWebRunner;
...@@ -158,7 +156,6 @@ void main() { ...@@ -158,7 +156,6 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, startPaused: true), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, startPaused: true),
ipv6: true, ipv6: true,
stayResident: true, stayResident: true,
dartDefines: <String>[],
urlTunneller: null, urlTunneller: null,
); );
...@@ -174,7 +171,6 @@ void main() { ...@@ -174,7 +171,6 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.profile), debuggingOptions: DebuggingOptions.enabled(BuildInfo.profile),
ipv6: true, ipv6: true,
stayResident: true, stayResident: true,
dartDefines: const <String>[],
urlTunneller: null, urlTunneller: null,
); );
...@@ -234,7 +230,6 @@ void main() { ...@@ -234,7 +230,6 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true, ipv6: true,
stayResident: false, stayResident: false,
dartDefines: const <String>[],
urlTunneller: null, urlTunneller: null,
) as ResidentWebRunner; ) as ResidentWebRunner;
...@@ -271,7 +266,6 @@ void main() { ...@@ -271,7 +266,6 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, startPaused: true), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, startPaused: true),
ipv6: true, ipv6: true,
stayResident: true, stayResident: true,
dartDefines: const <String>[],
urlTunneller: null, urlTunneller: null,
) as ResidentWebRunner; ) as ResidentWebRunner;
_setupMocks(); _setupMocks();
...@@ -779,7 +773,6 @@ void main() { ...@@ -779,7 +773,6 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true, ipv6: true,
stayResident: true, stayResident: true,
dartDefines: const <String>[],
urlTunneller: null, urlTunneller: null,
) as ResidentWebRunner; ) as ResidentWebRunner;
...@@ -820,7 +813,6 @@ void main() { ...@@ -820,7 +813,6 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true, ipv6: true,
stayResident: true, stayResident: true,
dartDefines: const <String>[],
urlTunneller: null, urlTunneller: null,
) as ResidentWebRunner; ) as ResidentWebRunner;
......
...@@ -18,7 +18,17 @@ void main() { ...@@ -18,7 +18,17 @@ void main() {
// TODO(jacobr): make these tests run with `trackWidgetCreation: true` as // TODO(jacobr): make these tests run with `trackWidgetCreation: true` as
// well as the default flags. // well as the default flags.
return TestRunner( return TestRunner(
<FlutterDevice>[FlutterDevice(MockDevice(), trackWidgetCreation: false, buildMode: BuildMode.debug)], <FlutterDevice>[
FlutterDevice(
MockDevice(),
buildInfo: const BuildInfo(
BuildMode.debug,
null,
trackWidgetCreation: false,
treeShakeIcons: false,
),
),
],
); );
} }
......
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