blob: e7089bf4db5db745e7094e78dc92991563cfcb1e [file] [log] [blame]
[email protected]cb155a82011-11-29 17:25:341#!/usr/bin/env python
[email protected]833b584ce2011-04-18 22:04:092# 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: [email protected] (Jyrki Alakuijala)
[email protected]cb155a82011-11-29 17:25:346
7"""Prints out include dependencies in chrome.
8
9Since it ignores defines, it gives just a rough estimation of file size.
10
11Usage:
12 tools/include_tracer.py chrome/browser/ui/browser.h
13"""
[email protected]833b584ce2011-04-18 22:04:0914
15import os
Kent Tamura654d87ef2018-06-05 05:31:5416import re
[email protected]833b584ce2011-04-18 22:04:0917import sys
18
19# Created by copying the command line for prerender_browsertest.cc, replacing
20# spaces with newlines, and dropping everything except -F and -I switches.
21# TODO(port): Add windows, linux directories.
22INCLUDE_PATHS = [
23 '',
24 'gpu',
25 'skia/config',
26 'skia/ext',
27 'testing/gmock/include',
28 'testing/gtest/include',
Blink Reformata30d4232018-04-07 15:31:0629 'third_party/blink/renderer',
30 'third_party/blink/renderer/core',
31 'third_party/blink/renderer/core/accessibility',
32 'third_party/blink/renderer/core/accessibility/chromium',
33 'third_party/blink/renderer/core/bindings',
34 'third_party/blink/renderer/core/bindings/generic',
35 'third_party/blink/renderer/core/bindings/v8',
36 'third_party/blink/renderer/core/bindings/v8/custom',
37 'third_party/blink/renderer/core/bindings/v8/specialization',
38 'third_party/blink/renderer/core/bridge',
39 'third_party/blink/renderer/core/bridge/jni',
40 'third_party/blink/renderer/core/bridge/jni/v8',
41 'third_party/blink/renderer/core/css',
42 'third_party/blink/renderer/core/dom',
43 'third_party/blink/renderer/core/dom/default',
44 'third_party/blink/renderer/core/editing',
45 'third_party/blink/renderer/core/fileapi',
46 'third_party/blink/renderer/core/history',
47 'third_party/blink/renderer/core/html',
48 'third_party/blink/renderer/core/html/canvas',
49 'third_party/blink/renderer/core/html/parser',
50 'third_party/blink/renderer/core/html/shadow',
51 'third_party/blink/renderer/core/inspector',
52 'third_party/blink/renderer/core/loader',
53 'third_party/blink/renderer/core/loader/appcache',
54 'third_party/blink/renderer/core/loader/archive',
55 'third_party/blink/renderer/core/loader/cache',
56 'third_party/blink/renderer/core/loader/icon',
57 'third_party/blink/renderer/core/mathml',
58 'third_party/blink/renderer/core/notifications',
59 'third_party/blink/renderer/core/page',
60 'third_party/blink/renderer/core/page/animation',
61 'third_party/blink/renderer/core/page/chromium',
62 'third_party/blink/renderer/core/platform',
63 'third_party/blink/renderer/core/platform/animation',
64 'third_party/blink/renderer/core/platform/audio',
65 'third_party/blink/renderer/core/platform/audio/chromium',
66 'third_party/blink/renderer/core/platform/audio/mac',
67 'third_party/blink/renderer/core/platform/chromium',
68 'third_party/blink/renderer/core/platform/cocoa',
69 'third_party/blink/renderer/core/platform/graphics',
70 'third_party/blink/renderer/core/platform/graphics/cg',
71 'third_party/blink/renderer/core/platform/graphics/chromium',
72 'third_party/blink/renderer/core/platform/graphics/cocoa',
73 'third_party/blink/renderer/core/platform/graphics/filters',
74 'third_party/blink/renderer/core/platform/graphics/gpu',
75 'third_party/blink/renderer/core/platform/graphics/mac',
76 'third_party/blink/renderer/core/platform/graphics/opentype',
77 'third_party/blink/renderer/core/platform/graphics/skia',
78 'third_party/blink/renderer/core/platform/graphics/transforms',
79 'third_party/blink/renderer/core/platform/image-decoders',
80 'third_party/blink/renderer/core/platform/image-decoders/bmp',
81 'third_party/blink/renderer/core/platform/image-decoders/gif',
82 'third_party/blink/renderer/core/platform/image-decoders/ico',
83 'third_party/blink/renderer/core/platform/image-decoders/jpeg',
84 'third_party/blink/renderer/core/platform/image-decoders/png',
85 'third_party/blink/renderer/core/platform/image-decoders/skia',
86 'third_party/blink/renderer/core/platform/image-decoders/webp',
87 'third_party/blink/renderer/core/platform/image-decoders/xbm',
88 'third_party/blink/renderer/core/platform/image-encoders/skia',
89 'third_party/blink/renderer/core/platform/mac',
90 'third_party/blink/renderer/core/platform/mock',
91 'third_party/blink/renderer/core/platform/network',
92 'third_party/blink/renderer/core/platform/network/chromium',
93 'third_party/blink/renderer/core/platform/sql',
94 'third_party/blink/renderer/core/platform/text',
95 'third_party/blink/renderer/core/platform/text/mac',
96 'third_party/blink/renderer/core/platform/text/transcoder',
97 'third_party/blink/renderer/core/plugins',
98 'third_party/blink/renderer/core/plugins/chromium',
99 'third_party/blink/renderer/core/rendering',
100 'third_party/blink/renderer/core/rendering/style',
101 'third_party/blink/renderer/core/rendering/svg',
102 'third_party/blink/renderer/core/storage',
103 'third_party/blink/renderer/core/storage/chromium',
104 'third_party/blink/renderer/core/svg',
105 'third_party/blink/renderer/core/svg/animation',
106 'third_party/blink/renderer/core/svg/graphics',
107 'third_party/blink/renderer/core/svg/graphics/filters',
108 'third_party/blink/renderer/core/svg/properties',
109 'third_party/blink/renderer/core/webaudio',
110 'third_party/blink/renderer/core/websockets',
111 'third_party/blink/renderer/core/workers',
112 'third_party/blink/renderer/core/xml',
113 'third_party/blink/renderer/public',
114 'third_party/blink/renderer/web',
115 'third_party/blink/renderer/wtf',
[email protected]a023dca2013-12-18 03:58:36116 'third_party/google_toolbox_for_mac/src',
[email protected]833b584ce2011-04-18 22:04:09117 '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',
137]
138
139
140def 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.
144 """
145 total_bytes = 0
146
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
154
155 # Show and count files only once.
156 if filename in seen:
157 return total_bytes
158 seen.add(filename)
159
160 # Display the paths.
161 print ' ' * indent + filename
162
163 # Skip system includes.
164 if filename[0] == '<':
165 return total_bytes
166
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
173
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()
Kent Tamura654d87ef2018-06-05 05:31:54182 match = re.match(r'#include\s+(\S+).*', line)
183 if match:
184 include = match.group(1)
185 if include.startswith('"'):
186 include = include[1:-1]
187 total_bytes += Walk(seen, include, resolved_filename, indent + 2)
[email protected]833b584ce2011-04-18 22:04:09188 elif line.startswith('import '):
189 total_bytes += Walk(
190 seen, line.split('"')[1], resolved_filename, indent + 2)
191 return total_bytes + len("".join(lines))
192
193
[email protected]cb155a82011-11-29 17:25:34194def main():
195 bytes = Walk(set(), sys.argv[1], '', 0)
196 print
197 print float(bytes) / (1 << 20), "megabytes of chrome source"
198
199
200if __name__ == '__main__':
201 sys.exit(main())