diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py index 16eb82a83..b623dbe95 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: