diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-08-29 21:23:43 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-09-08 20:15:56 +0200 |
commit | a4f4379c44c7f13bc9e44bc01504077af1f3a338 (patch) | |
tree | 6f969b023a4311c7bad7b1dbdd61fa845cadfef3 /mesonbuild/scripts/commandrunner.py | |
parent | 0d57e307b2fea541a9ee368873431fe224e5c982 (diff) | |
download | meson-a4f4379c44c7f13bc9e44bc01504077af1f3a338.zip meson-a4f4379c44c7f13bc9e44bc01504077af1f3a338.tar.gz meson-a4f4379c44c7f13bc9e44bc01504077af1f3a338.tar.bz2 |
typing: fully annotate scripts
Diffstat (limited to 'mesonbuild/scripts/commandrunner.py')
-rw-r--r-- | mesonbuild/scripts/commandrunner.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/mesonbuild/scripts/commandrunner.py b/mesonbuild/scripts/commandrunner.py index 22da417..aeeaa3b 100644 --- a/mesonbuild/scripts/commandrunner.py +++ b/mesonbuild/scripts/commandrunner.py @@ -17,8 +17,9 @@ what to run, sets up the environment and executes the command.""" import sys, os, subprocess, shutil, shlex import re +import typing as T -def run_command(source_dir, build_dir, subdir, meson_command, command, arguments): +def run_command(source_dir: str, build_dir: str, subdir: str, meson_command: T.List[str], command: str, arguments: T.List[str]) -> subprocess.Popen: env = {'MESON_SOURCE_ROOT': source_dir, 'MESON_BUILD_ROOT': build_dir, 'MESON_SUBDIR': subdir, @@ -50,24 +51,24 @@ def run_command(source_dir, build_dir, subdir, meson_command, command, arguments print('Could not execute command "{}": {}'.format(command, err)) sys.exit(1) -def is_python_command(cmdname): +def is_python_command(cmdname: str) -> bool: end_py_regex = r'python(3|3\.\d+)?(\.exe)?$' return re.search(end_py_regex, cmdname) is not None -def run(args): +def run(args: T.List[str]) -> int: if len(args) < 4: print('commandrunner.py <source dir> <build dir> <subdir> <command> [arguments]') return 1 src_dir = args[0] build_dir = args[1] subdir = args[2] - meson_command = args[3] - if is_python_command(meson_command): - meson_command = [meson_command, args[4]] + meson_bin = args[3] + if is_python_command(meson_bin): + meson_command = [meson_bin, args[4]] command = args[5] arguments = args[6:] else: - meson_command = [meson_command] + meson_command = [meson_bin] command = args[4] arguments = args[5:] pc = run_command(src_dir, build_dir, subdir, meson_command, command, arguments) |