aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/commandrunner.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/scripts/commandrunner.py')
-rw-r--r--mesonbuild/scripts/commandrunner.py24
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]