Fix mach run bustage (#33563)

Move `--flavor` to a new "Packaging options" group, so that
we can only apply the flavor option to the commands that support it.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender 2024-09-27 08:11:57 +02:00 committed by GitHub
parent 02953d2fb6
commit 78370fa6d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 9 deletions

View file

@ -57,7 +57,7 @@ class MachCommands(CommandBase):
help='Print very verbose output') help='Print very verbose output')
@CommandArgument('params', nargs='...', @CommandArgument('params', nargs='...',
help="Command-line arguments to be passed through to Cargo") help="Command-line arguments to be passed through to Cargo")
@CommandBase.common_command_arguments(build_configuration=True, build_type=True) @CommandBase.common_command_arguments(build_configuration=True, build_type=True, package_configuration=True)
def build(self, build_type: BuildType, jobs=None, params=None, no_package=False, def build(self, build_type: BuildType, jobs=None, params=None, no_package=False,
verbose=False, very_verbose=False, with_asan=False, flavor=None, **kwargs): verbose=False, very_verbose=False, with_asan=False, flavor=None, **kwargs):
opts = params or [] opts = params or []

View file

@ -515,7 +515,11 @@ class CommandBase(object):
return env return env
@staticmethod @staticmethod
def common_command_arguments(build_configuration=False, build_type=False, binary_selection=False): def common_command_arguments(build_configuration=False,
build_type=False,
binary_selection=False,
package_configuration=False
):
decorators = [] decorators = []
if build_type or binary_selection: if build_type or binary_selection:
decorators += [ decorators += [
@ -532,10 +536,6 @@ class CommandBase(object):
CommandArgument('--profile', group="Build Type", CommandArgument('--profile', group="Build Type",
help='Build with custom Cargo profile'), help='Build with custom Cargo profile'),
CommandArgument('--with-asan', action='store_true', help="Build with AddressSanitizer"), CommandArgument('--with-asan', action='store_true', help="Build with AddressSanitizer"),
CommandArgument(
'--flavor', default=None, group="Build Type",
help='Product flavor to be used when packaging with Gradle/Hvigor (android/ohos).'
),
] ]
if build_configuration: if build_configuration:
@ -594,6 +594,14 @@ class CommandBase(object):
help="Enable Servo's `crown` linter tool" help="Enable Servo's `crown` linter tool"
) )
] ]
if package_configuration:
decorators += [
CommandArgumentGroup('Packaging options'),
CommandArgument(
'--flavor', default=None, group="Packaging options",
help='Product flavor to be used when packaging with Gradle/Hvigor (android/ohos).'
),
]
if binary_selection: if binary_selection:
decorators += [ decorators += [

View file

@ -132,7 +132,7 @@ class PackageCommands(CommandBase):
@CommandArgument('--target', '-t', @CommandArgument('--target', '-t',
default=None, default=None,
help='Package for given target platform') help='Package for given target platform')
@CommandBase.common_command_arguments(build_configuration=False, build_type=True) @CommandBase.common_command_arguments(build_configuration=False, build_type=True, package_configuration=True)
@CommandBase.allow_target_configuration @CommandBase.allow_target_configuration
def package(self, build_type: BuildType, flavor=None, with_asan=False): def package(self, build_type: BuildType, flavor=None, with_asan=False):
env = self.build_env() env = self.build_env()
@ -420,7 +420,7 @@ class PackageCommands(CommandBase):
@CommandArgument('--target', '-t', @CommandArgument('--target', '-t',
default=None, default=None,
help='Install the given target platform') help='Install the given target platform')
@CommandBase.common_command_arguments(build_configuration=False, build_type=True) @CommandBase.common_command_arguments(build_configuration=False, build_type=True, package_configuration=True)
@CommandBase.allow_target_configuration @CommandBase.allow_target_configuration
def install(self, build_type: BuildType, emulator=False, usb=False, with_asan=False, flavor=None): def install(self, build_type: BuildType, emulator=False, usb=False, with_asan=False, flavor=None):
env = self.build_env() env = self.build_env()
@ -429,7 +429,7 @@ class PackageCommands(CommandBase):
except BuildNotFound: except BuildNotFound:
print("Servo build not found. Building servo...") print("Servo build not found. Building servo...")
result = Registrar.dispatch( result = Registrar.dispatch(
"build", context=self.context, build_type=build_type "build", context=self.context, build_type=build_type, flavor=flavor
) )
if result: if result:
return result return result