Skip to content

Commit 7590e93

Browse files
committed
Merge bitcoin/bitcoin#30986: contrib: skip missing binaries in gen-manpages
ee61853 gen-manpages: Prompt error if no binaries are found (Andre) 299e222 gen-manpages: implement --skip-missing-binaries (Andre Alves) Pull request description: 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. A new argument, `--skip-missing-binaries`, has been added to enable this behavior. ```sh ➜ bitcoin git:(fix-gen-manpages) ✗ ./contrib/devtools/gen-manpages.py --help usage: gen-manpages.py [-h] [-s] options: -h, --help show this help message and exit -s, --skip-missing-binaries skip generation for binaries that are not found ``` closes #30985 This PR also includes an error prompt if no binaries are found in the build path. ACKs for top commit: achow101: ACK ee61853 laanwj: re-ACK ee61853 Tree-SHA512: af4a0a5e26e508a51ab63f8aa9f98a6d6af9d7682a16791d8a6a61d49e44cb0147453f628ad5910f65d4efa6e3c7b6605c007259c23230b54888845bfaeb050c
2 parents b2af068 + ee61853 commit 7590e93

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

contrib/devtools/gen-manpages.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import subprocess
77
import sys
88
import tempfile
9+
import argparse
910

1011
BINARIES = [
1112
'src/bitcoind',
@@ -16,6 +17,18 @@
1617
'src/qt/bitcoin-qt',
1718
]
1819

20+
parser = argparse.ArgumentParser(
21+
formatter_class=argparse.RawDescriptionHelpFormatter,
22+
)
23+
parser.add_argument(
24+
"-s",
25+
"--skip-missing-binaries",
26+
action="store_true",
27+
default=False,
28+
help="skip generation for binaries that are not found in the build path",
29+
)
30+
args = parser.parse_args()
31+
1932
# Paths to external utilities.
2033
git = os.getenv('GIT', 'git')
2134
help2man = os.getenv('HELP2MAN', 'help2man')
@@ -38,8 +51,12 @@
3851
try:
3952
r = subprocess.run([abspath, "--version"], stdout=subprocess.PIPE, check=True, text=True)
4053
except IOError:
41-
print(f'{abspath} not found or not an executable', file=sys.stderr)
42-
sys.exit(1)
54+
if(args.skip_missing_binaries):
55+
print(f'{abspath} not found or not an executable. Skipping...', file=sys.stderr)
56+
continue
57+
else:
58+
print(f'{abspath} not found or not an executable', file=sys.stderr)
59+
sys.exit(1)
4360
# take first line (which must contain version)
4461
verstr = r.stdout.splitlines()[0]
4562
# last word of line is the actual version e.g. v22.99.0-5c6b3d5b3508
@@ -51,6 +68,10 @@
5168

5269
versions.append((abspath, verstr, copyright))
5370

71+
if not versions:
72+
print(f'No binaries found in {builddir}. Please ensure the binaries are present in {builddir}, or set another build path using the BUILDDIR env variable.')
73+
sys.exit(1)
74+
5475
if any(verstr.endswith('-dirty') for (_, verstr, _) in versions):
5576
print("WARNING: Binaries were built from a dirty tree.")
5677
print('man pages generated from dirty binaries should NOT be committed.')

0 commit comments

Comments
 (0)