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