adjust browser_tests drmemory exclusion list to find suitable tests
[chromium-blink-merge.git] / tools / include_tracer.py
blob567a79765f813920e254b725aaecb8843c531d2a
1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 # based on an almost identical script by: jyrki@google.com (Jyrki Alakuijala)
7 """Prints out include dependencies in chrome.
9 Since it ignores defines, it gives just a rough estimation of file size.
11 Usage:
12 tools/include_tracer.py chrome/browser/ui/browser.h
13 """
15 import os
16 import sys
18 # Created by copying the command line for prerender_browsertest.cc, replacing
19 # spaces with newlines, and dropping everything except -F and -I switches.
20 # TODO(port): Add windows, linux directories.
21 INCLUDE_PATHS = [
22 '',
23 'gpu',
24 'skia/config',
25 'skia/ext',
26 'testing/gmock/include',
27 'testing/gtest/include',
28 'third_party/WebKit/Source',
29 'third_party/WebKit/Source/core',
30 'third_party/WebKit/Source/core/accessibility',
31 'third_party/WebKit/Source/core/accessibility/chromium',
32 'third_party/WebKit/Source/core/bindings',
33 'third_party/WebKit/Source/core/bindings/generic',
34 'third_party/WebKit/Source/core/bindings/v8',
35 'third_party/WebKit/Source/core/bindings/v8/custom',
36 'third_party/WebKit/Source/core/bindings/v8/specialization',
37 'third_party/WebKit/Source/core/bridge',
38 'third_party/WebKit/Source/core/bridge/jni',
39 'third_party/WebKit/Source/core/bridge/jni/v8',
40 'third_party/WebKit/Source/core/css',
41 'third_party/WebKit/Source/core/dom',
42 'third_party/WebKit/Source/core/dom/default',
43 'third_party/WebKit/Source/core/editing',
44 'third_party/WebKit/Source/core/fileapi',
45 'third_party/WebKit/Source/core/history',
46 'third_party/WebKit/Source/core/html',
47 'third_party/WebKit/Source/core/html/canvas',
48 'third_party/WebKit/Source/core/html/parser',
49 'third_party/WebKit/Source/core/html/shadow',
50 'third_party/WebKit/Source/core/inspector',
51 'third_party/WebKit/Source/core/loader',
52 'third_party/WebKit/Source/core/loader/appcache',
53 'third_party/WebKit/Source/core/loader/archive',
54 'third_party/WebKit/Source/core/loader/cache',
55 'third_party/WebKit/Source/core/loader/icon',
56 'third_party/WebKit/Source/core/mathml',
57 'third_party/WebKit/Source/core/notifications',
58 'third_party/WebKit/Source/core/page',
59 'third_party/WebKit/Source/core/page/animation',
60 'third_party/WebKit/Source/core/page/chromium',
61 'third_party/WebKit/Source/core/platform',
62 'third_party/WebKit/Source/core/platform/animation',
63 'third_party/WebKit/Source/core/platform/audio',
64 'third_party/WebKit/Source/core/platform/audio/chromium',
65 'third_party/WebKit/Source/core/platform/audio/mac',
66 'third_party/WebKit/Source/core/platform/chromium',
67 'third_party/WebKit/Source/core/platform/cocoa',
68 'third_party/WebKit/Source/core/platform/graphics',
69 'third_party/WebKit/Source/core/platform/graphics/cg',
70 'third_party/WebKit/Source/core/platform/graphics/chromium',
71 'third_party/WebKit/Source/core/platform/graphics/cocoa',
72 'third_party/WebKit/Source/core/platform/graphics/filters',
73 'third_party/WebKit/Source/core/platform/graphics/gpu',
74 'third_party/WebKit/Source/core/platform/graphics/mac',
75 'third_party/WebKit/Source/core/platform/graphics/opentype',
76 'third_party/WebKit/Source/core/platform/graphics/skia',
77 'third_party/WebKit/Source/core/platform/graphics/transforms',
78 'third_party/WebKit/Source/core/platform/image-decoders',
79 'third_party/WebKit/Source/core/platform/image-decoders/bmp',
80 'third_party/WebKit/Source/core/platform/image-decoders/gif',
81 'third_party/WebKit/Source/core/platform/image-decoders/ico',
82 'third_party/WebKit/Source/core/platform/image-decoders/jpeg',
83 'third_party/WebKit/Source/core/platform/image-decoders/png',
84 'third_party/WebKit/Source/core/platform/image-decoders/skia',
85 'third_party/WebKit/Source/core/platform/image-decoders/webp',
86 'third_party/WebKit/Source/core/platform/image-decoders/xbm',
87 'third_party/WebKit/Source/core/platform/image-encoders/skia',
88 'third_party/WebKit/Source/core/platform/mac',
89 'third_party/WebKit/Source/core/platform/mock',
90 'third_party/WebKit/Source/core/platform/network',
91 'third_party/WebKit/Source/core/platform/network/chromium',
92 'third_party/WebKit/Source/core/platform/sql',
93 'third_party/WebKit/Source/core/platform/text',
94 'third_party/WebKit/Source/core/platform/text/mac',
95 'third_party/WebKit/Source/core/platform/text/transcoder',
96 'third_party/WebKit/Source/core/plugins',
97 'third_party/WebKit/Source/core/plugins/chromium',
98 'third_party/WebKit/Source/core/rendering',
99 'third_party/WebKit/Source/core/rendering/style',
100 'third_party/WebKit/Source/core/rendering/svg',
101 'third_party/WebKit/Source/core/storage',
102 'third_party/WebKit/Source/core/storage/chromium',
103 'third_party/WebKit/Source/core/svg',
104 'third_party/WebKit/Source/core/svg/animation',
105 'third_party/WebKit/Source/core/svg/graphics',
106 'third_party/WebKit/Source/core/svg/graphics/filters',
107 'third_party/WebKit/Source/core/svg/properties',
108 'third_party/WebKit/Source/core/webaudio',
109 'third_party/WebKit/Source/core/websockets',
110 'third_party/WebKit/Source/core/workers',
111 'third_party/WebKit/Source/core/xml',
112 'third_party/WebKit/Source/public',
113 'third_party/WebKit/Source/web',
114 'third_party/WebKit/Source/wtf',
115 'third_party/cld',
116 'third_party/google_toolbox_for_mac/src',
117 'third_party/icu/public/common',
118 'third_party/icu/public/i18n',
119 'third_party/npapi',
120 'third_party/npapi/bindings',
121 'third_party/protobuf',
122 'third_party/protobuf/src',
123 'third_party/skia/gpu/include',
124 'third_party/skia/include/config',
125 'third_party/skia/include/core',
126 'third_party/skia/include/effects',
127 'third_party/skia/include/gpu',
128 'third_party/skia/include/pdf',
129 'third_party/skia/include/ports',
130 'v8/include',
131 'xcodebuild/Debug/include',
132 'xcodebuild/DerivedSources/Debug/chrome',
133 'xcodebuild/DerivedSources/Debug/policy',
134 'xcodebuild/DerivedSources/Debug/protoc_out',
135 'xcodebuild/DerivedSources/Debug/webkit',
136 'xcodebuild/DerivedSources/Debug/webkit/bindings',
140 def Walk(seen, filename, parent, indent):
141 """Returns the size of |filename| plus the size of all files included by
142 |filename| and prints the include tree of |filename| to stdout. Every file
143 is visited at most once.
145 total_bytes = 0
147 # .proto(devel) filename translation
148 if filename.endswith('.pb.h'):
149 basename = filename[:-5]
150 if os.path.exists(basename + '.proto'):
151 filename = basename + '.proto'
152 else:
153 print 'could not find ', filename
155 # Show and count files only once.
156 if filename in seen:
157 return total_bytes
158 seen.add(filename)
160 # Display the paths.
161 print ' ' * indent + filename
163 # Skip system includes.
164 if filename[0] == '<':
165 return total_bytes
167 # Find file in all include paths.
168 resolved_filename = filename
169 for root in INCLUDE_PATHS + [os.path.dirname(parent)]:
170 if os.path.exists(os.path.join(root, filename)):
171 resolved_filename = os.path.join(root, filename)
172 break
174 # Recurse.
175 if os.path.exists(resolved_filename):
176 lines = open(resolved_filename).readlines()
177 else:
178 print ' ' * (indent + 2) + "-- not found"
179 lines = []
180 for line in lines:
181 line = line.strip()
182 if line.startswith('#include "'):
183 total_bytes += Walk(
184 seen, line.split('"')[1], resolved_filename, indent + 2)
185 elif line.startswith('#include '):
186 include = '<' + line.split('<')[1].split('>')[0] + '>'
187 total_bytes += Walk(
188 seen, include, resolved_filename, indent + 2)
189 elif line.startswith('import '):
190 total_bytes += Walk(
191 seen, line.split('"')[1], resolved_filename, indent + 2)
192 return total_bytes + len("".join(lines))
195 def main():
196 bytes = Walk(set(), sys.argv[1], '', 0)
197 print
198 print float(bytes) / (1 << 20), "megabytes of chrome source"
201 if __name__ == '__main__':
202 sys.exit(main())