Skip to content

Commit

Permalink
fix missing extension in command path
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bruchar1 committed Nov 12, 2024
1 parent b3f9b9d commit 7063b21
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mesonbuild/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7063b21

Please sign in to comment.