From af6652fc098fee10cdf4d2ad67648e7d813f1ec8 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Wed, 24 Jan 2024 13:12:05 +0100 Subject: [PATCH] tests: Add GStreamer library directory to DYLD_LIBRARY_PATH (#31163) This fixes an issue where the dylib for harfbuzz cannot be found when running unit tests on some systems, because unit tests don't get their rpaths adjusted during build. This is quite likely an issue with dylib dependency management. We just need a bit more exploration of how this is traditionally handled. --- python/servo/command_base.py | 6 ++++++ python/servo/platform/base.py | 3 --- python/servo/platform/linux.py | 3 --- python/servo/platform/macos.py | 3 --- python/servo/platform/windows.py | 3 --- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 833f0bac417..b839f4d1dc4 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -488,6 +488,12 @@ class CommandBase(object): if gstreamer_root: util.prepend_paths_to_env(env, "PATH", os.path.join(gstreamer_root, "bin")) + # FIXME: This is necessary to run unit tests, because they depend on dylibs from the + # GStreamer distribution (such as harfbuzz), but we only modify the rpath of the + # target binary (servoshell / libsimpleservo). + if platform.is_macos: + util.prepend_paths_to_env(env, "DYLD_LIBRARY_PATH", os.path.join(gstreamer_root, "lib")) + effective_target = self.cross_compile_target or servo.platform.host_triple() if "msvc" in effective_target: # Always build harfbuzz from source diff --git a/python/servo/platform/base.py b/python/servo/platform/base.py index 7cb1a9b0996..b654a43cd5c 100644 --- a/python/servo/platform/base.py +++ b/python/servo/platform/base.py @@ -26,9 +26,6 @@ class Base: def gstreamer_root(self, _cross_compilation_target: Optional[str]) -> Optional[str]: raise NotImplementedError("Do not know how to get GStreamer path for platform.") - def library_path_variable_name(self): - raise NotImplementedError("Do not know how to set library path for platform.") - def executable_suffix(self) -> str: return "" diff --git a/python/servo/platform/linux.py b/python/servo/platform/linux.py index b49e9018358..d6000badcd9 100644 --- a/python/servo/platform/linux.py +++ b/python/servo/platform/linux.py @@ -82,9 +82,6 @@ class Linux(Base): self.is_linux = True (self.distro, self.version) = Linux.get_distro_and_version() - def library_path_variable_name(self): - return "LD_LIBRARY_PATH" - @staticmethod def get_distro_and_version() -> Tuple[str, str]: distrib = distro.name() diff --git a/python/servo/platform/macos.py b/python/servo/platform/macos.py index 73708af6446..eeb2ee26c1c 100644 --- a/python/servo/platform/macos.py +++ b/python/servo/platform/macos.py @@ -26,9 +26,6 @@ class MacOS(Base): super().__init__(*args, **kwargs) self.is_macos = True - def library_path_variable_name(self): - return "DYLD_LIBRARY_PATH" - def gstreamer_root(self, cross_compilation_target: Optional[str]) -> Optional[str]: # We do not support building with gstreamer while cross-compiling on MacOS. if cross_compilation_target or not os.path.exists(GSTREAMER_ROOT): diff --git a/python/servo/platform/windows.py b/python/servo/platform/windows.py index 028f4a167cc..394dc649493 100644 --- a/python/servo/platform/windows.py +++ b/python/servo/platform/windows.py @@ -41,9 +41,6 @@ class Windows(Base): def executable_suffix(self): return ".exe" - def library_path_variable_name(self): - return "LIB" - @classmethod def download_and_extract_dependency(cls, zip_path: str, full_spec: str): if not os.path.isfile(zip_path):