[libc++] graph_header_deps.py: Update the computing of "root" (public) headers.

The "root nodes" of the graph are displayed in bold. My intent here
was to bold just the public-API headers, e.g. <vector> and
<experimental/coroutine> and <stdlib.h>, but not helper headers
such as <__functional_base> and <__iterator/next.h>. However,
the recent mass helper-header-ification has exposed defects in
this logic: all the new helpers were ending up bolded! Fix this.
Also, add <__undef_macros> to the list of headers we don't display
by default (like <__config>); it's not interesting to see those edges.

Also, add a sample `dot` command line to the `--help` text.
This commit is contained in:
Arthur O'Dwyer 2021-06-05 12:47:30 -04:00
parent 469d18c064
commit 11e0882e8d
1 changed files with 8 additions and 4 deletions

View File

@ -14,7 +14,7 @@ import sys
def is_config_header(h): def is_config_header(h):
return os.path.basename(h) in ['__config', '__libcpp_version'] return os.path.basename(h) in ['__config', '__libcpp_version', '__undef_macros']
def is_experimental_header(h): def is_experimental_header(h):
@ -37,7 +37,7 @@ def list_all_roots_under(root):
result = [] result = []
for root, _, files in os.walk(root): for root, _, files in os.walk(root):
for fname in files: for fname in files:
if '__support' in root: if os.path.basename(root).startswith('__') or fname.startswith('__'):
pass pass
elif ('.' in fname and not fname.endswith('.h')): elif ('.' in fname and not fname.endswith('.h')):
pass pass
@ -155,11 +155,15 @@ def get_graphviz(graph, options):
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Produce a dependency graph of libc++ headers, in GraphViz dot format.') parser = argparse.ArgumentParser(
description='Produce a dependency graph of libc++ headers, in GraphViz dot format.\n' +
'For example, ./graph_header_deps.py | dot -Tpng > graph.png',
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument('--root', default=None, metavar='FILE', help='File or directory to be the root of the dependency graph') parser.add_argument('--root', default=None, metavar='FILE', help='File or directory to be the root of the dependency graph')
parser.add_argument('-I', dest='search_dirs', default=[], action='append', metavar='DIR', help='Path(s) to search for local includes') parser.add_argument('-I', dest='search_dirs', default=[], action='append', metavar='DIR', help='Path(s) to search for local includes')
parser.add_argument('--show-transitive-edges', action='store_true', help='Show edges to headers that are transitively included anyway') parser.add_argument('--show-transitive-edges', action='store_true', help='Show edges to headers that are transitively included anyway')
parser.add_argument('--show-config-headers', action='store_true', help='Show headers named __config') parser.add_argument('--show-config-headers', action='store_true', help='Show universally included headers, such as __config')
parser.add_argument('--show-experimental-headers', action='store_true', help='Show headers in the experimental/ and ext/ directories') parser.add_argument('--show-experimental-headers', action='store_true', help='Show headers in the experimental/ and ext/ directories')
parser.add_argument('--show-support-headers', action='store_true', help='Show headers in the __support/ directory') parser.add_argument('--show-support-headers', action='store_true', help='Show headers in the __support/ directory')
parser.add_argument('--show-individual-line-counts', action='store_true', help='Include an individual line count in each node') parser.add_argument('--show-individual-line-counts', action='store_true', help='Include an individual line count in each node')