From f73970cc8f2599e41bac4e99de3a88ee7983a7ce Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 7 Nov 2022 13:04:22 -0500 Subject: [PATCH] devenv: Add executables locations to both PATH and WINEPATH Handles the case when wine-binfmt is installed, which makes .exe files executable without without specifying an exe wrapper. --- mesonbuild/backend/backends.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 747d80edd..eda6fb6d2 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -1850,9 +1850,9 @@ class Backend: env = build.EnvironmentVariables() extra_paths = set() library_paths = set() + build_machine = self.environment.machines[MachineChoice.BUILD] host_machine = self.environment.machines[MachineChoice.HOST] - need_exe_wrapper = self.environment.need_exe_wrapper() - need_wine = need_exe_wrapper and host_machine.is_windows() + need_wine = not build_machine.is_windows() and host_machine.is_windows() for t in self.build.get_targets().values(): cross_built = not self.environment.machines.matches_build_machine(t.for_machine) can_run = not cross_built or not need_exe_wrapper or need_wine @@ -1874,18 +1874,23 @@ class Backend: # LD_LIBRARY_PATH. This allows running system applications using # that library. library_paths.add(tdir) + 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 host_machine.is_windows() or host_machine.is_cygwin(): + if need_wine: + env.prepend('WINEPATH', list(library_paths), separator=';') + elif host_machine.is_windows() or host_machine.is_cygwin(): extra_paths.update(library_paths) elif host_machine.is_darwin(): env.prepend('DYLD_LIBRARY_PATH', list(library_paths)) else: env.prepend('LD_LIBRARY_PATH', list(library_paths)) if extra_paths: - if need_wine: - env.prepend('WINEPATH', list(extra_paths), separator=';') - else: - env.prepend('PATH', list(extra_paths)) + env.prepend('PATH', list(extra_paths)) return env def compiler_to_generator(self, target: build.BuildTarget,