aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-12-18 13:38:39 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-12-18 13:38:39 +0530
commit361ae8d22b762e627a0bad6a6ce8dd7a0def2dd4 (patch)
tree8d04e92349c1d66a08f54425d4470a0df1b8886f
parentb389f430609a4956d23beddcdaa26b3fea06bc23 (diff)
downloadmeson-361ae8d22b762e627a0bad6a6ce8dd7a0def2dd4.zip
meson-361ae8d22b762e627a0bad6a6ce8dd7a0def2dd4.tar.gz
meson-361ae8d22b762e627a0bad6a6ce8dd7a0def2dd4.tar.bz2
qt: Fix detection of tools on Windows
When you pass an absolute path to shutil.which, it will not implicitly append any extensions. This is problematic on Windows, so we need to account for that. This fixes detection of Qt tools on Windows which are searched with the full path to the Qt bindir.
-rw-r--r--mesonbuild/dependencies.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py
index 7306201..183835d 100644
--- a/mesonbuild/dependencies.py
+++ b/mesonbuild/dependencies.py
@@ -373,6 +373,8 @@ class WxDependency(Dependency):
return self.is_found
class ExternalProgram():
+ windows_exts = ('exe', 'com', 'bat')
+
def __init__(self, name, fullpath=None, silent=False, search_dir=None):
self.name = name
if fullpath is not None:
@@ -410,11 +412,10 @@ class ExternalProgram():
pass
return False
- @staticmethod
- def _is_executable(path):
+ def _is_executable(self, path):
suffix = os.path.splitext(path)[-1].lower()[1:]
if mesonlib.is_windows():
- if suffix == 'exe' or suffix == 'com' or suffix == 'bat':
+ if suffix in self.windows_exts:
return True
elif os.access(path, os.X_OK):
return True
@@ -424,10 +425,15 @@ class ExternalProgram():
if search_dir is None:
return False
trial = os.path.join(search_dir, name)
- if not os.path.exists(trial):
+ if os.path.exists(trial):
+ if self._is_executable(trial):
+ return [trial]
+ else:
+ for ext in self.windows_exts:
+ trial_ext = '{}.{}'.format(trial, ext)
+ if os.path.exists(trial_ext):
+ return [trial_ext]
return False
- if self._is_executable(trial):
- return [trial]
# Now getting desperate. Maybe it is a script file that is a) not chmodded
# executable or b) we are on windows so they can't be directly executed.
return self._shebang_to_cmd(trial)
@@ -441,6 +447,11 @@ class ExternalProgram():
if fullpath or not mesonlib.is_windows():
# On UNIX-like platforms, the standard PATH search is enough
return [fullpath]
+ # On Windows, if name is an absolute path, we need the extension too
+ for ext in self.windows_exts:
+ fullpath = '{}.{}'.format(name, ext)
+ if os.path.exists(fullpath):
+ return [fullpath]
# On Windows, interpreted scripts must have an extension otherwise they
# cannot be found by a standard PATH search. So we do a custom search
# where we manually search for a script with a shebang in PATH.