[flutter_tools] skip web renderer defines unless web target is picked (#75160)
This commit is contained in:
@@ -198,7 +198,7 @@ class DriveCommand extends RunCommandBase {
|
||||
) ?? PackageConfig.empty;
|
||||
final DriverService driverService = _flutterDriverFactory.createDriverService(web);
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
final DebuggingOptions debuggingOptions = await createDebuggingOptions();
|
||||
final DebuggingOptions debuggingOptions = await createDebuggingOptions(web);
|
||||
final File applicationBinary = stringArg('use-application-binary') == null
|
||||
? null
|
||||
: _fileSystem.file(stringArg('use-application-binary'));
|
||||
|
||||
@@ -159,8 +159,8 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
|
||||
String get traceAllowlist => stringArg('trace-allowlist');
|
||||
|
||||
/// Create a debugging options instance for the current `run` or `drive` invocation.
|
||||
Future<DebuggingOptions> createDebuggingOptions() async {
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
Future<DebuggingOptions> createDebuggingOptions(bool webMode) async {
|
||||
final BuildInfo buildInfo = await getBuildInfo(updateWebDefines: webMode);
|
||||
final int browserDebugPort = featureFlags.isWebEnabled && argResults.wasParsed('web-browser-debug-port')
|
||||
? int.parse(stringArg('web-browser-debug-port'))
|
||||
: null;
|
||||
@@ -322,6 +322,7 @@ class RunCommand extends RunCommandBase {
|
||||
final String description = 'Run your Flutter app on an attached device.';
|
||||
|
||||
List<Device> devices;
|
||||
bool webMode = false;
|
||||
|
||||
String get userIdentifier => stringArg(FlutterOptions.kDeviceUser);
|
||||
|
||||
@@ -393,7 +394,7 @@ class RunCommand extends RunCommandBase {
|
||||
}
|
||||
}
|
||||
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
final BuildInfo buildInfo = await getBuildInfo(updateWebDefines: webMode);
|
||||
final String modeName = buildInfo.modeName;
|
||||
return <CustomDimensions, String>{
|
||||
CustomDimensions.commandRunIsEmulator: '$isEmulator',
|
||||
@@ -448,13 +449,18 @@ class RunCommand extends RunCommandBase {
|
||||
'--${FlutterOptions.kDeviceUser} is only supported for Android. At least one Android device is required.'
|
||||
);
|
||||
}
|
||||
// Only support "web mode" with a single web device due to resident runner
|
||||
// refactoring required otherwise.
|
||||
webMode = featureFlags.isWebEnabled &&
|
||||
devices.length == 1 &&
|
||||
await devices.single.targetPlatform == TargetPlatform.web_javascript;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
// Enable hot mode by default if `--no-hot` was not passed and we are in
|
||||
// debug mode.
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
final BuildInfo buildInfo = await getBuildInfo(updateWebDefines: webMode);
|
||||
final bool hotMode = shouldUseHotMode(buildInfo);
|
||||
final String applicationBinaryPath = stringArg('use-application-binary');
|
||||
|
||||
@@ -476,7 +482,7 @@ class RunCommand extends RunCommandBase {
|
||||
try {
|
||||
app = await daemon.appDomain.startApp(
|
||||
devices.first, globals.fs.currentDirectory.path, targetFile, route,
|
||||
await createDebuggingOptions(), hotMode,
|
||||
await createDebuggingOptions(webMode), hotMode,
|
||||
applicationBinary: applicationBinaryPath == null
|
||||
? null
|
||||
: globals.fs.file(applicationBinaryPath),
|
||||
@@ -550,18 +556,13 @@ class RunCommand extends RunCommandBase {
|
||||
platform: globals.platform,
|
||||
),
|
||||
];
|
||||
// Only support "web mode" with a single web device due to resident runner
|
||||
// refactoring required otherwise.
|
||||
final bool webMode = featureFlags.isWebEnabled &&
|
||||
devices.length == 1 &&
|
||||
await devices.single.targetPlatform == TargetPlatform.web_javascript;
|
||||
|
||||
ResidentRunner runner;
|
||||
if (hotMode && !webMode) {
|
||||
runner = HotRunner(
|
||||
flutterDevices,
|
||||
target: targetFile,
|
||||
debuggingOptions: await createDebuggingOptions(),
|
||||
debuggingOptions: await createDebuggingOptions(webMode),
|
||||
benchmarkMode: boolArg('benchmark'),
|
||||
applicationBinary: applicationBinaryPath == null
|
||||
? null
|
||||
@@ -577,7 +578,7 @@ class RunCommand extends RunCommandBase {
|
||||
target: targetFile,
|
||||
flutterProject: flutterProject,
|
||||
ipv6: ipv6,
|
||||
debuggingOptions: await createDebuggingOptions(),
|
||||
debuggingOptions: await createDebuggingOptions(webMode),
|
||||
stayResident: stayResident,
|
||||
urlTunneller: null,
|
||||
);
|
||||
@@ -585,7 +586,7 @@ class RunCommand extends RunCommandBase {
|
||||
runner = ColdRunner(
|
||||
flutterDevices,
|
||||
target: targetFile,
|
||||
debuggingOptions: await createDebuggingOptions(),
|
||||
debuggingOptions: await createDebuggingOptions(webMode),
|
||||
traceStartup: traceStartup,
|
||||
awaitFirstFrameWhenTracing: awaitFirstFrameWhenTracing,
|
||||
applicationBinary: applicationBinaryPath == null
|
||||
|
||||
@@ -820,7 +820,7 @@ abstract class FlutterCommand extends Command<void> {
|
||||
///
|
||||
/// Throws a [ToolExit] if the current set of options is not compatible with
|
||||
/// each other.
|
||||
Future<BuildInfo> getBuildInfo({ BuildMode forcedBuildMode }) async {
|
||||
Future<BuildInfo> getBuildInfo({ BuildMode forcedBuildMode, bool updateWebDefines = true }) async {
|
||||
final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation') &&
|
||||
boolArg('track-widget-creation');
|
||||
|
||||
@@ -940,7 +940,7 @@ abstract class FlutterCommand extends Command<void> {
|
||||
? stringsArg(FlutterOptions.kDartDefinesOption)
|
||||
: <String>[];
|
||||
|
||||
if (argParser.options.containsKey('web-renderer')) {
|
||||
if (argParser.options.containsKey('web-renderer') && updateWebDefines) {
|
||||
dartDefines = updateDartDefines(dartDefines, stringArg('web-renderer'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user