From: Wolfgang Bangerth Date: Tue, 4 Feb 2025 13:07:02 +0000 (-0700) Subject: Detect header cycles regardless of how we spell the #include. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c76e06f427f1faaf3f79905b1833d7c602798b3;p=dealii.git Detect header cycles regardless of how we spell the #include. --- diff --git a/contrib/utilities/detect_include_cycles.py b/contrib/utilities/detect_include_cycles.py index 81838f2c0a..e1a2670bda 100644 --- a/contrib/utilities/detect_include_cycles.py +++ b/contrib/utilities/detect_include_cycles.py @@ -27,21 +27,24 @@ from glob import glob import networkx as nx +import re + +match_includes = re.compile(r"# *include *<(deal.II/.*.h)>") # For a given header file, read through all the lines and extract the -# ones that correspond to #include statements. For those, add a link -# from header file to the one it includes to the graph. +# ones that correspond to #include statements for deal.II header +# files. For those, add a link from header file to the one it includes +# to the graph. def add_includes_for_file(header_file_name, G) : f = open(header_file_name) lines = f.readlines() f.close() for line in lines : - if "#include" in line : - line = line.strip() - line = line.replace("#include <", "") - included_file = line.replace(">", "") + m = match_includes.match(line) + if m : + included_file = m.group(1) G.add_edge(header_file_name.replace("include/", ""), included_file)