OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 # based on an almost identical script by: jyrki@google.com (Jyrki Alakuijala) | 5 # based on an almost identical script by: jyrki@google.com (Jyrki Alakuijala) |
6 # | 6 |
7 # This script prints out include dependencies in chrome. Since it ignores | 7 """Prints out include dependencies in chrome. |
8 # defines, it gives just a rough estimation of file size. | 8 |
9 # | 9 Since it ignores defines, it gives just a rough estimation of file size. |
10 # Usage: | 10 |
11 # python tools/include_tracer.py chrome/browser/ui/browser.h | 11 Usage: |
| 12 tools/include_tracer.py chrome/browser/ui/browser.h |
| 13 """ |
12 | 14 |
13 import os | 15 import os |
14 import sys | 16 import sys |
15 | 17 |
16 # Created by copying the command line for prerender_browsertest.cc, replacing | 18 # Created by copying the command line for prerender_browsertest.cc, replacing |
17 # spaces with newlines, and dropping everything except -F and -I switches. | 19 # spaces with newlines, and dropping everything except -F and -I switches. |
18 # TODO(port): Add windows, linux directories. | 20 # TODO(port): Add windows, linux directories. |
19 INCLUDE_PATHS = [ | 21 INCLUDE_PATHS = [ |
20 '', | 22 '', |
21 'gpu', | 23 'gpu', |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 elif line.startswith('#include '): | 189 elif line.startswith('#include '): |
188 include = '<' + line.split('<')[1].split('>')[0] + '>' | 190 include = '<' + line.split('<')[1].split('>')[0] + '>' |
189 total_bytes += Walk( | 191 total_bytes += Walk( |
190 seen, include, resolved_filename, indent + 2) | 192 seen, include, resolved_filename, indent + 2) |
191 elif line.startswith('import '): | 193 elif line.startswith('import '): |
192 total_bytes += Walk( | 194 total_bytes += Walk( |
193 seen, line.split('"')[1], resolved_filename, indent + 2) | 195 seen, line.split('"')[1], resolved_filename, indent + 2) |
194 return total_bytes + len("".join(lines)) | 196 return total_bytes + len("".join(lines)) |
195 | 197 |
196 | 198 |
197 bytes = Walk(set(), sys.argv[1], '', 0) | 199 def main(): |
198 print | 200 bytes = Walk(set(), sys.argv[1], '', 0) |
199 print float(bytes) / (1 << 20), "megabytes of chrome source" | 201 print |
| 202 print float(bytes) / (1 << 20), "megabytes of chrome source" |
| 203 |
| 204 |
| 205 if __name__ == '__main__': |
| 206 sys.exit(main()) |
OLD | NEW |