Depend on stored sync session GUID for Android.
[chromium-blink-merge.git] / tools / include_tracer.py
blob5d908d1d1f79aeb37168913f13ffd07b24130bce
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/GTM',
29 'third_party/WebKit/Source',
30 'third_party/WebKit/Source/JavaScriptCore',
31 'third_party/WebKit/Source/JavaScriptCore/wtf',
32 'third_party/WebKit/Source/ThirdParty/glu',
33 'third_party/WebKit/Source/WebCore',
34 'third_party/WebKit/Source/WebCore/accessibility',
35 'third_party/WebKit/Source/WebCore/accessibility/chromium',
36 'third_party/WebKit/Source/WebCore/bindings',
37 'third_party/WebKit/Source/WebCore/bindings/generic',
38 'third_party/WebKit/Source/WebCore/bindings/v8',
39 'third_party/WebKit/Source/WebCore/bindings/v8/custom',
40 'third_party/WebKit/Source/WebCore/bindings/v8/specialization',
41 'third_party/WebKit/Source/WebCore/bridge',
42 'third_party/WebKit/Source/WebCore/bridge/jni',
43 'third_party/WebKit/Source/WebCore/bridge/jni/v8',
44 'third_party/WebKit/Source/WebCore/css',
45 'third_party/WebKit/Source/WebCore/dom',
46 'third_party/WebKit/Source/WebCore/dom/default',
47 'third_party/WebKit/Source/WebCore/editing',
48 'third_party/WebKit/Source/WebCore/fileapi',
49 'third_party/WebKit/Source/WebCore/history',
50 'third_party/WebKit/Source/WebCore/html',
51 'third_party/WebKit/Source/WebCore/html/canvas',
52 'third_party/WebKit/Source/WebCore/html/parser',
53 'third_party/WebKit/Source/WebCore/html/shadow',
54 'third_party/WebKit/Source/WebCore/inspector',
55 'third_party/WebKit/Source/WebCore/loader',
56 'third_party/WebKit/Source/WebCore/loader/appcache',
57 'third_party/WebKit/Source/WebCore/loader/archive',
58 'third_party/WebKit/Source/WebCore/loader/cache',
59 'third_party/WebKit/Source/WebCore/loader/icon',
60 'third_party/WebKit/Source/WebCore/mathml',
61 'third_party/WebKit/Source/WebCore/notifications',
62 'third_party/WebKit/Source/WebCore/page',
63 'third_party/WebKit/Source/WebCore/page/animation',
64 'third_party/WebKit/Source/WebCore/page/chromium',
65 'third_party/WebKit/Source/WebCore/platform',
66 'third_party/WebKit/Source/WebCore/platform/animation',
67 'third_party/WebKit/Source/WebCore/platform/audio',
68 'third_party/WebKit/Source/WebCore/platform/audio/chromium',
69 'third_party/WebKit/Source/WebCore/platform/audio/mac',
70 'third_party/WebKit/Source/WebCore/platform/chromium',
71 'third_party/WebKit/Source/WebCore/platform/cocoa',
72 'third_party/WebKit/Source/WebCore/platform/graphics',
73 'third_party/WebKit/Source/WebCore/platform/graphics/cg',
74 'third_party/WebKit/Source/WebCore/platform/graphics/chromium',
75 'third_party/WebKit/Source/WebCore/platform/graphics/cocoa',
76 'third_party/WebKit/Source/WebCore/platform/graphics/filters',
77 'third_party/WebKit/Source/WebCore/platform/graphics/gpu',
78 'third_party/WebKit/Source/WebCore/platform/graphics/mac',
79 'third_party/WebKit/Source/WebCore/platform/graphics/opentype',
80 'third_party/WebKit/Source/WebCore/platform/graphics/skia',
81 'third_party/WebKit/Source/WebCore/platform/graphics/transforms',
82 'third_party/WebKit/Source/WebCore/platform/image-decoders',
83 'third_party/WebKit/Source/WebCore/platform/image-decoders/bmp',
84 'third_party/WebKit/Source/WebCore/platform/image-decoders/gif',
85 'third_party/WebKit/Source/WebCore/platform/image-decoders/ico',
86 'third_party/WebKit/Source/WebCore/platform/image-decoders/jpeg',
87 'third_party/WebKit/Source/WebCore/platform/image-decoders/png',
88 'third_party/WebKit/Source/WebCore/platform/image-decoders/skia',
89 'third_party/WebKit/Source/WebCore/platform/image-decoders/webp',
90 'third_party/WebKit/Source/WebCore/platform/image-decoders/xbm',
91 'third_party/WebKit/Source/WebCore/platform/image-encoders/skia',
92 'third_party/WebKit/Source/WebCore/platform/mac',
93 'third_party/WebKit/Source/WebCore/platform/mock',
94 'third_party/WebKit/Source/WebCore/platform/network',
95 'third_party/WebKit/Source/WebCore/platform/network/chromium',
96 'third_party/WebKit/Source/WebCore/platform/sql',
97 'third_party/WebKit/Source/WebCore/platform/text',
98 'third_party/WebKit/Source/WebCore/platform/text/mac',
99 'third_party/WebKit/Source/WebCore/platform/text/transcoder',
100 'third_party/WebKit/Source/WebCore/plugins',
101 'third_party/WebKit/Source/WebCore/plugins/chromium',
102 'third_party/WebKit/Source/WebCore/rendering',
103 'third_party/WebKit/Source/WebCore/rendering/style',
104 'third_party/WebKit/Source/WebCore/rendering/svg',
105 'third_party/WebKit/Source/WebCore/storage',
106 'third_party/WebKit/Source/WebCore/storage/chromium',
107 'third_party/WebKit/Source/WebCore/svg',
108 'third_party/WebKit/Source/WebCore/svg/animation',
109 'third_party/WebKit/Source/WebCore/svg/graphics',
110 'third_party/WebKit/Source/WebCore/svg/graphics/filters',
111 'third_party/WebKit/Source/WebCore/svg/properties',
112 'third_party/WebKit/Source/WebCore/webaudio',
113 'third_party/WebKit/Source/WebCore/websockets',
114 'third_party/WebKit/Source/WebCore/workers',
115 'third_party/WebKit/Source/WebCore/xml',
116 'third_party/WebKit/Source/WebKit/chromium/public',
117 'third_party/WebKit/Source/WebKit/chromium/src',
118 'third_party/WebKit/Source/WebKit/mac/WebCoreSupport',
119 'third_party/WebKit/WebKitLibraries',
120 'third_party/cld',
121 'third_party/icu/public/common',
122 'third_party/icu/public/i18n',
123 'third_party/npapi',
124 'third_party/npapi/bindings',
125 'third_party/protobuf',
126 'third_party/protobuf/src',
127 'third_party/skia/gpu/include',
128 'third_party/skia/include/config',
129 'third_party/skia/include/core',
130 'third_party/skia/include/effects',
131 'third_party/skia/include/gpu',
132 'third_party/skia/include/pdf',
133 'third_party/skia/include/ports',
134 'v8/include',
135 'xcodebuild/Debug/include',
136 'xcodebuild/DerivedSources/Debug/chrome',
137 'xcodebuild/DerivedSources/Debug/policy',
138 'xcodebuild/DerivedSources/Debug/protoc_out',
139 'xcodebuild/DerivedSources/Debug/webkit',
140 'xcodebuild/DerivedSources/Debug/webkit/bindings',
144 def Walk(seen, filename, parent, indent):
145 """Returns the size of |filename| plus the size of all files included by
146 |filename| and prints the include tree of |filename| to stdout. Every file
147 is visited at most once.
149 total_bytes = 0
151 # .proto(devel) filename translation
152 if filename.endswith('.pb.h'):
153 basename = filename[:-5]
154 if os.path.exists(basename + '.proto'):
155 filename = basename + '.proto'
156 else:
157 print 'could not find ', filename
159 # Show and count files only once.
160 if filename in seen:
161 return total_bytes
162 seen.add(filename)
164 # Display the paths.
165 print ' ' * indent + filename
167 # Skip system includes.
168 if filename[0] == '<':
169 return total_bytes
171 # Find file in all include paths.
172 resolved_filename = filename
173 for root in INCLUDE_PATHS + [os.path.dirname(parent)]:
174 if os.path.exists(os.path.join(root, filename)):
175 resolved_filename = os.path.join(root, filename)
176 break
178 # Recurse.
179 if os.path.exists(resolved_filename):
180 lines = open(resolved_filename).readlines()
181 else:
182 print ' ' * (indent + 2) + "-- not found"
183 lines = []
184 for line in lines:
185 line = line.strip()
186 if line.startswith('#include "'):
187 total_bytes += Walk(
188 seen, line.split('"')[1], resolved_filename, indent + 2)
189 elif line.startswith('#include '):
190 include = '<' + line.split('<')[1].split('>')[0] + '>'
191 total_bytes += Walk(
192 seen, include, resolved_filename, indent + 2)
193 elif line.startswith('import '):
194 total_bytes += Walk(
195 seen, line.split('"')[1], resolved_filename, indent + 2)
196 return total_bytes + len("".join(lines))
199 def main():
200 bytes = Walk(set(), sys.argv[1], '', 0)
201 print
202 print float(bytes) / (1 << 20), "megabytes of chrome source"
205 if __name__ == '__main__':
206 sys.exit(main())