[flutter_tool] Adds --enable-impeller flag to the run command (#100835)

This commit is contained in:
Zachary Anderson
2022-03-26 20:07:24 -07:00
committed by GitHub
parent 689672ff9d
commit 47f08a3fd6
9 changed files with 70 additions and 1 deletions

View File

@@ -140,7 +140,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
'startup. By default this is main(List<String> args). Specify '
'this option multiple times each with one argument to pass '
'multiple arguments to the Dart entrypoint. Currently this is '
'only supported on desktop platforms.'
'only supported on desktop platforms.',
);
usesWebOptions(verboseHelp: verboseHelp);
usesTargetOption();
@@ -155,6 +155,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
addDevToolsOptions(verboseHelp: verboseHelp);
addAndroidSpecificBuildOptions(hide: !verboseHelp);
usesFatalWarningsOption(verboseHelp: verboseHelp);
addEnableImpellerFlag(verboseHelp: verboseHelp);
}
bool get traceStartup => boolArg('trace-startup');
@@ -164,6 +165,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
bool get disableServiceAuthCodes => boolArg('disable-service-auth-codes');
bool get runningWithPrebuiltApplication => argResults['use-application-binary'] != null;
bool get trackWidgetCreation => boolArg('track-widget-creation');
bool get enableImpeller => boolArg('enable-impeller');
@override
bool get reportNullSafety => true;
@@ -193,6 +195,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'),
webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'),
webBrowserDebugPort: browserDebugPort,
enableImpeller: enableImpeller,
);
} else {
return DebuggingOptions.enabled(
@@ -235,6 +238,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
&& !runningWithPrebuiltApplication,
nullAssertions: boolArg('null-assertions'),
nativeNullAssertions: boolArg('native-null-assertions'),
enableImpeller: enableImpeller,
);
}
}
@@ -438,6 +442,7 @@ class RunCommand extends RunCommandBase {
commandRunProjectModule: FlutterProject.current().isModule,
commandRunProjectHostLanguage: hostLanguage.join(','),
commandRunAndroidEmbeddingVersion: androidEmbeddingVersion,
commandRunEnableImpeller: enableImpeller,
);
}

View File

@@ -790,6 +790,7 @@ class DebuggingOptions {
this.fastStart = false,
this.nullAssertions = false,
this.nativeNullAssertions = false,
this.enableImpeller = false,
}) : debuggingEnabled = true;
DebuggingOptions.disabled(this.buildInfo, {
@@ -805,6 +806,7 @@ class DebuggingOptions {
this.webLaunchUrl,
this.cacheSkSL = false,
this.traceAllowlist,
this.enableImpeller = false,
}) : debuggingEnabled = false,
useTestFonts = false,
startPaused = false,
@@ -870,6 +872,7 @@ class DebuggingOptions {
required this.fastStart,
required this.nullAssertions,
required this.nativeNullAssertions,
required this.enableImpeller,
});
final bool debuggingEnabled;
@@ -903,6 +906,7 @@ class DebuggingOptions {
final bool webUseSseForDebugProxy;
final bool webUseSseForDebugBackend;
final bool webUseSseForInjectedClient;
final bool enableImpeller;
/// Whether to run the browser in headless mode.
///
@@ -972,6 +976,7 @@ class DebuggingOptions {
'fastStart': fastStart,
'nullAssertions': nullAssertions,
'nativeNullAssertions': nativeNullAssertions,
'enableImpeller': enableImpeller,
};
static DebuggingOptions fromJson(Map<String, Object?> json, BuildInfo buildInfo) =>
@@ -1014,6 +1019,7 @@ class DebuggingOptions {
fastStart: (json['fastStart'] as bool?)!,
nullAssertions: (json['nullAssertions'] as bool?)!,
nativeNullAssertions: (json['nativeNullAssertions'] as bool?)!,
enableImpeller: (json['enableImpeller'] as bool?) ?? false,
);
}

View File

@@ -373,6 +373,7 @@ class IOSDevice extends Device {
if (debuggingOptions.purgePersistentCache) '--purge-persistent-cache',
if (route != null) '--route=$route',
if (platformArgs['trace-startup'] as bool? ?? false) '--trace-startup',
if (debuggingOptions.enableImpeller) '--enable-impeller',
];
final Status installStatus = _logger.startProgress(

View File

@@ -66,6 +66,7 @@ class CustomDimensions {
this.hotEventScannedSourcesCount,
this.hotEventReassembleTimeInMs,
this.hotEventReloadVMTimeInMs,
this.commandRunEnableImpeller,
});
final String? sessionHostOsDetails; // cd1
@@ -123,6 +124,7 @@ class CustomDimensions {
final int? hotEventScannedSourcesCount; // cd 53
final int? hotEventReassembleTimeInMs; // cd 54
final int? hotEventReloadVMTimeInMs; // cd 55
final bool? commandRunEnableImpeller; // cd 56
/// Convert to a map that will be used to upload to the analytics backend.
Map<String, String> toMap() => <String, String>{
@@ -181,6 +183,7 @@ class CustomDimensions {
if (hotEventScannedSourcesCount != null) cdKey(CustomDimensionsEnum.hotEventScannedSourcesCount): hotEventScannedSourcesCount.toString(),
if (hotEventReassembleTimeInMs != null) cdKey(CustomDimensionsEnum.hotEventReassembleTimeInMs): hotEventReassembleTimeInMs.toString(),
if (hotEventReloadVMTimeInMs != null) cdKey(CustomDimensionsEnum.hotEventReloadVMTimeInMs): hotEventReloadVMTimeInMs.toString(),
if (commandRunEnableImpeller != null) cdKey(CustomDimensionsEnum.commandRunEnableImpeller): commandRunEnableImpeller.toString(),
};
/// Merge the values of two [CustomDimensions] into one. If a value is defined
@@ -246,6 +249,7 @@ class CustomDimensions {
hotEventScannedSourcesCount: other.hotEventScannedSourcesCount ?? hotEventScannedSourcesCount,
hotEventReassembleTimeInMs: other.hotEventReassembleTimeInMs ?? hotEventReassembleTimeInMs,
hotEventReloadVMTimeInMs: other.hotEventReloadVMTimeInMs ?? hotEventReloadVMTimeInMs,
commandRunEnableImpeller: other.commandRunEnableImpeller ?? commandRunEnableImpeller,
);
}
@@ -305,6 +309,7 @@ class CustomDimensions {
hotEventScannedSourcesCount: _extractInt(map, CustomDimensionsEnum.hotEventScannedSourcesCount),
hotEventReassembleTimeInMs: _extractInt(map, CustomDimensionsEnum.hotEventReassembleTimeInMs),
hotEventReloadVMTimeInMs: _extractInt(map, CustomDimensionsEnum.hotEventReloadVMTimeInMs),
commandRunEnableImpeller: _extractBool(map, CustomDimensionsEnum.commandRunEnableImpeller),
);
static bool? _extractBool(Map<String, String> map, CustomDimensionsEnum field) =>
@@ -390,6 +395,7 @@ enum CustomDimensionsEnum {
hotEventScannedSourcesCount, // cd53
hotEventReassembleTimeInMs, // cd54
hotEventReloadVMTimeInMs, // cd55
commandRunEnableImpeller, // cd56
}
String cdKey(CustomDimensionsEnum cd) => 'cd${cd.index + 1}';

View File

@@ -948,6 +948,16 @@ abstract class FlutterCommand extends Command<void> {
);
}
void addEnableImpellerFlag({required bool verboseHelp}) {
argParser.addFlag('enable-impeller',
negatable: false,
hide: !verboseHelp,
help: 'Whether to enable the experimental Impeller rendering engine. '
'Impeller is currently only supported on iOS. This flag will '
'be ignored when targeting other platforms.',
);
}
/// Compute the [BuildInfo] for the current flutter command.
/// Commands that build multiple build modes can pass in a [forcedBuildMode]
/// to be used instead of parsing flags.