7 from headerutils import *
17 # list of headers to emphasize
21 # search path for headers
22 incl_dirs = ["../include", "../libcpp/include", "common", "c-family", "c", "cp", "config" ]
23 # extra search paths to look in *after* the directory the source file is in.
25 # append (1) to the end of the first line which includes INC in list INC.
26 def append_1 (output, inc):
27 for n,t in enumerate (output):
31 t = t[:eos] + " (1)" + t[eos+1:]
35 # These headers show up as duplicates in rtl.h due to conditional code arund the includes
36 rtl_core = [ "machmode.h" , "signop.h" , "wide-int.h" , "double-int.h" , "real.h" , "fixed-value.h" , "statistics.h" , "vec.h" , "hash-table.h" , "hash-set.h" , "input.h" , "is-a.h" ]
38 def find_include_data (inc):
42 if os.path.exists (nm):
43 info = find_unique_include_list (nm)
44 # rtl.h mimics coretypes for GENERATOR FILES, remove if coretypes.h seen.
45 if inc == "coretypes.h":
47 elif inc == "rtl.h" and sawcore:
54 def process_include (inc, indent):
57 bname = os.path.basename (inc)
58 if bname in highlight:
60 if bname not in summary:
61 summary.append (bname)
64 if seen.get(inc) == None:
66 output.append (padding[:indent*tabstop] + bname + arrow)
67 info = find_include_data (inc)
69 process_include (y, indent+1)
74 output.append (padding[:indent*tabstop] + bname + " ("+str(seen[inc])+")" + arrow)
82 for x in sys.argv[1:]:
87 highlight.append (os.path.basename (x[2:]))
95 elif not os.path.exists (src[0]):
96 print src[0] + ": Requested source file does not exist.\n"
100 print "show-headers [-idir] [-sfilen] file1 "
102 print " Show a hierarchical visual format how many times each header file"
103 print " is included in a source file. Should be run from the source directory"
104 print " files from find-include-depends"
105 print " -s : search for a header, and point it out."
106 print " -i : Specifies additonal directories to search for includes."
112 incl_dirs = extradir + incl_dirs;
114 blddir = find_gcc_bld_dir ("../..")
117 print "Using build directory: " + blddir
118 incl_dirs.insert (0, blddir)
120 print "Could not find a build directory, better results if you specify one with -i"
122 # search path is now ".", blddir, extradirs_from_-i, built_in_incl_dirs
123 incl_dirs.insert (0, ".")
125 # if source is in a subdirectory, prepend the subdirectory to the search list
127 srcpath = os.path.dirname(x)
129 incl_dirs.insert (0, srcpath)
134 data = open (x).read().splitlines()
136 d = find_pound_include (line, True, True)
137 if d and d[-2:] == ".h":
138 process_include (d, 1)
147 print h + " is included by source file."
150 print h + " is not included by source file."