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.
pull/8401/head
Eli Schwartz 4 years ago
parent 671647188c
commit 691eb0250a
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 15
      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:

Loading…
Cancel
Save