From 299e2220e9546e7dca1ba5e56bdcfbbf97530fba Mon Sep 17 00:00:00 2001 From: Andre Alves Date: Thu, 14 Nov 2024 01:15:00 -0300 Subject: [PATCH] gen-manpages: implement --skip-missing-binaries With --skip-missing-binaries, instead of stopping the execution of gen-manpages.py when a binary is not found, continue generating manpages for the available binaries and skip the missing ones. --- contrib/devtools/gen-manpages.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/contrib/devtools/gen-manpages.py b/contrib/devtools/gen-manpages.py index 92acd9a4037..5675e6b11f7 100755 --- a/contrib/devtools/gen-manpages.py +++ b/contrib/devtools/gen-manpages.py @@ -6,6 +6,7 @@ import os import subprocess import sys import tempfile +import argparse BINARIES = [ 'src/bitcoind', @@ -16,6 +17,18 @@ BINARIES = [ 'src/qt/bitcoin-qt', ] +parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, +) +parser.add_argument( + "-s", + "--skip-missing-binaries", + action="store_true", + default=False, + help="skip generation for binaries that are not found in the build path", +) +args = parser.parse_args() + # Paths to external utilities. git = os.getenv('GIT', 'git') help2man = os.getenv('HELP2MAN', 'help2man') @@ -38,8 +51,12 @@ for relpath in BINARIES: try: r = subprocess.run([abspath, "--version"], stdout=subprocess.PIPE, check=True, text=True) except IOError: - print(f'{abspath} not found or not an executable', file=sys.stderr) - sys.exit(1) + if(args.skip_missing_binaries): + print(f'{abspath} not found or not an executable. Skipping...', file=sys.stderr) + continue + else: + print(f'{abspath} not found or not an executable', file=sys.stderr) + sys.exit(1) # take first line (which must contain version) verstr = r.stdout.splitlines()[0] # last word of line is the actual version e.g. v22.99.0-5c6b3d5b3508