Add Windows support for mach install

This commit is contained in:
UK992 2016-12-09 22:58:33 +01:00
parent ca9e726280
commit 10cf2e1f39

View file

@ -321,33 +321,44 @@ class PackageCommands(CommandBase):
print("Packaged Servo into " + tar_path) print("Packaged Servo into " + tar_path)
@Command('install', @Command('install',
description='Install Servo (currently, Android only)', description='Install Servo (currently, Android and Windows only)',
category='package') category='package')
@CommandArgument('--release', '-r', action='store_true', @CommandArgument('--release', '-r', action='store_true',
help='Install the release build') help='Install the release build')
@CommandArgument('--dev', '-d', action='store_true', @CommandArgument('--dev', '-d', action='store_true',
help='Install the dev build') help='Install the dev build')
def install(self, release=False, dev=False): @CommandArgument('--android',
action='store_true',
help='Install on Android')
def install(self, release=False, dev=False, android=False):
try: try:
binary_path = self.get_binary_path(release, dev, android=True) binary_path = self.get_binary_path(release, dev, android=android)
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, release=release, dev=dev "build", context=self.context, release=release, dev=dev, android=android
) )
if result: if result:
return result return result
try: try:
binary_path = self.get_binary_path(release, dev, android=True) binary_path = self.get_binary_path(release, dev, android=android)
except BuildNotFound: except BuildNotFound:
print("Rebuilding Servo did not solve the missing build problem.") print("Rebuilding Servo did not solve the missing build problem.")
return 1 return 1
apk_path = binary_path + ".apk" if android:
if not path.exists(apk_path): pkg_path = binary_path + ".apk"
result = Registrar.dispatch("package", context=self.context, release=release, dev=dev) exec_command = ["adb", "install", "-r", pkg_path]
elif is_windows():
pkg_path = path.join(path.dirname(binary_path), 'msi', 'Servo.msi')
exec_command = ["msiexec", "/i", pkg_path]
if not path.exists(pkg_path):
result = Registrar.dispatch(
"package", context=self.context, release=release, dev=dev, android=android
)
if result != 0: if result != 0:
return result return result
print(["adb", "install", "-r", apk_path]) print(" ".join(exec_command))
return subprocess.call(["adb", "install", "-r", apk_path], env=self.build_env()) return subprocess.call(exec_command, env=self.build_env())