Skip to content

Commit

Permalink
Add Android build config to mach/servobuild
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrubeck committed Oct 3, 2014
1 parent d4e977a commit b736256
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
11 changes: 10 additions & 1 deletion README.md
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion python/servo/build_commands.py
Expand Up @@ -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:
Expand All @@ -47,6 +57,10 @@ def build(self, target, release=False, jobs=None, verbose=False):
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)
Expand Down
16 changes: 16 additions & 0 deletions python/servo/command_base.py
Expand Up @@ -73,6 +73,14 @@ def __init__(self, context):
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):
Expand Down Expand Up @@ -111,6 +119,14 @@ def build_env(self):
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):
Expand Down
4 changes: 4 additions & 0 deletions servobuild.example
Expand Up @@ -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"
Expand Down

5 comments on commit b736256

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from metajack
at mbrubeck@b736256

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging mbrubeck/servo/mach-android = b736256 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mbrubeck/servo/mach-android = b736256 merged ok, testing candidate = bf7beb4

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = bf7beb4

Please sign in to comment.