From 691eb0250a58fa8e63a2cf6b256043a5479c2722 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 22 Feb 2021 20:03:07 -0500 Subject: mcompile: make sure arguments are passed in the correct order meson compile itself doesn't permit GNU-style argument permutation, i.e. TARGET to precede options, so why should we expect ninja to? And indeed, ninja doesn't document support for this -- but it does accept it anyway, which is confusing and results in people thinking it's "supposed to" work. However, if NINJA=samu then this is in fact enforced. samu does not permit GNU-style argument permutation. As a result, the arguments passed to mcompile are actively re-ordered before being passed to the subprocess, and samu dies with a fatal error. Fix ordering in mcompile.py and add a comment to warn future readers that the order does, in fact, matter. --- mesonbuild/mcompile.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py index 16eb82a..b623dbe 100644 --- a/mesonbuild/mcompile.py +++ b/mesonbuild/mcompile.py @@ -144,13 +144,6 @@ def get_parsed_args_ninja(options: 'argparse.Namespace', builddir: Path) -> T.Tu cmd = runner + ['-C', builddir.as_posix()] - if options.targets: - intro_data = parse_introspect_data(builddir) - for t in options.targets: - cmd.extend(generate_target_names_ninja(ParsedTargetName(t), builddir, intro_data)) - if options.clean: - cmd.append('clean') - # If the value is set to < 1 then don't set anything, which let's # ninja/samu decide what to do. if options.jobs > 0: @@ -163,6 +156,14 @@ def get_parsed_args_ninja(options: 'argparse.Namespace', builddir: Path) -> T.Tu cmd += options.ninja_args + # operands must be processed after options/option-arguments + if options.targets: + intro_data = parse_introspect_data(builddir) + for t in options.targets: + cmd.extend(generate_target_names_ninja(ParsedTargetName(t), builddir, intro_data)) + if options.clean: + cmd.append('clean') + return cmd, None def generate_target_name_vs(target: ParsedTargetName, builddir: Path, introspect_data: dict) -> str: -- cgit v1.1