Skip to content

Commit 9b06b34

Browse files
authored
Merge pull request #13247 from jsquyres/pr/limit-show-help-generation-scanning
show_help: only parse specific trees for help files
2 parents b12149a + 114cd4d commit 9b06b34

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

opal/util/Makefile.am

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ libopalutil_core_la_SOURCES = \
128128
uri.c
129129

130130
show_help_content.c: convert-help-files-to-c-code.py
131-
$(OMPI_V_GEN) $(PYTHON) $(abs_srcdir)/convert-help-files-to-c-code.py \
132-
--root $(abs_top_srcdir) \
131+
$(OMPI_V_GEN) subdirs=""; \
132+
for dir in $(MCA_PROJECT_SUBDIRS); do \
133+
subdirs="$(abs_top_srcdir)/$$dir $$subdirs"; \
134+
done; \
135+
$(PYTHON) $(abs_srcdir)/convert-help-files-to-c-code.py \
136+
--roots $$subdirs \
133137
--out show_help_content.c
134138

135139
if OPAL_COMPILE_TIMING

opal/util/convert-help-files-to-c-code.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,24 @@
1212
import sys
1313
import argparse
1414

15-
def find_help_files(root, verbose=False):
15+
def find_help_files(roots, skip_dirs, verbose=False):
1616
# Search for help-*.txt files across the source tree, skipping
1717
# some directories (e.g., 3rd-party)
1818
help_files = []
19-
skip_dirs = ['.git', '3rd-party']
20-
for root_dir, dirs, files in os.walk(root):
21-
for sd in skip_dirs:
22-
if sd in dirs:
23-
dirs.remove(sd)
24-
25-
for file in files:
26-
if file.startswith("help-") and file.endswith(".txt"):
27-
full_path = os.path.join(root_dir, file)
28-
help_files.append(full_path)
29-
if verbose:
30-
print(f"Found: {full_path}")
19+
for root in roots:
20+
for root_dir, dirs, files in os.walk(root):
21+
for sd in skip_dirs:
22+
if sd in dirs:
23+
print(f"Skipping additional dir: {root_dir}/{sd}")
24+
dirs.remove(sd)
25+
26+
for file in files:
27+
if file.startswith("help-") and file.endswith(".txt"):
28+
full_path = os.path.join(root_dir, file)
29+
help_files.append(full_path)
30+
if verbose:
31+
print(f"Found: {full_path}")
32+
3133
return help_files
3234

3335
def parse_ini_files(file_paths, verbose=False):
@@ -162,9 +164,14 @@ def generate_c_code(parsed_data):
162164

163165
def main():
164166
parser = argparse.ArgumentParser(description="Generate C code from help text INI files.")
165-
parser.add_argument("--root",
167+
parser.add_argument("--roots",
168+
nargs='+',
166169
required=True,
167-
help="Root directory to search for help-*.txt files")
170+
help="Space-delimited list of directories to search for help-*.txt files")
171+
parser.add_argument("--skip-dirs",
172+
nargs='*',
173+
default=['.git', '3rd-party'],
174+
help="Space-delimited list of directories to skip traversing")
168175
parser.add_argument("--out",
169176
required=True,
170177
help="Output C file")
@@ -176,7 +183,7 @@ def main():
176183
if args.verbose:
177184
print(f"Searching in: {args.root}")
178185

179-
file_paths = find_help_files(args.root, args.verbose)
186+
file_paths = find_help_files(args.roots, args.skip_dirs, args.verbose)
180187
parsed_data = parse_ini_files(file_paths, args.verbose)
181188
c_code = generate_c_code(parsed_data)
182189

0 commit comments

Comments
 (0)