mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Auto merge of #20912 - paulrouget:androidv2, r=jdm,mortimergoro,simonsapin
Revisit how the Android port works. Fix #20855 Fix #18625 Fix #21147 Before polishing and making sure everything works fine (like the VR code, the android-x86 version, the non-android version of the lib, …), I'd like to get some early feedback on the approach. I recommend reviewing commit by commit. To test, just follow the regular steps: ``` ./mach build -d --android ./mach package --dev --android builds servo.apk ./mach install --dev --android && ./mach run --android ``` --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] 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/20912) <!-- Reviewable:end -->
This commit is contained in:
commit
95b54ca8f3
57 changed files with 2450 additions and 915 deletions
|
@ -63,7 +63,7 @@ class MachCommands(CommandBase):
|
|||
ndk = "android-ndk-r12b-{system}-{arch}"
|
||||
tools = "sdk-tools-{system}-4333796"
|
||||
|
||||
sdk_build_tools = "25.0.2"
|
||||
sdk_build_tools = "27.0.3"
|
||||
emulator_images = [
|
||||
("servo-arm", "25", "google_apis;armeabi-v7a"),
|
||||
("servo-x86", "28", "google_apis;x86"),
|
||||
|
|
|
@ -185,7 +185,6 @@ class MachCommands(CommandBase):
|
|||
debug_mozjs=False, params=None, with_debug_assertions=False):
|
||||
|
||||
opts = params or []
|
||||
opts += ["--manifest-path", self.servo_manifest()]
|
||||
|
||||
if android is None:
|
||||
android = self.config["build"]["android"]
|
||||
|
@ -420,4 +419,4 @@ class MachCommands(CommandBase):
|
|||
opts += ["-v"]
|
||||
opts += params
|
||||
return check_call(["cargo", "clean"] + opts,
|
||||
env=self.build_env(), cwd=self.servo_crate(), verbose=verbose)
|
||||
env=self.build_env(), cwd=self.ports_servo_crate(), verbose=verbose)
|
||||
|
|
|
@ -330,15 +330,24 @@ class CommandBase(object):
|
|||
else:
|
||||
return path.join(self.context.topdir, "target")
|
||||
|
||||
def get_apk_path(self, release):
|
||||
base_path = self.get_target_dir()
|
||||
base_path = path.join(base_path, self.config["android"]["target"])
|
||||
apk_name = "servoapp.apk"
|
||||
build_type = "release" if release else "debug"
|
||||
return path.join(base_path, build_type, apk_name)
|
||||
|
||||
def get_binary_path(self, release, dev, android=False):
|
||||
# TODO(autrilla): this function could still use work - it shouldn't
|
||||
# handle quitting, or printing. It should return the path, or an error.
|
||||
base_path = self.get_target_dir()
|
||||
|
||||
binary_name = "servo" + BIN_SUFFIX
|
||||
|
||||
if android:
|
||||
base_path = path.join(base_path, self.config["android"]["target"])
|
||||
binary_name = "libsimpleservo.so"
|
||||
|
||||
binary_name = "servo" + BIN_SUFFIX
|
||||
release_path = path.join(base_path, "release", binary_name)
|
||||
dev_path = path.join(base_path, "debug", binary_name)
|
||||
|
||||
|
@ -594,10 +603,10 @@ class CommandBase(object):
|
|||
|
||||
return env
|
||||
|
||||
def servo_crate(self):
|
||||
def ports_servo_crate(self):
|
||||
return path.join(self.context.topdir, "ports", "servo")
|
||||
|
||||
def servo_manifest(self):
|
||||
def ports_servo_manifest(self):
|
||||
return path.join(self.context.topdir, "ports", "servo", "Cargo.toml")
|
||||
|
||||
def servo_features(self):
|
||||
|
|
|
@ -42,7 +42,7 @@ from servo.util import delete
|
|||
|
||||
PACKAGES = {
|
||||
'android': [
|
||||
'target/armv7-linux-androideabi/release/servo.apk',
|
||||
'target/armv7-linux-androideabi/release/servoapp.apk',
|
||||
],
|
||||
'linux': [
|
||||
'target/release/servo-tech-demo.tar.gz',
|
||||
|
@ -421,7 +421,7 @@ class PackageCommands(CommandBase):
|
|||
return 1
|
||||
|
||||
if android:
|
||||
pkg_path = binary_path + ".apk"
|
||||
pkg_path = self.get_apk_path(release)
|
||||
exec_command = [self.android_adb_path(env)]
|
||||
if emulator and usb:
|
||||
print("Cannot install to both emulator and USB at the same time.")
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import json
|
||||
import os
|
||||
import os.path as path
|
||||
import subprocess
|
||||
|
@ -34,6 +35,13 @@ def read_file(filename, if_exists=False):
|
|||
return f.read()
|
||||
|
||||
|
||||
# Copied from Python 3.3+'s shlex.quote()
|
||||
def shell_quote(arg):
|
||||
# use single quotes, and put single quotes into double quotes
|
||||
# the string $'b is then quoted as '$'"'"'b'
|
||||
return "'" + arg.replace("'", "'\"'\"'") + "'"
|
||||
|
||||
|
||||
@CommandProvider
|
||||
class PostBuildCommands(CommandBase):
|
||||
@Command('run',
|
||||
|
@ -88,15 +96,11 @@ class PostBuildCommands(CommandBase):
|
|||
return
|
||||
script = [
|
||||
"am force-stop com.mozilla.servo",
|
||||
"echo servo >/sdcard/Android/data/com.mozilla.servo/files/android_params"
|
||||
]
|
||||
for param in params:
|
||||
script += [
|
||||
"echo '%s' >>/sdcard/Android/data/com.mozilla.servo/files/android_params"
|
||||
% param.replace("'", "\\'")
|
||||
]
|
||||
json_params = shell_quote(json.dumps(params))
|
||||
extra = "-e servoargs " + json_params
|
||||
script += [
|
||||
"am start com.mozilla.servo/com.mozilla.servo.MainActivity",
|
||||
"am start " + extra + " com.mozilla.servo/com.mozilla.servo.MainActivity",
|
||||
"sleep 0.5",
|
||||
"echo Servo PID: $(pidof com.mozilla.servo)",
|
||||
"exit"
|
||||
|
@ -257,7 +261,7 @@ class PostBuildCommands(CommandBase):
|
|||
copy2(full_name, destination)
|
||||
|
||||
return self.call_rustup_run(
|
||||
["cargo", "doc", "--manifest-path", self.servo_manifest()] + params,
|
||||
["cargo", "doc", "--manifest-path", self.ports_servo_manifest()] + params,
|
||||
env=self.build_env()
|
||||
)
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ class MachCommands(CommandBase):
|
|||
|
||||
features = self.servo_features()
|
||||
if len(packages) > 0 or len(in_crate_packages) > 0:
|
||||
args = ["cargo", "bench" if bench else "test", "--manifest-path", self.servo_manifest()]
|
||||
args = ["cargo", "bench" if bench else "test", "--manifest-path", self.ports_servo_manifest()]
|
||||
for crate in packages:
|
||||
args += ["-p", "%s_tests" % crate]
|
||||
for crate in in_crate_packages:
|
||||
|
@ -576,7 +576,7 @@ class MachCommands(CommandBase):
|
|||
def test_android_startup(self, release, dev):
|
||||
html = """
|
||||
<script>
|
||||
console.log("JavaScript is running!")
|
||||
window.alert("JavaScript is running!")
|
||||
</script>
|
||||
"""
|
||||
url = "data:text/html;base64," + html.encode("base64").replace("\n", "")
|
||||
|
@ -607,8 +607,7 @@ class MachCommands(CommandBase):
|
|||
env = self.build_env(target=target)
|
||||
os.environ["PATH"] = env["PATH"]
|
||||
assert self.handle_android_target(target)
|
||||
binary_path = self.get_binary_path(release, dev, android=True)
|
||||
apk = binary_path + ".apk"
|
||||
apk = self.get_apk_path(release)
|
||||
|
||||
py = path.join(self.context.topdir, "etc", "run_in_headless_android_emulator.py")
|
||||
return [py, avd, apk]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue