diff options
author | Martin Kelly <mkelly@xevo.com> | 2018-04-24 16:55:12 -0700 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-05-30 18:29:16 +0000 |
commit | ab599b5733539130db5c4d17c664744f4d5aacaf (patch) | |
tree | 594bd5206a03c2e800b12e3af09a2e8cfa975841 /mesonbuild/scripts | |
parent | 0f86df4d232ef335705e75f0e1303af0e7c3a45c (diff) | |
download | meson-ab599b5733539130db5c4d17c664744f4d5aacaf.zip meson-ab599b5733539130db5c4d17c664744f4d5aacaf.tar.gz meson-ab599b5733539130db5c4d17c664744f4d5aacaf.tar.bz2 |
commandrunner: make run handle python options
Currently, commandrunner breaks when we give options to python because
it assumes python commands are in the form "python script.py", rather
than "python -u script.py" or "python -u -m module script.py". Extend it
to be more resilient and correctly parse python options.
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r-- | mesonbuild/scripts/commandrunner.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/mesonbuild/scripts/commandrunner.py b/mesonbuild/scripts/commandrunner.py index fc65e5b..5922c64 100644 --- a/mesonbuild/scripts/commandrunner.py +++ b/mesonbuild/scripts/commandrunner.py @@ -59,9 +59,27 @@ def run(args): subdir = args[2] meson_command = args[3] if 'python' in meson_command: # Hack. - meson_command = [meson_command, args[4]] - command = args[5] - arguments = args[6:] + # Handle any of these: + # python meson.py ... + # python -m mesonbuild.mesonmain ... + # python ARGS -m mesonbuild.mesonmain ... + # python -m mesonbuild.mesonmain ARGS ... + i = 4 + while i < len(args): + arg = args[i] + # Skip past optional arguments. + if arg[0] == '-': + if arg == '-m': + # Skip past -m PYTHONFILE. + i += 2 + else: + i += 1 + else: + break + end = i + meson_command = args[3:end] + command = args[end] + arguments = args[end + 1:] else: meson_command = [meson_command] command = args[4] |