diff options
Diffstat (limited to 'python/servo/command_base.py')
-rw-r--r-- | python/servo/command_base.py | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 7d81b5a29ef..b335dcd69eb 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -24,6 +24,7 @@ import tarfile from xml.etree.ElementTree import XML from servo.util import download_file import urllib2 +from bootstrap import check_gstreamer_lib from mach.registrar import Registrar import toml @@ -347,6 +348,9 @@ class CommandBase(object): build_type = "release" if release else "debug" return path.join(base_path, build_type, apk_name) + def get_gstreamer_path(self): + return path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + 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. @@ -476,6 +480,37 @@ class CommandBase(object): bin_folder = path.join(destination_folder, "PFiles", "Mozilla research", "Servo Tech Demo") return path.join(bin_folder, "servo{}".format(BIN_SUFFIX)) + def needs_gstreamer_env(self, target): + try: + if check_gstreamer_lib(): + return False + except: + # Some systems don't have pkg-config; we can't probe in this case + # and must hope for the best + return False + effective_target = target or host_triple() + if "x86_64" not in effective_target or "android" in effective_target: + # We don't build gstreamer for non-x86_64 / android yet + return False + if sys.platform == "linux2": + if path.isdir(self.get_gstreamer_path()): + return True + else: + raise Exception("Your system's gstreamer libraries are out of date \ +(we need at least 1.12). Please run ./mach bootstrap-gstreamer") + else: + raise Exception("Your system's gstreamer libraries are out of date \ +(we need at least 1.12). If you're unable to \ +install them, let us know by filing a bug!") + return False + + def set_run_env(self, android=False): + """Some commands, like test-wpt, don't use a full build env, + but may still need dynamic search paths. This command sets that up""" + if not android and self.needs_gstreamer_env(None): + gstpath = self.get_gstreamer_path() + os.environ["LD_LIBRARY_PATH"] = path.join(gstpath, "lib", "x86_64-linux-gnu") + def build_env(self, hosts_file_path=None, target=None, is_build=False, test_unit=False): """Return an extended environment dictionary.""" env = os.environ.copy() @@ -513,12 +548,26 @@ class CommandBase(object): # Link LLVM env["LIBCLANG_PATH"] = path.join(package_dir("llvm"), "lib") - if is_windows(): if not os.environ.get("NATIVE_WIN32_PYTHON"): env["NATIVE_WIN32_PYTHON"] = sys.executable # Always build harfbuzz from source env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true" + if self.needs_gstreamer_env(target): + gstpath = self.get_gstreamer_path() + extra_path += [path.join(gstpath, "bin")] + libpath = path.join(gstpath, "lib", "x86_64-linux-gnu") + # we append in the reverse order so that system gstreamer libraries + # do not get precedence + extra_path = [libpath] + extra_path + extra_lib = [libpath] + extra_path + append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH") + + if sys.platform == "linux2": + distro, version, _ = platform.linux_distribution() + if distro == "Ubuntu" and (version == "16.04" or version == "14.04"): + env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true" + if extra_path: env["PATH"] = "%s%s%s" % (os.pathsep.join(extra_path), os.pathsep, env["PATH"]) |