diff options
| author | Xavier Claessens <xclaessens@netflix.com> | 2024-10-26 17:48:19 -0400 |
|---|---|---|
| committer | Xavier Claessens <xclaesse@gmail.com> | 2024-10-28 09:03:46 -0400 |
| commit | 38dc9894add23691a948a8a733d3175e0b94b183 (patch) | |
| tree | 8f20add8d66259c56710b4a6b2f691f4e160c62e /mesonbuild/environment.py | |
| parent | b131b2dc76ff0b14d755b1a3bbf7ce9565f49b0d (diff) | |
| download | meson-38dc9894add23691a948a8a733d3175e0b94b183.tar.gz | |
Move LD_LIBRARY_PATH logic to environment object
Diffstat (limited to 'mesonbuild/environment.py')
| -rw-r--r-- | mesonbuild/environment.py | 22 |
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 |
