diff --git a/docs/markdown/Commands.md b/docs/markdown/Commands.md index b7b72c495..52eb76c1d 100644 --- a/docs/markdown/Commands.md +++ b/docs/markdown/Commands.md @@ -61,7 +61,7 @@ Builds a default or a specified target of a configured Meson project. `TARGET` has the following syntax `[PATH/]NAME[:TYPE]`, where: - `NAME`: name of the target from `meson.build` (e.g. `foo` from `executable('foo', ...)`). - `PATH`: path to the target relative to the root `meson.build` file. Note: relative path for a target specified in the root `meson.build` is `./`. -- `TYPE`: type of the target. Can be one of the following: 'executable', 'static_library', 'shared_library', 'shared_module', 'custom', 'run', 'jar'. +- `TYPE`: type of the target. Can be one of the following: 'executable', 'static_library', 'shared_library', 'shared_module', 'custom', 'alias', 'run', 'jar'. `PATH` and/or `TYPE` can be omitted if the resulting `TARGET` can be used to uniquely identify the target in `meson.build`. diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py index ce002bd9b..817978407 100644 --- a/mesonbuild/mcompile.py +++ b/mesonbuild/mcompile.py @@ -89,6 +89,7 @@ class ParsedTargetName: 'shared_library', 'shared_module', 'custom', + 'alias', 'run', 'jar', } @@ -130,7 +131,7 @@ def get_target_from_intro_data(target: ParsedTargetName, builddir: Path, introsp def generate_target_names_ninja(target: ParsedTargetName, builddir: Path, introspect_data: dict) -> T.List[str]: intro_target = get_target_from_intro_data(target, builddir, introspect_data) - if intro_target['type'] == 'run': + if intro_target['type'] in {'alias', 'run'}: return [target.name] else: return [str(Path(out_file).relative_to(builddir.resolve())) for out_file in intro_target['filename']] @@ -169,7 +170,7 @@ def get_parsed_args_ninja(options: 'argparse.Namespace', builddir: Path) -> T.Tu def generate_target_name_vs(target: ParsedTargetName, builddir: Path, introspect_data: dict) -> str: intro_target = get_target_from_intro_data(target, builddir, introspect_data) - assert intro_target['type'] != 'run', 'Should not reach here: `run` targets must be handle above' + assert intro_target['type'] not in {'alias', 'run'}, 'Should not reach here: `run` targets must be handle above' # Normalize project name # Source: https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-build-specific-targets-in-solutions-by-using-msbuild-exe @@ -189,7 +190,7 @@ def get_parsed_args_vs(options: 'argparse.Namespace', builddir: Path) -> T.Tuple if options.targets: intro_data = parse_introspect_data(builddir) has_run_target = any( - get_target_from_intro_data(ParsedTargetName(t), builddir, intro_data)['type'] == 'run' + get_target_from_intro_data(ParsedTargetName(t), builddir, intro_data)['type'] in {'alias', 'run'} for t in options.targets) if has_run_target: