aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/package_commands.py
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-08-14 12:21:29 +0200
committerGitHub <noreply@github.com>2023-08-14 10:21:29 +0000
commit1d79f5dad2a8b006bddf1cabec519f21a1fe6d31 (patch)
tree819a12982b155029db401716d7e37ee2ac5db0dd /python/servo/package_commands.py
parentcc86854c4efefe21dbcd2746a05c379b8f1fb479 (diff)
downloadservo-1d79f5dad2a8b006bddf1cabec519f21a1fe6d31.tar.gz
servo-1d79f5dad2a8b006bddf1cabec519f21a1fe6d31.zip
Make the `--release`/`--dev` more consistent and less surprising (#30091)
There were some issues with the way that the `--release` and `--dev` arguments were handled in mach commands. - Not all commands accepted them in the same way. For instance `./mach test-wpt` didn't really accept them at all. - If you did not pass either of them, mach would try to guess which build you meant. This guess was often quite surprising as it wasn't printed and it depended on the state of the your target directory, which is difficult to remember. - The `dev` profile is colloquially called a "debug" profile and some commands accepted `-d` or `--debug...` like arguments, but `--debug` with `./mach run` meant run in a debugger. It was easy to mix this up. This change: - Centralizes where build type argument processing happens. Now it the same shared decorator in CommandBase. - Uses a `BuildType` enum instead of passing around two different booleans. This reduces the error checking for situations where both are true. - Be much less clever about guessing what build to use. Now if you don't specify a build type, `--dev` is chosen. I think this behavior matches cargo. - Makes it so that `./mach test-wpt` accepts the exact same arguments and has the same behavior as other commands. In addition, the suite correct for `test-wpt` is removed. There are only two suites now and it's quite unlikely that people will confuse WPT tests for rust unit tests.
Diffstat (limited to 'python/servo/package_commands.py')
-rw-r--r--python/servo/package_commands.py45
1 files changed, 17 insertions, 28 deletions
diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py
index 1ac0357b2f6..8dff69b29c2 100644
--- a/python/servo/package_commands.py
+++ b/python/servo/package_commands.py
@@ -29,6 +29,7 @@ from mach.decorators import (
from mach.registrar import Registrar
from servo.command_base import (
+ BuildType,
archive_deterministically,
BuildNotFound,
cd,
@@ -112,10 +113,6 @@ class PackageCommands(CommandBase):
@Command('package',
description='Package Servo',
category='package')
- @CommandArgument('--release', '-r', action='store_true',
- help='Package the release build')
- @CommandArgument('--dev', '-d', action='store_true',
- help='Package the dev build')
@CommandArgument('--android',
default=None,
action='store_true',
@@ -130,8 +127,8 @@ class PackageCommands(CommandBase):
default=None,
action='store_true',
help='Create a local Maven repository')
- def package(self, release=False, dev=False, android=None, target=None,
- flavor=None, maven=False):
+ @CommandBase.common_command_arguments(build_configuration=False, build_type=True)
+ def package(self, build_type: BuildType, android=None, target=None, flavor=None, maven=False):
if android is None:
android = self.config["build"]["android"]
if target and android:
@@ -144,26 +141,21 @@ class PackageCommands(CommandBase):
self.cross_compile_target = target
env = self.build_env()
- binary_path = self.get_binary_path(
- release, dev, target=target, android=android,
- )
+ binary_path = self.get_binary_path(build_type, target=target, android=android)
dir_to_root = self.get_top_dir()
target_dir = path.dirname(binary_path)
if android:
android_target = self.config["android"]["target"]
if "aarch64" in android_target:
- build_type = "Arm64"
+ arch_string = "Arm64"
elif "armv7" in android_target:
- build_type = "Armv7"
+ arch_string = "Armv7"
elif "i686" in android_target:
- build_type = "x86"
+ arch_string = "x86"
else:
- build_type = "Arm"
+ arch_string = "Arm"
- if dev:
- build_mode = "Debug"
- else:
- build_mode = "Release"
+ build_type_string = "Debug" if build_type == BuildType.DEV else "Release"
flavor_name = "Main"
if flavor is not None:
@@ -178,7 +170,7 @@ class PackageCommands(CommandBase):
shutil.copytree(path.join(dir_to_root, 'resources'), dir_to_resources)
change_prefs(dir_to_resources, "android", vr=vr)
- variant = ":assemble" + flavor_name + build_type + build_mode
+ variant = ":assemble" + flavor_name + arch_string + build_type_string
apk_task_name = ":servoapp" + variant
aar_task_name = ":servoview" + variant
maven_task_name = ":servoview:uploadArchive"
@@ -354,10 +346,6 @@ class PackageCommands(CommandBase):
@Command('install',
description='Install Servo (currently, Android and Windows only)',
category='package')
- @CommandArgument('--release', '-r', action='store_true',
- help='Install the release build')
- @CommandArgument('--dev', '-d', action='store_true',
- help='Install the dev build')
@CommandArgument('--android',
action='store_true',
help='Install on Android')
@@ -370,7 +358,8 @@ class PackageCommands(CommandBase):
@CommandArgument('--target', '-t',
default=None,
help='Install the given target platform')
- def install(self, release=False, dev=False, android=False, emulator=False, usb=False, target=None):
+ @CommandBase.common_command_arguments(build_configuration=False, build_type=True)
+ def install(self, build_type: BuildType, android=False, emulator=False, usb=False, target=None):
if target and android:
print("Please specify either --target or --android.")
sys.exit(1)
@@ -380,21 +369,21 @@ class PackageCommands(CommandBase):
env = self.build_env()
try:
- binary_path = self.get_binary_path(release, dev, android=android)
+ binary_path = self.get_binary_path(build_type, android=android)
except BuildNotFound:
print("Servo build not found. Building servo...")
result = Registrar.dispatch(
- "build", context=self.context, release=release, dev=dev, android=android,
+ "build", context=self.context, build_type=build_type, android=android,
)
if result:
return result
try:
- binary_path = self.get_binary_path(release, dev, android=android)
+ binary_path = self.get_binary_path(build_type, android=android)
except BuildNotFound:
print("Rebuilding Servo did not solve the missing build problem.")
return 1
if android:
- pkg_path = self.get_apk_path(release)
+ pkg_path = self.get_apk_path(build_type)
exec_command = [self.android_adb_path(env)]
if emulator and usb:
print("Cannot install to both emulator and USB at the same time.")
@@ -411,7 +400,7 @@ class PackageCommands(CommandBase):
if not path.exists(pkg_path):
print("Servo package not found. Packaging servo...")
result = Registrar.dispatch(
- "package", context=self.context, release=release, dev=dev, android=android,
+ "package", context=self.context, build_type=build_type, android=android,
)
if result != 0:
return result