From 7063b21cc0dccd2404bac331b1f37480f104c5c5 Mon Sep 17 00:00:00 2001 From: Charles Brunet Date: Tue, 12 Nov 2024 15:41:52 -0500 Subject: [PATCH] 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. --- mesonbuild/programs.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mesonbuild/programs.py b/mesonbuild/programs.py index 9ad38e126b60..46d00ceca2dd 100644 --- a/mesonbuild/programs.py +++ b/mesonbuild/programs.py @@ -55,6 +55,15 @@ def __init__(self, name: str, command: T.Optional[T.List[str]] = None, 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: