diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-05-13 10:24:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-13 10:24:29 -0500 |
commit | 286bfb96a06705e37e690be07a51f5e1797f35b0 (patch) | |
tree | be4fc497a0f959ca4f73fb9b476149c52bbb7207 /python/servo | |
parent | 2766529c2450ba3fac1b7669c195869a0f7e341b (diff) | |
parent | 01228282cd7725a1c8d822006a42acc84c4eef2c (diff) | |
download | servo-286bfb96a06705e37e690be07a51f5e1797f35b0.tar.gz servo-286bfb96a06705e37e690be07a51f5e1797f35b0.zip |
Auto merge of #16769 - MortimerGoro:android_archs, r=larsbergstrom
Support for Android armv7 and aarch64 target triples
<!-- Please describe your changes on the following line: -->
Support for Android armv7 and aarch64 target triples in python build scripts (build + packaging)
`--android` build parameter works as always (arm-linux-androideabi still the default)
`./mach build --release --android`
New compilation modes for android
`./mach build --release --target=arm-linux-androideabi`
`./mach build --release --target=armv7-linux-androideabi`
`./mach build --release --target=aarch64-linux-android`
See https://github.com/servo/servo/issues/11921. When all crates are ready we'll switch default android compilations to` armv7-linux-androideabi` target triple.
---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- 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/16769)
<!-- Reviewable:end -->
Diffstat (limited to 'python/servo')
-rw-r--r-- | python/servo/build_commands.py | 13 | ||||
-rw-r--r-- | python/servo/command_base.py | 29 | ||||
-rw-r--r-- | python/servo/package_commands.py | 14 |
3 files changed, 49 insertions, 7 deletions
diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 73c5bd9572d..546fcfdf911 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -221,11 +221,14 @@ class MachCommands(CommandBase): opts += ["-j", jobs] if verbose: opts += ["-v"] + if android: target = self.config["android"]["target"] if target: opts += ["--target", target] + if not android: + android = self.handle_android_target(target) self.ensure_bootstrapped(target=target) self.ensure_clobbered() @@ -278,10 +281,15 @@ class MachCommands(CommandBase): elif cpu_type in ["x86_64", "x86-64", "x64", "amd64"]: host_suffix = "x86_64" host = os_type + "-" + host_suffix + + android_platform = self.config["android"]["platform"] + android_toolchain = self.config["android"]["toolchain_name"] + android_arch = "arch-" + self.config["android"]["arch"] + env['PATH'] = path.join( - env['ANDROID_NDK'], "toolchains", "arm-linux-androideabi-4.9", "prebuilt", host, "bin" + env['ANDROID_NDK'], "toolchains", android_toolchain, "prebuilt", host, "bin" ) + ':' + env['PATH'] - env['ANDROID_SYSROOT'] = path.join(env['ANDROID_NDK'], "platforms", "android-18", "arch-arm") + env['ANDROID_SYSROOT'] = path.join(env['ANDROID_NDK'], "platforms", android_platform, android_arch) support_include = path.join(env['ANDROID_NDK'], "sources", "android", "support", "include") cxx_include = path.join( env['ANDROID_NDK'], "sources", "cxx-stl", "llvm-libc++", "libcxx", "include") @@ -295,6 +303,7 @@ class MachCommands(CommandBase): "-I" + support_include, "-I" + cxx_include, "-I" + cxxabi_include]) + env["NDK_ANDROID_VERSION"] = android_platform.replace("android-", "") cargo_binary = "cargo" + BIN_SUFFIX diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 7ab5191b41a..8f04fde27e4 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -277,8 +277,7 @@ class CommandBase(object): self.config["android"].setdefault("sdk", "") self.config["android"].setdefault("ndk", "") self.config["android"].setdefault("toolchain", "") - self.config["android"].setdefault("platform", "android-18") - self.config["android"].setdefault("target", "arm-linux-androideabi") + self.handle_android_target("arm-linux-androideabi") self.set_cargo_root() self.set_use_stable_rust(False) @@ -538,7 +537,31 @@ class CommandBase(object): return path.join(self.context.topdir, "support", "android") def android_build_dir(self, dev): - return path.join(self.get_target_dir(), "arm-linux-androideabi", "debug" if dev else "release") + return path.join(self.get_target_dir(), self.config["android"]["target"], "debug" if dev else "release") + + def handle_android_target(self, target): + if target == "arm-linux-androideabi": + self.config["android"]["platform"] = "android-18" + self.config["android"]["target"] = target + self.config["android"]["arch"] = "arm" + self.config["android"]["lib"] = "armeabi" + self.config["android"]["toolchain_name"] = target + "-4.9" + return True + elif target == "armv7-linux-androideabi": + self.config["android"]["platform"] = "android-18" + self.config["android"]["target"] = target + self.config["android"]["arch"] = "arm" + self.config["android"]["lib"] = "armeabi-v7a" + self.config["android"]["toolchain_name"] = "arm-linux-androideabi-4.9" + return True + elif target == "aarch64-linux-android": + self.config["android"]["platform"] = "android-21" + self.config["android"]["target"] = target + self.config["android"]["arch"] = "arm64" + self.config["android"]["lib"] = "arm64-v8a" + self.config["android"]["toolchain_name"] = target + "-4.9" + return True + return False def ensure_bootstrapped(self, target=None): if self.context.bootstrapped: diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index 63921037c25..ad842c9258a 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -141,10 +141,20 @@ class PackageCommands(CommandBase): 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" + elif "armv7" in android_target: + build_type = "Armv7" + else: + build_type = "Arm" + if dev: - task_name = "assembleArmDebug" + build_mode = "Debug" else: - task_name = "assembleArmRelease" + build_mode = "Release" + + task_name = "assemble" + build_type + build_mode try: with cd(path.join("support", "android", "apk")): subprocess.check_call(["./gradlew", "--no-daemon", task_name], env=env) |