diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2022-04-03 17:16:08 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2022-05-01 23:56:38 +0300 |
commit | 17f5d0cffb9c40fec292244894b909ace4ea08ed (patch) | |
tree | f1b3ac63b720fd8b435d387e63ada56125b5615d /mesonbuild | |
parent | 1a80e5b35ed79ac67461d54346a9299df3b9c4c3 (diff) | |
download | meson-17f5d0cffb9c40fec292244894b909ace4ea08ed.zip meson-17f5d0cffb9c40fec292244894b909ace4ea08ed.tar.gz meson-17f5d0cffb9c40fec292244894b909ace4ea08ed.tar.bz2 |
mcompile: Print suggestions when target is ambigous
Fixes: #10221
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/mcompile.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py index fbdf92c..cea2f72 100644 --- a/mesonbuild/mcompile.py +++ b/mesonbuild/mcompile.py @@ -118,7 +118,14 @@ def get_target_from_intro_data(target: ParsedTargetName, builddir: Path, introsp if not found_targets: raise MesonException(f'Can\'t invoke target `{target.full_name}`: target not found') elif len(found_targets) > 1: - raise MesonException(f'Can\'t invoke target `{target.full_name}`: ambiguous name. Add target type and/or path: `PATH/NAME:TYPE`') + suggestions: T.List[str] = [] + for i in found_targets: + p = Path(i['filename'][0]).relative_to(resolved_bdir) + t = i['type'].replace(' ', '_') + suggestions.append(f'- ./{p}:{t}') + suggestions_str = '\n'.join(suggestions) + raise MesonException(f'Can\'t invoke target `{target.full_name}`: ambiguous name.' \ + f'Add target type and/or path:\n{suggestions_str}') return found_targets[0] |