diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-05-08 20:08:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-08 20:08:28 +0200 |
commit | e0cf45edf099240cce38661904d3169c7fd9bb76 (patch) | |
tree | 8ac7592c352c08db9e13244f1744cc9d407b54e1 /mesonbuild/dependencies.py | |
parent | 8b0d575823ca6a0a36c20952220b9beec6664b20 (diff) | |
parent | 333085160d6cbff2b4a47fac76cb507cd1f6d1c7 (diff) | |
download | meson-e0cf45edf099240cce38661904d3169c7fd9bb76.zip meson-e0cf45edf099240cce38661904d3169c7fd9bb76.tar.gz meson-e0cf45edf099240cce38661904d3169c7fd9bb76.tar.bz2 |
Merge pull request #1747 from centricular/run-command-configure-file
Some fixes to run_command()
Diffstat (limited to 'mesonbuild/dependencies.py')
-rw-r--r-- | mesonbuild/dependencies.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index ef7be3a..37e2cbd 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -465,8 +465,9 @@ class ExternalProgram: @staticmethod def _shebang_to_cmd(script): """ - Windows does not understand shebangs, so we check if the file has a - shebang and manually parse it to figure out the interpreter to use + Check if the file has a shebang and manually parse it to figure out + the interpreter to use. This is useful if the script is not executable + or if we're on Windows (which does not understand shebangs). """ try: with open(script) as f: @@ -504,15 +505,17 @@ class ExternalProgram: if os.path.exists(trial): 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) else: - for ext in self.windows_exts: - trial_ext = '{}.{}'.format(trial, ext) - if os.path.exists(trial_ext): - return [trial_ext] - return False - # 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) + if mesonlib.is_windows(): + for ext in self.windows_exts: + trial_ext = '{}.{}'.format(trial, ext) + if os.path.exists(trial_ext): + return [trial_ext] + return False def _search(self, name, search_dir): ''' @@ -525,7 +528,8 @@ class ExternalProgram: # Do a standard search in PATH command = shutil.which(name) if not mesonlib.is_windows(): - # On UNIX-like platforms, the standard PATH search is enough + # On UNIX-like platforms, shutil.which() is enough to find + # all executables whether in PATH or with an absolute path return [command] # HERE BEGINS THE TERROR OF WINDOWS if command: @@ -567,9 +571,9 @@ class ExternalProgram: return self.command[:] def get_path(self): - # Assume that the last element is the full path to the script - # If it's not a script, this will be an array of length 1 if self.found(): + # Assume that the last element is the full path to the script or + # binary being run return self.command[-1] return None |