Reland [flutter_tools] show only supported sub commands (#86153)
This commit is contained in:
@@ -24,25 +24,31 @@ import 'build_winuwp.dart';
|
||||
|
||||
class BuildCommand extends FlutterCommand {
|
||||
BuildCommand({ bool verboseHelp = false }) {
|
||||
addSubcommand(BuildAarCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildApkCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildAppBundleCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildIOSCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildIOSFrameworkCommand(
|
||||
_addSubcommand(BuildAarCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildApkCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildAppBundleCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildIOSCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildIOSFrameworkCommand(
|
||||
buildSystem: globals.buildSystem,
|
||||
verboseHelp: verboseHelp,
|
||||
));
|
||||
addSubcommand(BuildIOSArchiveCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildWebCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildMacosCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildLinuxCommand(
|
||||
_addSubcommand(BuildIOSArchiveCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildWebCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildMacosCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildLinuxCommand(
|
||||
operatingSystemUtils: globals.os,
|
||||
verboseHelp: verboseHelp
|
||||
));
|
||||
addSubcommand(BuildWindowsCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildWindowsUwpCommand(verboseHelp: verboseHelp));
|
||||
addSubcommand(BuildFuchsiaCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildWindowsCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildWindowsUwpCommand(verboseHelp: verboseHelp));
|
||||
_addSubcommand(BuildFuchsiaCommand(verboseHelp: verboseHelp));
|
||||
}
|
||||
|
||||
void _addSubcommand(BuildSubCommand command) {
|
||||
if (command.supported) {
|
||||
addSubcommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -63,6 +69,8 @@ abstract class BuildSubCommand extends FlutterCommand {
|
||||
@override
|
||||
bool get reportNullSafety => true;
|
||||
|
||||
bool get supported => true;
|
||||
|
||||
/// Display a message describing the current null safety runtime mode
|
||||
/// that was selected.
|
||||
///
|
||||
|
||||
@@ -58,6 +58,9 @@ class BuildFuchsiaCommand extends BuildSubCommand {
|
||||
@override
|
||||
String get description => 'Build the Fuchsia target (Experimental).';
|
||||
|
||||
@override
|
||||
bool get supported => globals.platform.isLinux || globals.platform.isMacOS;
|
||||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
if (!featureFlags.isFuchsiaEnabled) {
|
||||
@@ -68,7 +71,7 @@ class BuildFuchsiaCommand extends BuildSubCommand {
|
||||
}
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
if (!globals.platform.isLinux && !globals.platform.isMacOS) {
|
||||
if (!supported) {
|
||||
throwToolExit('"build fuchsia" is only supported on Linux and MacOS hosts.');
|
||||
}
|
||||
if (!flutterProject.fuchsia.existsSync()) {
|
||||
|
||||
@@ -224,12 +224,15 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
|
||||
|
||||
Directory _outputAppDirectory(String xcodeResultOutput);
|
||||
|
||||
@override
|
||||
bool get supported => globals.platform.isMacOS;
|
||||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
defaultBuildMode = forSimulator ? BuildMode.debug : BuildMode.release;
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
|
||||
if (!globals.platform.isMacOS) {
|
||||
if (!supported) {
|
||||
throwToolExit('Building for iOS is only supported on macOS.');
|
||||
}
|
||||
if (forSimulator && !buildInfo.supportsSimulator) {
|
||||
|
||||
@@ -141,11 +141,14 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
|
||||
return buildInfos;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get supported => _platform.isMacOS;
|
||||
|
||||
@override
|
||||
Future<void> validateCommand() async {
|
||||
await super.validateCommand();
|
||||
_project = FlutterProject.current();
|
||||
if (!_platform.isMacOS) {
|
||||
if (!supported) {
|
||||
throwToolExit('Building frameworks for iOS is only supported on the Mac.');
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,9 @@ class BuildMacosCommand extends BuildSubCommand {
|
||||
@override
|
||||
String get description => 'Build a macOS desktop application.';
|
||||
|
||||
@override
|
||||
bool get supported => globals.platform.isMacOS;
|
||||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
@@ -46,7 +49,7 @@ class BuildMacosCommand extends BuildSubCommand {
|
||||
if (!featureFlags.isMacOSEnabled) {
|
||||
throwToolExit('"build macos" is not currently supported. To enable, run "flutter config --enable-macos-desktop".');
|
||||
}
|
||||
if (!globals.platform.isMacOS) {
|
||||
if (!supported) {
|
||||
throwToolExit('"build macos" only supported on macOS hosts.');
|
||||
}
|
||||
displayNullSafetyMode(buildInfo);
|
||||
|
||||
Reference in New Issue
Block a user