Skip to content

show_help: only parse specific trees for help files #13247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions opal/util/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ libopalutil_core_la_SOURCES = \
uri.c

show_help_content.c: convert-help-files-to-c-code.py
$(OMPI_V_GEN) $(PYTHON) $(abs_srcdir)/convert-help-files-to-c-code.py \
--root $(abs_top_srcdir) \
$(OMPI_V_GEN) subdirs=""; \
for dir in $(MCA_PROJECT_SUBDIRS); do \
subdirs="$(abs_top_srcdir)/$$dir $$subdirs"; \
done; \
$(PYTHON) $(abs_srcdir)/convert-help-files-to-c-code.py \
--roots $$subdirs \
--out show_help_content.c

if OPAL_COMPILE_TIMING
Expand Down
39 changes: 23 additions & 16 deletions opal/util/convert-help-files-to-c-code.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@
import sys
import argparse

def find_help_files(root, verbose=False):
def find_help_files(roots, skip_dirs, verbose=False):
# Search for help-*.txt files across the source tree, skipping
# some directories (e.g., 3rd-party)
help_files = []
skip_dirs = ['.git', '3rd-party']
for root_dir, dirs, files in os.walk(root):
for sd in skip_dirs:
if sd in dirs:
dirs.remove(sd)

for file in files:
if file.startswith("help-") and file.endswith(".txt"):
full_path = os.path.join(root_dir, file)
help_files.append(full_path)
if verbose:
print(f"Found: {full_path}")
for root in roots:
for root_dir, dirs, files in os.walk(root):
for sd in skip_dirs:
if sd in dirs:
print(f"Skipping additional dir: {root_dir}/{sd}")
dirs.remove(sd)

for file in files:
if file.startswith("help-") and file.endswith(".txt"):
full_path = os.path.join(root_dir, file)
help_files.append(full_path)
if verbose:
print(f"Found: {full_path}")

return help_files

def parse_ini_files(file_paths, verbose=False):
Expand Down Expand Up @@ -162,9 +164,14 @@ def generate_c_code(parsed_data):

def main():
parser = argparse.ArgumentParser(description="Generate C code from help text INI files.")
parser.add_argument("--root",
parser.add_argument("--roots",
nargs='+',
required=True,
help="Root directory to search for help-*.txt files")
help="Space-delimited list of directories to search for help-*.txt files")
parser.add_argument("--skip-dirs",
nargs='*',
default=['.git', '3rd-party'],
help="Space-delimited list of directories to skip traversing")
parser.add_argument("--out",
required=True,
help="Output C file")
Expand All @@ -176,7 +183,7 @@ def main():
if args.verbose:
print(f"Searching in: {args.root}")

file_paths = find_help_files(args.root, args.verbose)
file_paths = find_help_files(args.roots, args.skip_dirs, args.verbose)
parsed_data = parse_ini_files(file_paths, args.verbose)
c_code = generate_c_code(parsed_data)

Expand Down