Friendlier flutter tool messages for dynamic mode (#26378)
This commit is contained in:
committed by
GitHub
parent
17d741ea4e
commit
585e23173a
@@ -119,6 +119,7 @@ class BuildInfo {
|
||||
bool get supportsEmulator => isEmulatorBuildMode(mode);
|
||||
bool get supportsSimulator => isEmulatorBuildMode(mode);
|
||||
String get modeName => getModeName(mode);
|
||||
String get friendlyModeName => getFriendlyModeName(mode);
|
||||
|
||||
BuildInfo withTargetPlatform(TargetPlatform targetPlatform) =>
|
||||
BuildInfo(mode, flavor,
|
||||
@@ -142,6 +143,10 @@ enum BuildMode {
|
||||
|
||||
String getModeName(BuildMode mode) => getEnumName(mode);
|
||||
|
||||
String getFriendlyModeName(BuildMode mode) {
|
||||
return snakeCase(getModeName(mode)).replaceAll('_', ' ');
|
||||
}
|
||||
|
||||
// Returns true if the selected build mode uses ahead-of-time compilation.
|
||||
bool isAotBuildMode(BuildMode mode) {
|
||||
return mode == BuildMode.profile || mode == BuildMode.release;
|
||||
|
||||
@@ -85,7 +85,7 @@ Future<void> build({
|
||||
|
||||
} else if (!fs.file(compilationTraceFilePath).existsSync()) {
|
||||
// Be forgiving if compilation trace file is missing.
|
||||
printError('Warning: Ignoring missing compilation training file $compilationTraceFilePath.');
|
||||
printStatus('No compilation trace available. To optimize performance, consider using --train.');
|
||||
final File tmp = fs.systemTempDirectory.childFile('flutterEmptyCompilationTrace.txt');
|
||||
compilationTraceFilePath = (tmp..createSync(recursive: true)).path;
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class BuildAotCommand extends BuildSubCommand {
|
||||
if (!argResults['quiet']) {
|
||||
final String typeName = artifacts.getEngineType(platform, buildMode);
|
||||
status = logger.startProgress(
|
||||
'Building AOT snapshot in ${getModeName(getBuildMode())} mode ($typeName)...',
|
||||
'Building AOT snapshot in ${getFriendlyModeName(getBuildMode())} mode ($typeName)...',
|
||||
expectSlowOperation: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class BuildIOSCommand extends BuildSubCommand {
|
||||
}
|
||||
final BuildInfo buildInfo = getBuildInfo();
|
||||
if (forSimulator && !buildInfo.supportsSimulator)
|
||||
throwToolExit('${toTitleCase(buildInfo.modeName)} mode is not supported for simulators.');
|
||||
throwToolExit('${toTitleCase(buildInfo.friendlyModeName)} mode is not supported for simulators.');
|
||||
|
||||
final String logTarget = forSimulator ? 'simulator' : 'device';
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ class AppDomain extends Domain {
|
||||
String isolateFilter,
|
||||
}) async {
|
||||
if (await device.isLocalEmulator && !options.buildInfo.supportsEmulator) {
|
||||
throw '${toTitleCase(options.buildInfo.modeName)} mode is not supported for emulators.';
|
||||
throw '${toTitleCase(options.buildInfo.friendlyModeName)} mode is not supported for emulators.';
|
||||
}
|
||||
|
||||
// We change the current working directory for the duration of the `start` command.
|
||||
|
||||
@@ -303,7 +303,7 @@ class RunCommand extends RunCommandBase {
|
||||
}
|
||||
|
||||
if (!isEmulatorBuildMode(getBuildMode())) {
|
||||
throwToolExit('${toTitleCase(getModeName(getBuildMode()))} mode is not supported for emulators.');
|
||||
throwToolExit('${toTitleCase(getFriendlyModeName(getBuildMode()))} mode is not supported for emulators.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ class FlutterDevice {
|
||||
bool shouldBuild,
|
||||
}) async {
|
||||
final bool prebuiltMode = hotRunner.applicationBinary != null;
|
||||
final String modeName = hotRunner.debuggingOptions.buildInfo.modeName;
|
||||
final String modeName = hotRunner.debuggingOptions.buildInfo.friendlyModeName;
|
||||
printStatus('Launching ${getDisplayPath(hotRunner.mainPath)} on ${device.name} in $modeName mode...');
|
||||
|
||||
final TargetPlatform targetPlatform = await device.targetPlatform;
|
||||
@@ -324,7 +324,7 @@ class FlutterDevice {
|
||||
applicationBinary: coldRunner.applicationBinary
|
||||
);
|
||||
|
||||
final String modeName = coldRunner.debuggingOptions.buildInfo.modeName;
|
||||
final String modeName = coldRunner.debuggingOptions.buildInfo.friendlyModeName;
|
||||
final bool prebuiltMode = coldRunner.applicationBinary != null;
|
||||
if (coldRunner.mainPath == null) {
|
||||
assert(prebuiltMode);
|
||||
|
||||
Reference in New Issue
Block a user