Auto merge of #24003 - asajeffrey:magicleap-mach-install, r=Manishearth

Add --magicleap option to mach install

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22866
- [x] These changes do not require tests because we don't test installing on devices

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24003)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-08-19 12:25:43 -04:00 committed by GitHub
commit a084997afe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -487,6 +487,10 @@ class PackageCommands(CommandBase):
@CommandArgument('--android', @CommandArgument('--android',
action='store_true', action='store_true',
help='Install on Android') help='Install on Android')
@CommandArgument('--magicleap',
default=None,
action='store_true',
help='Install on Magic Leap')
@CommandArgument('--emulator', @CommandArgument('--emulator',
action='store_true', action='store_true',
help='For Android, install to the only emulated device') help='For Android, install to the only emulated device')
@ -496,29 +500,44 @@ 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')
def install(self, release=False, dev=False, android=False, emulator=False, usb=False, target=None): def install(self, release=False, dev=False, android=False, magicleap=False, emulator=False, usb=False, target=None):
env = self.build_env()
if target and android: if target and android:
print("Please specify either --target or --android.") print("Please specify either --target or --android.")
sys.exit(1) sys.exit(1)
if not android: if not android:
android = self.handle_android_target(target) android = self.handle_android_target(target)
if target and magicleap:
print("Please specify either --target or --magicleap.")
sys.exit(1)
if magicleap:
target = "aarch64-linux-android"
env = self.build_env(target=target)
try: try:
binary_path = self.get_binary_path(release, dev, android=android) binary_path = self.get_binary_path(release, dev, android=android, magicleap=magicleap)
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, android=android "build", context=self.context, release=release, dev=dev, android=android, magicleap=magicleap,
) )
if result: if result:
return result return result
try: try:
binary_path = self.get_binary_path(release, dev, android=android) binary_path = self.get_binary_path(release, dev, android=android, magicleap=magicleap)
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
if android: if magicleap:
if not env.get("MAGICLEAP_SDK"):
raise Exception("Magic Leap installs need the MAGICLEAP_SDK environment variable")
mldb = path.join(env.get("MAGICLEAP_SDK"), "tools", "mldb", "mldb")
pkg_path = path.join(path.dirname(binary_path), "Servo.mpk")
exec_command = [
mldb,
"install", "-u",
pkg_path,
]
elif android:
pkg_path = self.get_apk_path(release) pkg_path = self.get_apk_path(release)
exec_command = [self.android_adb_path(env)] exec_command = [self.android_adb_path(env)]
if emulator and usb: if emulator and usb:
@ -534,8 +553,9 @@ class PackageCommands(CommandBase):
exec_command = ["msiexec", "/i", pkg_path] exec_command = ["msiexec", "/i", pkg_path]
if not path.exists(pkg_path): if not path.exists(pkg_path):
print("Servo package not found. Packaging servo...")
result = Registrar.dispatch( result = Registrar.dispatch(
"package", context=self.context, release=release, dev=dev, android=android "package", context=self.context, release=release, dev=dev, android=android, magicleap=magicleap,
) )
if result != 0: if result != 0:
return result return result