summaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorXavier Claessens <xclaessens@netflix.com>2024-10-26 17:48:19 -0400
committerXavier Claessens <xclaesse@gmail.com>2024-10-28 09:03:46 -0400
commit38dc9894add23691a948a8a733d3175e0b94b183 (patch)
tree8f20add8d66259c56710b4a6b2f691f4e160c62e /mesonbuild/environment.py
parentb131b2dc76ff0b14d755b1a3bbf7ce9565f49b0d (diff)
downloadmeson-38dc9894add23691a948a8a733d3175e0b94b183.tar.gz
Move LD_LIBRARY_PATH logic to environment object
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r--mesonbuild/environment.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 81a23404a..584d7366d 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -1000,3 +1000,25 @@ class Environment:
def has_exe_wrapper(self) -> bool:
return self.exe_wrapper and self.exe_wrapper.found()
+
+ def get_env_for_paths(self, library_paths: T.Set[str], extra_paths: T.Set[str]) -> mesonlib.EnvironmentVariables:
+ env = mesonlib.EnvironmentVariables()
+ need_wine = not self.machines.build.is_windows() and self.machines.host.is_windows()
+ if need_wine:
+ # Executable paths should be in both PATH and WINEPATH.
+ # - Having them in PATH makes bash completion find it,
+ # and make running "foo.exe" find it when wine-binfmt is installed.
+ # - Having them in WINEPATH makes "wine foo.exe" find it.
+ library_paths.update(extra_paths)
+ if library_paths:
+ if need_wine:
+ env.prepend('WINEPATH', list(library_paths), separator=';')
+ elif self.machines.host.is_windows() or self.machines.host.is_cygwin():
+ extra_paths.update(library_paths)
+ elif self.machines.host.is_darwin():
+ env.prepend('DYLD_LIBRARY_PATH', list(library_paths))
+ else:
+ env.prepend('LD_LIBRARY_PATH', list(library_paths))
+ if extra_paths:
+ env.prepend('PATH', list(extra_paths))
+ return env