From 4cbf3dea054469c03551b19afc8a819dc52a453e Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 25 Jun 2018 18:50:15 +0200 Subject: [PATCH] mach {package,install} --android: add --emulator and --usb --- python/servo/package_commands.py | 18 ++++++++++++++++-- python/servo/post_build_commands.py | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index 5f0e3494279..296f25cd00e 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -389,10 +389,16 @@ class PackageCommands(CommandBase): @CommandArgument('--android', action='store_true', help='Install on Android') + @CommandArgument('--emulator', + action='store_true', + help='For Android, intall to the only emulated device') + @CommandArgument('--usb', + action='store_true', + help='For Android, intall to the only USB device') @CommandArgument('--target', '-t', default=None, help='Install the given target platform') - def install(self, release=False, dev=False, android=False, target=None): + def install(self, release=False, dev=False, android=False, emulator=False, usb=False, target=None): env = self.build_env() if target and android: print("Please specify either --target or --android.") @@ -416,7 +422,15 @@ class PackageCommands(CommandBase): if android: pkg_path = binary_path + ".apk" - exec_command = [self.android_adb_path(env), "install", "-r", pkg_path] + exec_command = [self.android_adb_path(env)] + if emulator and usb: + print("Cannot install to both emulator and USB at the same time.") + return 1 + if emulator: + exec_command += ["-e"] + if usb: + exec_command += ["-d"] + exec_command += ["install", "-r", pkg_path] elif is_windows(): pkg_path = path.join(path.dirname(binary_path), 'msi', 'Servo.msi') exec_command = ["msiexec", "/i", pkg_path] diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py index 2705fda10fa..d89a8af458a 100644 --- a/python/servo/post_build_commands.py +++ b/python/servo/post_build_commands.py @@ -45,6 +45,12 @@ class PostBuildCommands(CommandBase): help='Run the dev build') @CommandArgument('--android', action='store_true', default=None, help='Run on an Android device through `adb shell`') + @CommandArgument('--emulator', + action='store_true', + help='For Android, intall to the only emulated device') + @CommandArgument('--usb', + action='store_true', + help='For Android, intall to the only USB device') @CommandArgument('--debug', action='store_true', help='Enable the debugger. Not specifying a ' '--debugger option will result in the default ' @@ -64,7 +70,7 @@ class PostBuildCommands(CommandBase): 'params', nargs='...', help="Command-line arguments to be passed through to Servo") def run(self, params, release=False, dev=False, android=None, debug=False, debugger=None, - headless=False, software=False, bin=None, nightly=None): + headless=False, software=False, bin=None, emulator=False, usb=False, nightly=None): env = self.build_env() env["RUST_BACKTRACE"] = "1" @@ -95,7 +101,15 @@ class PostBuildCommands(CommandBase): "echo Servo PID: $(pidof com.mozilla.servo)", "exit" ] - shell = subprocess.Popen([self.android_adb_path(env), "shell"], stdin=subprocess.PIPE) + args = [self.android_adb_path(env)] + if emulator and usb: + print("Cannot install to both emulator and USB at the same time.") + return 1 + if emulator: + args += ["-e"] + if usb: + args += ["-d"] + shell = subprocess.Popen(args + ["shell"], stdin=subprocess.PIPE) shell.communicate("\n".join(script) + "\n") return shell.wait()