New Android suppport

This commit is contained in:
Lars Bergstrom 2015-09-24 13:33:55 -05:00
parent 53d8f04ac4
commit 17a6cb5873
25 changed files with 657 additions and 29 deletions

View file

@ -198,13 +198,6 @@ class MachCommands(CommandBase):
if verbose:
opts += ["-v"]
if android:
# Ensure the APK builder submodule has been built first
apk_builder_dir = "support/android-rs-glue"
with cd(path.join(apk_builder_dir, "apk-builder")):
status = call(["cargo", "build"], env=self.build_env(), verbose=verbose)
if status:
return status
opts += ["--target", "arm-linux-androideabi"]
if debug_mozjs or self.config["build"]["debug-mozjs"]:

View file

@ -135,6 +135,9 @@ class CommandBase(object):
self._cargo_build_id = f.read().strip()
return self._cargo_build_id
def get_top_dir(self):
return self.context.topdir
def get_target_dir(self):
if "CARGO_TARGET_DIR" in os.environ:
return os.environ["CARGO_TARGET_DIR"]

View file

@ -22,7 +22,7 @@ from mach.decorators import (
Command,
)
from servo.command_base import CommandBase
from servo.command_base import CommandBase, cd
def read_file(filename, if_exists=False):
@ -33,8 +33,7 @@ def read_file(filename, if_exists=False):
@CommandProvider
class MachCommands(CommandBase):
class PostBuildCommands(CommandBase):
@Command('run',
description='Run Servo',
category='post-build')
@ -167,3 +166,36 @@ class MachCommands(CommandBase):
import webbrowser
webbrowser.open("file://" + path.abspath(path.join(
self.get_target_dir(), "doc", "servo", "index.html")))
@Command('package',
description='Package Servo (currently, Android APK only)',
category='post-build')
@CommandArgument('--release', '-r', action='store_true',
help='Package the release build')
@CommandArgument('--dev', '-d', action='store_true',
help='Package the dev build')
@CommandArgument(
'params', nargs='...',
help="Command-line arguments to be passed through to Servo")
def package(self, params, release=False, dev=False, debug=False, debugger=None):
env = self.build_env()
target_dir = path.join(self.get_target_dir(), "arm-linux-androideabi")
dev_flag = ""
if dev:
env["NDK_DEBUG"] = "1"
env["ANT_FLAVOR"] = "debug"
dev_flag = "-d"
target_dir = path.join(target_dir, "debug")
else:
env["ANT_FLAVOR"] = "release"
target_dir = path.join(target_dir, "release")
output_apk = path.join(target_dir, "servo.apk")
try:
with cd(path.join("support", "android", "build-apk")):
subprocess.check_call(["cargo", "run", "--", dev_flag, "-o", output_apk, "-t", target_dir,
"-r", self.get_top_dir()], env=env)
except subprocess.CalledProcessError as e:
print("Packaging Android exited with return value %d" % e.returncode)
return e.returncode