[flang][runtime] Make defined formatted I/O process format elementally (#74150)
[llvm-project.git] / libcxx / utils / graph_header_deps.py
blob6c4bd2a056d5fc8ab60784b14f39e264299c5757
1 #!/usr/bin/env python
2 # ===----------------------------------------------------------------------===##
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 # ===----------------------------------------------------------------------===##
10 import argparse
12 if __name__ == "__main__":
13 """Converts a header dependency CSV file to Graphviz dot file.
15 The header dependency CSV files are found on the directory
16 libcxx/test/libcxx/transitive_includes
17 """
19 parser = argparse.ArgumentParser(
20 description="""Converts a libc++ dependency CSV file to a Graphviz dot file.
21 For example:
22 libcxx/utils/graph_header_deps.py libcxx/test/libcxx/transitive_includes/cxx20.csv | dot -Tsvg > graph.svg
23 """,
24 formatter_class=argparse.RawDescriptionHelpFormatter,
26 parser.add_argument(
27 "input",
28 default=None,
29 metavar="FILE",
30 help="The header dependency CSV file.",
32 options = parser.parse_args()
34 print(
35 """digraph includes {
36 graph [nodesep=0.5, ranksep=1];
37 node [shape=box, width=4];"""
39 with open(options.input, "r") as f:
40 for line in f.readlines():
41 elements = line.rstrip().split(" ")
42 assert len(elements) == 2
44 print(f'\t"{elements[0]}" -> "{elements[1]}"')
46 print("}")