From 5806303a18e7578c203bdc30c2121d8f88e84534 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 6 Jun 2023 11:39:47 +0200 Subject: [PATCH 1/2] Tools/build/stable_abi.py: Improve ergonomics - Make the manifest file argument optional - Output resolved paths with --list (getting rid of `../../`) - Mention --all or --generate-all if no actions are specified --- Tools/build/stable_abi.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Tools/build/stable_abi.py b/Tools/build/stable_abi.py index 4cd1cd953d0d29..6bfc3dfa766861 100644 --- a/Tools/build/stable_abi.py +++ b/Tools/build/stable_abi.py @@ -25,6 +25,8 @@ import csv SCRIPT_NAME = 'Tools/build/stable_abi.py' +DEFAULT_MANIFEST_PATH = ( + Path(__file__).parent / '../../Misc/stable_abi.toml').resolve() MISSING = object() EXCLUDED_HEADERS = { @@ -631,8 +633,9 @@ def main(): formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument( - "file", type=Path, metavar='FILE', - help="file with the stable abi manifest", + "file", type=Path, metavar='FILE', nargs='?', + default=DEFAULT_MANIFEST_PATH, + help=f"file with the stable abi manifest (default: {DEFAULT_MANIFEST_PATH})", ) parser.add_argument( "--generate", action='store_true', @@ -674,7 +677,7 @@ def main(): if args.list: for gen in generators: - print(f'{gen.arg_name}: {base_path / gen.default_path}') + print(f'{gen.arg_name}: {(base_path / gen.default_path).resolve()}') sys.exit(0) run_all_generators = args.generate_all @@ -725,8 +728,10 @@ def main(): if not results: if args.generate: - parser.error('No file specified. Use --help for usage.') - parser.error('No check specified. Use --help for usage.') + parser.error('No file specified. Use --generate-all to regenerate ' + + 'all files, or --help for usage.') + parser.error('No check specified. Use --all to check all files, ' + + 'or --help for usage.') failed_results = [name for name, result in results.items() if not result] From 08262043ddd06df626aa1d6e8f6741d5bc9b2720 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 7 Jun 2023 14:14:24 +0200 Subject: [PATCH 2/2] Don't hardcode Misc/stable_abi.toml in Makefile, rely on the default --- Makefile.pre.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index a9c53bae4bf63c..6f52a6dc00dad1 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1309,7 +1309,7 @@ check-abidump: all .PHONY: regen-limited-abi regen-limited-abi: all - $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --generate-all $(srcdir)/Misc/stable_abi.toml + $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --generate-all ############################################################################ # Regenerate all generated files @@ -2736,7 +2736,7 @@ patchcheck: all .PHONY: check-limited-abi check-limited-abi: all - $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --all $(srcdir)/Misc/stable_abi.toml + $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --all .PHONY: update-config update-config: