Skip to content

Commit 4d09719

Browse files
authored
Tools/build/stable_abi.py: Improve ergonomics (GH-105355)
* 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 * Don't hardcode Misc/stable_abi.toml in Makefile, rely on the default
1 parent 28aea5d commit 4d09719

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Makefile.pre.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ check-abidump: all
16961696

16971697
.PHONY: regen-limited-abi
16981698
regen-limited-abi: all
1699-
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --generate-all $(srcdir)/Misc/stable_abi.toml
1699+
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --generate-all
17001700

17011701
############################################################################
17021702
# Regenerate Unicode Data
@@ -3142,7 +3142,7 @@ patchcheck: all
31423142

31433143
.PHONY: check-limited-abi
31443144
check-limited-abi: all
3145-
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --all $(srcdir)/Misc/stable_abi.toml
3145+
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --all
31463146

31473147
.PHONY: update-config
31483148
update-config:

Tools/build/stable_abi.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import csv
2626

2727
SCRIPT_NAME = 'Tools/build/stable_abi.py'
28+
DEFAULT_MANIFEST_PATH = (
29+
Path(__file__).parent / '../../Misc/stable_abi.toml').resolve()
2830
MISSING = object()
2931

3032
EXCLUDED_HEADERS = {
@@ -641,8 +643,9 @@ def main():
641643
formatter_class=argparse.RawDescriptionHelpFormatter,
642644
)
643645
parser.add_argument(
644-
"file", type=Path, metavar='FILE',
645-
help="file with the stable abi manifest",
646+
"file", type=Path, metavar='FILE', nargs='?',
647+
default=DEFAULT_MANIFEST_PATH,
648+
help=f"file with the stable abi manifest (default: {DEFAULT_MANIFEST_PATH})",
646649
)
647650
parser.add_argument(
648651
"--generate", action='store_true',
@@ -684,7 +687,7 @@ def main():
684687

685688
if args.list:
686689
for gen in generators:
687-
print(f'{gen.arg_name}: {base_path / gen.default_path}')
690+
print(f'{gen.arg_name}: {(base_path / gen.default_path).resolve()}')
688691
sys.exit(0)
689692

690693
run_all_generators = args.generate_all
@@ -735,8 +738,10 @@ def main():
735738

736739
if not results:
737740
if args.generate:
738-
parser.error('No file specified. Use --help for usage.')
739-
parser.error('No check specified. Use --help for usage.')
741+
parser.error('No file specified. Use --generate-all to regenerate '
742+
+ 'all files, or --help for usage.')
743+
parser.error('No check specified. Use --all to check all files, '
744+
+ 'or --help for usage.')
740745

741746
failed_results = [name for name, result in results.items() if not result]
742747

0 commit comments

Comments
 (0)