summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2024-11-12 15:41:52 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2025-01-07 21:37:56 +0200
commit0310ab6c6db1938fd94345bbe8c54bf6c33b90fd (patch)
treec777a412ca860ef37fa0cb7456f3d8a984142971
parent836bfb93c4fca7132885b727849315ec19cedfc8 (diff)
downloadmeson-0310ab6c6db1938fd94345bbe8c54bf6c33b90fd.tar.gz
fix missing extension in command path
On Windows, if the native file contains a path without the extension, the executable may be found, but custom target would fail because that path does not exist.
-rw-r--r--mesonbuild/programs.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/mesonbuild/programs.py b/mesonbuild/programs.py
index 9ad38e126..46d00ceca 100644
--- a/mesonbuild/programs.py
+++ b/mesonbuild/programs.py
@@ -55,6 +55,15 @@ class ExternalProgram(mesonlib.HoldableObject):
if ret:
self.command = ret + args
else:
+ if os.path.isabs(cmd) and not os.path.exists(cmd):
+ # Maybe the name is an absolute path to a native Windows
+ # executable, but without the extension. This is technically wrong,
+ # but many people do it because it works in the MinGW shell.
+ for ext in self.windows_exts:
+ trial_ext = f'{cmd}.{ext}'
+ if os.path.exists(trial_ext):
+ cmd = trial_ext
+ break
self.command = [cmd] + args
else:
if search_dirs is None: