aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Brubeck <mbrubeck@limpet.net>2014-09-30 13:45:21 -0700
committerMatt Brubeck <mbrubeck@limpet.net>2014-10-03 14:29:54 -0700
commitb736256d53d84ea9ba97c0fd5fc87e5d8a2e1ffd (patch)
treefcc7c4910deef5cc7bc76fa4d55528302edff69e
parentd4e977a2be1f1fea81c32d1f7024b228cb161966 (diff)
downloadservo-b736256d53d84ea9ba97c0fd5fc87e5d8a2e1ffd.tar.gz
servo-b736256d53d84ea9ba97c0fd5fc87e5d8a2e1ffd.zip
Add Android build config to mach/servobuild
-rw-r--r--README.md11
-rw-r--r--python/servo/build_commands.py16
-rw-r--r--python/servo/command_base.py16
-rw-r--r--servobuild.example4
4 files changed, 45 insertions, 2 deletions
diff --git a/README.md b/README.md
index 798da1d2dbd..5794bf98b55 100644
--- a/README.md
+++ b/README.md
@@ -87,12 +87,21 @@ cd servo
``` sh
git clone https://github.com/servo/servo
cd servo
-ANDROID_TOOLCHAIN=/path/to/toolchain ANDROID_NDK=/path/to/ndk PATH=$PATH:/path/to/toolchain/bin ./mach build --target arm-linux-androideabi
+ANDROID_TOOLCHAIN=/path/to/toolchain ANDROID_NDK=/path/to/ndk PATH=$PATH:/path/to/toolchain/bin ./mach build --android
cd ports/android
ANDROID_NDK=/path/to/ndk ANDROID_SDK=/path/to/sdk make
ANDROID_SDK=/path/to/sdk make install
```
+Rather than setting the `ANDROID_*` environment variables every time, you can
+also create a `.servobuild` file and then edit it to contain the correct paths
+to the Android SDK/NDK tools:
+
+```
+cp servobuild.example .servobuild
+# edit .servobuild
+```
+
## Running
### Commandline Arguments
diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py
index bf880390d94..2d67fdb8c75 100644
--- a/python/servo/build_commands.py
+++ b/python/servo/build_commands.py
@@ -27,17 +27,27 @@ class MachCommands(CommandBase):
@CommandArgument('--jobs', '-j',
default=None,
help='Number of jobs to run in parallel')
+ @CommandArgument('--android',
+ default=None,
+ action='store_true',
+ help='Build for Android')
@CommandArgument('--verbose', '-v',
action='store_true',
help='Print verbose output')
- def build(self, target, release=False, jobs=None, verbose=False):
+ def build(self, target=None, release=False, jobs=None, android=None,
+ verbose=False):
self.ensure_bootstrapped()
+ if android is None:
+ android = self.config["build"]["android"]
+
opts = []
if release:
opts += ["--release"]
if target:
opts += ["--target", target]
+ elif android:
+ opts += ["--target", "arm-linux-androideabi"]
if jobs is not None:
opts += ["-j", jobs]
if verbose:
@@ -47,6 +57,10 @@ class MachCommands(CommandBase):
status = subprocess.call(
["cargo", "build"] + opts,
env=self.build_env())
+ if android:
+ status = status or subprocess.call(
+ ["make", "-C", "ports/android"],
+ env=self.build_env())
elapsed = time() - build_start
print("Build completed in %0.2fs" % elapsed)
diff --git a/python/servo/command_base.py b/python/servo/command_base.py
index 3a755c7e106..72810efff0d 100644
--- a/python/servo/command_base.py
+++ b/python/servo/command_base.py
@@ -73,6 +73,14 @@ class CommandBase(object):
self.config["tools"]["cargo-root"] = path.join(
context.topdir, "cargo")
+ self.config.setdefault("build", {})
+ self.config["build"].setdefault("android", False)
+
+ self.config.setdefault("android", {})
+ self.config["android"].setdefault("sdk", "")
+ self.config["android"].setdefault("ndk", "")
+ self.config["android"].setdefault("toolchain", "")
+
_rust_snapshot_path = None
def rust_snapshot_path(self):
@@ -111,6 +119,14 @@ class CommandBase(object):
os.pathsep,
env.get("LD_LIBRARY_PATH", ""))
+ # Paths to Android build tools:
+ if self.config["android"]["sdk"]:
+ env["ANDROID_SDK"] = self.config["android"]["sdk"]
+ if self.config["android"]["ndk"]:
+ env["ANDROID_NDK"] = self.config["android"]["ndk"]
+ if self.config["android"]["toolchain"]:
+ env["ANDROID_TOOLCHAIN"] = self.config["android"]["toolchain"]
+
return env
def ensure_bootstrapped(self):
diff --git a/servobuild.example b/servobuild.example
index 71d693a3225..2d0ceeba46f 100644
--- a/servobuild.example
+++ b/servobuild.example
@@ -9,6 +9,10 @@ rust-root = "/path/to/rust"
system-cargo = false
cargo-root = "/path/to/cargo"
+[build]
+# Set "android = true" or use `mach build --android` to build the Android app.
+android = false
+
# Android information
[android]
sdk = "/opt/android-sdk"