diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-03-16 00:54:50 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2016-03-17 16:16:35 +0530 |
commit | d5c9b98cab5aba89ac7ba184b56f1b9d00bd6d24 (patch) | |
tree | bfa89ad01f8e48420cb3fd627aeb310aa9f72e75 | |
parent | a3004652eaa8eef877ccf009e7a6ec8e32ad3475 (diff) | |
download | meson-d5c9b98cab5aba89ac7ba184b56f1b9d00bd6d24.zip meson-d5c9b98cab5aba89ac7ba184b56f1b9d00bd6d24.tar.gz meson-d5c9b98cab5aba89ac7ba184b56f1b9d00bd6d24.tar.bz2 |
meson_install.py: Start by checking if the shebang is directly runnable
If it's just runnable as-is, then we don't need to do fancy basename detection
and such to find the interpretor to use for running the script.
-rw-r--r-- | mesonbuild/scripts/meson_install.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py index 792af6c..8e3d0ca 100644 --- a/mesonbuild/scripts/meson_install.py +++ b/mesonbuild/scripts/meson_install.py @@ -118,10 +118,14 @@ def run_install_script(d): if platform.system().lower() == 'windows' and suffix != '.bat': first_line = open(script).readline().strip() if first_line.startswith('#!'): - commands = first_line[2:].split('#')[0].strip().split() - commands[0] = shutil.which(commands[0].split('/')[-1]) - if commands[0] is None: - raise RuntimeError("Don't know how to run script %s." % script) + if shutil.which(first_line[2:]): + commands = [first_line[2:]] + else: + commands = first_line[2:].split('#')[0].strip().split() + commands[0] = shutil.which(commands[0].split('/')[-1]) + if commands[0] is None: + commands + raise RuntimeError("Don't know how to run script %s." % script) final_command = commands + [script] + i.cmd_arr[1:] else: final_command = i.cmd_arr @@ -129,8 +133,8 @@ def run_install_script(d): rc = subprocess.call(final_command, env=child_env) if rc != 0: sys.exit(rc) - except Exception: - print('Failed to run install script:', i.cmd_arr[0]) + except: + print('Failed to run install script:', *i.cmd_arr) sys.exit(1) def is_elf_platform(): |