Share build command flag configuration on desktop (#64983)

Almost all of the flag setup on Linux, macOS, and Windows should be
identical; this pulls that common setup to a shared method.

This adds support for several flags on macOS that have all the necessary
plumbing already in place due to shared backend code, but were never
enabled.

Fixes https://github.com/flutter/flutter/issues/64944
This commit is contained in:
stuartmorgan
2020-09-01 13:21:51 -04:00
committed by GitHub
parent e82571a98c
commit 6eef5f2c5f
5 changed files with 77 additions and 48 deletions

View File

@@ -18,20 +18,7 @@ import 'build.dart';
/// A command to build a linux desktop target through a build shell script.
class BuildLinuxCommand extends BuildSubCommand {
BuildLinuxCommand({ bool verboseHelp = false }) {
addTreeShakeIconsFlag();
usesTargetOption();
addBuildModeFlags(verboseHelp: verboseHelp);
usesPubOption();
addSplitDebugInfoOption();
addDartObfuscationOption();
usesDartDefineOption();
usesExtraFrontendOptions();
addEnableExperimentation(hide: !verboseHelp);
usesTrackWidgetCreation(verboseHelp: verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addBundleSkSLPathOption(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesAnalyzeSizeFlag();
addCommonDesktopBuildOptions(verboseHelp: verboseHelp);
}
@override

View File

@@ -20,19 +20,9 @@ import 'build.dart';
/// A command to build a macOS desktop target through a build shell script.
class BuildMacosCommand extends BuildSubCommand {
BuildMacosCommand({ @required bool verboseHelp }) {
addTreeShakeIconsFlag();
addSplitDebugInfoOption();
usesTargetOption();
addBuildModeFlags();
addDartObfuscationOption();
usesExtraFrontendOptions();
addCommonDesktopBuildOptions(verboseHelp: verboseHelp);
usesBuildNumberOption();
usesBuildNameOption();
addEnableExperimentation(hide: !verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addBundleSkSLPathOption(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesAnalyzeSizeFlag();
}
@override

View File

@@ -21,20 +21,7 @@ import 'build.dart';
/// A command to build a windows desktop target through a build shell script.
class BuildWindowsCommand extends BuildSubCommand {
BuildWindowsCommand({ bool verboseHelp = false }) {
addTreeShakeIconsFlag();
usesTargetOption();
addBuildModeFlags(verboseHelp: verboseHelp);
usesPubOption();
addSplitDebugInfoOption();
addDartObfuscationOption();
usesDartDefineOption();
usesExtraFrontendOptions();
addEnableExperimentation(hide: !verboseHelp);
usesTrackWidgetCreation(verboseHelp: verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addBundleSkSLPathOption(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
usesAnalyzeSizeFlag();
addCommonDesktopBuildOptions(verboseHelp: verboseHelp);
}
@override

View File

@@ -554,6 +554,24 @@ abstract class FlutterCommand extends Command<void> {
);
}
/// Adds build options common to all of the desktop build commands.
void addCommonDesktopBuildOptions({ bool verboseHelp = false }) {
addBuildModeFlags(verboseHelp: verboseHelp);
addBuildPerformanceFile(hide: !verboseHelp);
addBundleSkSLPathOption(hide: !verboseHelp);
addDartObfuscationOption();
addEnableExperimentation(hide: !verboseHelp);
addNullSafetyModeOptions(hide: !verboseHelp);
addSplitDebugInfoOption();
addTreeShakeIconsFlag();
usesAnalyzeSizeFlag();
usesDartDefineOption();
usesExtraFrontendOptions();
usesPubOption();
usesTargetOption();
usesTrackWidgetCreation(verboseHelp: verboseHelp);
}
set defaultBuildMode(BuildMode value) {
_defaultBuildMode = value;
}