From 36797801e9eda3405444cd55201104072a55a099 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 3 Sep 2018 13:54:20 +0530 Subject: [PATCH] Allow WPT to be run with local gstreamer --- python/servo/command_base.py | 35 ++++++++++++++++++++++---------- python/servo/testing_commands.py | 1 + 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index c997b0bcc80..cedfeb626f3 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -477,6 +477,23 @@ 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): + gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + if sys.platform == "linux2" and path.isdir(gstpath): + if not check_gstreamer_lib(): + if "x86_64" not in (target or host_triple()): + raise Exception("We don't currently support using local gstreamer builds \ + for non-x86_64, please file a bug") + return True + return False + + def set_run_env(self): + """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 self.needs_gstreamer_env(None): + gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + 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() @@ -519,17 +536,13 @@ class CommandBase(object): # Always build harfbuzz from source env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true" - gstpath = path.join(os.getcwd(), "support", "linux", "gstreamer", "gstreamer") - if sys.platform == "linux2" and path.isdir(gstpath): - if not check_gstreamer_lib(): - if "x86_64" not in (target or host_triple()): - raise Exception("We don't currently support using local gstreamer builds \ - for non-x86_64, please file a bug") - extra_path += [path.join(gstpath, "bin")] - libpath = path.join(gstpath, "lib", "x86_64-linux-gnu") - extra_path += [libpath] - extra_lib += [libpath] - append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH") + if self.needs_gstreamer_env(target): + gstpath = path.join(self.context.topdir, "support", "linux", "gstreamer", "gstreamer") + extra_path += [path.join(gstpath, "bin")] + libpath = path.join(gstpath, "lib", "x86_64-linux-gnu") + extra_path += [libpath] + extra_lib += [libpath] + append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH") if extra_path: env["PATH"] = "%s%s%s" % (os.pathsep.join(extra_path), os.pathsep, env["PATH"]) diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 1cfddcc1ac7..957dfca22ae 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -383,6 +383,7 @@ class MachCommands(CommandBase): return self._test_wpt(**kwargs) def _test_wpt(self, **kwargs): + self.set_run_env() hosts_file_path = path.join(self.context.topdir, 'tests', 'wpt', 'hosts') os.environ["hosts_file_path"] = hosts_file_path run_file = path.abspath(path.join(self.context.topdir, "tests", "wpt", "run.py"))