diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/servo/build_commands.py | 36 | ||||
-rw-r--r-- | python/servo/command_base.py | 39 | ||||
-rw-r--r-- | python/servo/devenv_commands.py | 9 | ||||
-rw-r--r-- | python/servo/post_build_commands.py | 9 | ||||
-rw-r--r-- | python/servo/testing_commands.py | 6 |
5 files changed, 93 insertions, 6 deletions
diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 7b8819583c3..e4327d64b9e 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -137,6 +137,42 @@ class MachCommands(CommandBase): return ret + @Command('build-gonk', + description='Build the Gonk port', + category='build') + @CommandArgument('--jobs', '-j', + default=None, + help='Number of jobs to run in parallel') + @CommandArgument('--verbose', '-v', + action='store_true', + help='Print verbose output') + @CommandArgument('--release', '-r', + action='store_true', + help='Build in release mode') + def build_gonk(self, jobs=None, verbose=False, release=False): + self.ensure_bootstrapped() + + ret = None + opts = [] + if jobs is not None: + opts += ["-j", jobs] + if verbose: + opts += ["-v"] + if release: + opts += ["--release"] + + opts += ["--target", "arm-linux-androideabi"] + env=self.build_env(gonk=True) + build_start = time() + with cd(path.join("ports", "gonk")): + ret = subprocess.call(["cargo", "build"] + opts, env=env) + elapsed = time() - build_start + + print("Gonk build completed in %0.2fs" % elapsed) + + return ret + + @Command('build-tests', description='Build the Servo test suites', category='build') diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 3b151affdd0..b3a4b6d2feb 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -88,6 +88,10 @@ class CommandBase(object): self.config["android"].setdefault("ndk", "") self.config["android"].setdefault("toolchain", "") + self.config.setdefault("gonk", {}) + self.config["gonk"].setdefault("b2g", "") + self.config["gonk"].setdefault("product", "flame") + _rust_snapshot_path = None _cargo_build_id = None @@ -104,7 +108,7 @@ class CommandBase(object): self._cargo_build_id = open(filename).read().strip() return self._cargo_build_id - def build_env(self): + def build_env(self, gonk=False): """Return an extended environment dictionary.""" env = os.environ.copy() extra_path = [] @@ -142,6 +146,38 @@ class CommandBase(object): if self.config["android"]["toolchain"]: env["ANDROID_TOOLCHAIN"] = self.config["android"]["toolchain"] + if gonk: + if self.config["gonk"]["b2g"]: + env["GONKDIR"] = self.config["gonk"]["b2g"] + if "GONKDIR" not in env: + # Things can get pretty opaque if this hasn't been set + print("Please set $GONKDIR in your environment or servobild file") + os.exit(1) + if self.config["gonk"]["product"]: + env["GONK_PRODUCT"] = self.config["gonk"]["product"] + + env["CC"] = "arm-linux-androideabi-gcc" + env["ARCH_DIR"] = "arch-arm" + env["CPPFLAGS"] = ("-DANDROID -DTARGET_OS_GONK -DGR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE=1 " + "-isystem %(gonkdir)s/bionic/libc/%(archdir)s/include -isystem %(gonkdir)s/bionic/libc/include/ " + "-isystem %(gonkdir)s/bionic/libc/kernel/common -isystem %(gonkdir)s/bionic/libc/kernel/%(archdir)s " + "-isystem %(gonkdir)s/bionic/libm/include -I%(gonkdir)s/system -I%(gonkdir)s/system/core/include " + "-isystem %(gonkdir)s/bionic -I%(gonkdir)s/frameworks/native/opengl/include -I%(gonkdir)s/external/zlib " + "-I%(gonkdir)s/hardware/libhardware/include/hardware/") % {"gonkdir": env["GONKDIR"], "archdir": env["ARCH_DIR"] } + env["CXXFLAGS"] = ("-O2 -mandroid -fPIC %(cppflags)s -I%(gonkdir)s/ndk/sources/cxx-stl/stlport/stlport " + "-I%(gonkdir)s/ndk/sources/cxx-stl/system/include") % {"gonkdir": env["GONKDIR"], "cppflags": env["CPPFLAGS"] } + env["CFLAGS"] = ("-O2 -mandroid -fPIC %(cppflags)s -I%(gonkdir)s/ndk/sources/cxx-stl/stlport/stlport " + "-I%(gonkdir)s/ndk/sources/cxx-stl/system/include") % {"gonkdir": env["GONKDIR"], "cppflags": env["CPPFLAGS"] } + + another_extra_path = path.join(env["GONKDIR"], "prebuilts", "gcc", "linux-x86", "arm", "arm-linux-androideabi-4.7", "bin") + env["PATH"] = "%s%s%s" % (another_extra_path, os.pathsep, env["PATH"]) + env["LDFLAGS"] = ("-mandroid -L%(gonkdir)s/out/target/product/%(gonkproduct)s/obj/lib " + "-Wl,-rpath-link=%(gonkdir)s/out/target/product/%(gonkproduct)s/obj/lib " + "--sysroot=%(gonkdir)s/out/target/product/%(gonkproduct)s/obj/") % {"gonkdir": env["GONKDIR"], "gonkproduct": env["GONK_PRODUCT"] } + + # Not strictly necessary for a vanilla build, but might be when tweaking the openssl build + env["OPENSSL_PATH"] = "%(gonkdir)s/out/target/product/%(gonkproduct)s/obj/lib" % {"gonkdir": env["GONKDIR"], "gonkproduct": env["GONK_PRODUCT"] } + # FIXME: These are set because they are the variable names that # android-rs-glue expects. However, other submodules have makefiles that # reference the env var names above. Once glutin is enabled and set as @@ -166,6 +202,7 @@ class CommandBase(object): if self.context.bootstrapped: return + subprocess.check_call(["git", "submodule", "sync"]) submodules = subprocess.check_output(["git", "submodule", "status"]) for line in submodules.split('\n'): components = line.strip().split(' ') diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index 76f4a5e0bd3..cab3f7ba81f 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -1,5 +1,5 @@ from __future__ import print_function, unicode_literals -from os import path +from os import path, getcwd import subprocess @@ -23,7 +23,12 @@ class MachCommands(CommandBase): def cargo(self, params): if not params: params = [] - return subprocess.call(["cargo"] + params, + + if self.context.topdir == getcwd(): + with cd(path.join('components', 'servo')): + return subprocess.call(["cargo"] + params, + env=self.build_env()) + return subprocess.call(['cargo'] + params, env=self.build_env()) @Command('update-cargo', diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py index 7cec97f0d0a..d427fe1181f 100644 --- a/python/servo/post_build_commands.py +++ b/python/servo/post_build_commands.py @@ -75,7 +75,14 @@ class MachCommands(CommandBase): else: args = args + params - subprocess.check_call(args, env=env) + try: + subprocess.check_call(args, env=env) + except OSError as e: + if e.errno == 2: + print("Servo Binary can't be found! Run './mach build'" + " and try again!") + else: + raise e @Command('doc', description='Generate documentation', diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index ab1337a9f4f..562c103de0d 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -1,6 +1,7 @@ from __future__ import print_function, unicode_literals import argparse +import sys import os import os.path as path import subprocess @@ -27,7 +28,9 @@ class MachCommands(CommandBase): def ensure_built_tests(self): if self.context.built_tests: return - Registrar.dispatch('build-tests', context=self.context) + returncode = Registrar.dispatch('build-tests', context=self.context) + if returncode: + sys.exit(returncode) self.context.built_tests = True def find_test(self, prefix): @@ -180,7 +183,6 @@ class MachCommands(CommandBase): def test_content(self, test_name=None): self.ensure_bootstrapped() self.ensure_built_tests() - test_path = path.join(self.context.topdir, "tests", "content") test_args = ["--source-dir=%s" % test_path] |