Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 # Copyright 2011 Google Inc. | |
|
Evan Martin
2011/04/18 21:05:55
I think you need to fix this to the official licen
Nico
2011/04/18 21:20:23
Done.
| |
| 3 # All Rights Reserved. | |
| 4 # author: thakis@chromium.org (Nico Weber) | |
| 5 # based on an almost identical script by: jyrki@google.com (Jyrki Alakuijala) | |
| 6 # | |
| 7 # This script prints out include dependencies in chrome. Since it ignores | |
| 8 # defines, it gives just a rough estimation of file size. | |
| 9 # | |
| 10 # Usage: | |
| 11 # python tools/include_tracer.py chrome/browser/ui/browser.h | |
| 12 | |
| 13 import os | |
| 14 import sys | |
| 15 | |
| 16 # Created by copying the command line for prerender_browsertest.cc, replacing | |
| 17 # spaces with newlines, and dropping everything except -F and -I switches. | |
| 18 # TODO(port): Add windows, linux directories. | |
| 19 | |
| 20 INCLUDE_PATHS = [ | |
| 21 '', | |
| 22 'gpu', | |
| 23 'skia/config', | |
| 24 'skia/ext', | |
| 25 'testing/gmock/include', | |
| 26 'testing/gtest/include', | |
| 27 'third_party/GTM', | |
| 28 'third_party/WebKit/Source', | |
| 29 'third_party/WebKit/Source/JavaScriptCore', | |
| 30 'third_party/WebKit/Source/JavaScriptCore/wtf', | |
| 31 'third_party/WebKit/Source/ThirdParty/glu', | |
| 32 'third_party/WebKit/Source/WebCore', | |
| 33 'third_party/WebKit/Source/WebCore/accessibility', | |
| 34 'third_party/WebKit/Source/WebCore/accessibility/chromium', | |
| 35 'third_party/WebKit/Source/WebCore/bindings', | |
| 36 'third_party/WebKit/Source/WebCore/bindings/generic', | |
| 37 'third_party/WebKit/Source/WebCore/bindings/v8', | |
| 38 'third_party/WebKit/Source/WebCore/bindings/v8/custom', | |
| 39 'third_party/WebKit/Source/WebCore/bindings/v8/specialization', | |
| 40 'third_party/WebKit/Source/WebCore/bridge', | |
| 41 'third_party/WebKit/Source/WebCore/bridge/jni', | |
| 42 'third_party/WebKit/Source/WebCore/bridge/jni/v8', | |
| 43 'third_party/WebKit/Source/WebCore/css', | |
| 44 'third_party/WebKit/Source/WebCore/dom', | |
| 45 'third_party/WebKit/Source/WebCore/dom/default', | |
| 46 'third_party/WebKit/Source/WebCore/editing', | |
| 47 'third_party/WebKit/Source/WebCore/fileapi', | |
| 48 'third_party/WebKit/Source/WebCore/history', | |
| 49 'third_party/WebKit/Source/WebCore/html', | |
| 50 'third_party/WebKit/Source/WebCore/html/canvas', | |
| 51 'third_party/WebKit/Source/WebCore/html/parser', | |
| 52 'third_party/WebKit/Source/WebCore/html/shadow', | |
| 53 'third_party/WebKit/Source/WebCore/inspector', | |
| 54 'third_party/WebKit/Source/WebCore/loader', | |
| 55 'third_party/WebKit/Source/WebCore/loader/appcache', | |
| 56 'third_party/WebKit/Source/WebCore/loader/archive', | |
| 57 'third_party/WebKit/Source/WebCore/loader/cache', | |
| 58 'third_party/WebKit/Source/WebCore/loader/icon', | |
| 59 'third_party/WebKit/Source/WebCore/mathml', | |
| 60 'third_party/WebKit/Source/WebCore/notifications', | |
| 61 'third_party/WebKit/Source/WebCore/page', | |
| 62 'third_party/WebKit/Source/WebCore/page/animation', | |
| 63 'third_party/WebKit/Source/WebCore/page/chromium', | |
| 64 'third_party/WebKit/Source/WebCore/platform', | |
| 65 'third_party/WebKit/Source/WebCore/platform/animation', | |
| 66 'third_party/WebKit/Source/WebCore/platform/audio', | |
| 67 'third_party/WebKit/Source/WebCore/platform/audio/chromium', | |
| 68 'third_party/WebKit/Source/WebCore/platform/audio/mac', | |
| 69 'third_party/WebKit/Source/WebCore/platform/chromium', | |
| 70 'third_party/WebKit/Source/WebCore/platform/cocoa', | |
| 71 'third_party/WebKit/Source/WebCore/platform/graphics', | |
| 72 'third_party/WebKit/Source/WebCore/platform/graphics/cg', | |
| 73 'third_party/WebKit/Source/WebCore/platform/graphics/chromium', | |
| 74 'third_party/WebKit/Source/WebCore/platform/graphics/cocoa', | |
| 75 'third_party/WebKit/Source/WebCore/platform/graphics/filters', | |
| 76 'third_party/WebKit/Source/WebCore/platform/graphics/gpu', | |
| 77 'third_party/WebKit/Source/WebCore/platform/graphics/mac', | |
| 78 'third_party/WebKit/Source/WebCore/platform/graphics/opentype', | |
| 79 'third_party/WebKit/Source/WebCore/platform/graphics/skia', | |
| 80 'third_party/WebKit/Source/WebCore/platform/graphics/transforms', | |
| 81 'third_party/WebKit/Source/WebCore/platform/image-decoders', | |
| 82 'third_party/WebKit/Source/WebCore/platform/image-decoders/bmp', | |
| 83 'third_party/WebKit/Source/WebCore/platform/image-decoders/gif', | |
| 84 'third_party/WebKit/Source/WebCore/platform/image-decoders/ico', | |
| 85 'third_party/WebKit/Source/WebCore/platform/image-decoders/jpeg', | |
| 86 'third_party/WebKit/Source/WebCore/platform/image-decoders/png', | |
| 87 'third_party/WebKit/Source/WebCore/platform/image-decoders/skia', | |
| 88 'third_party/WebKit/Source/WebCore/platform/image-decoders/webp', | |
| 89 'third_party/WebKit/Source/WebCore/platform/image-decoders/xbm', | |
| 90 'third_party/WebKit/Source/WebCore/platform/image-encoders/skia', | |
| 91 'third_party/WebKit/Source/WebCore/platform/mac', | |
| 92 'third_party/WebKit/Source/WebCore/platform/mock', | |
| 93 'third_party/WebKit/Source/WebCore/platform/network', | |
| 94 'third_party/WebKit/Source/WebCore/platform/network/chromium', | |
| 95 'third_party/WebKit/Source/WebCore/platform/sql', | |
| 96 'third_party/WebKit/Source/WebCore/platform/text', | |
| 97 'third_party/WebKit/Source/WebCore/platform/text/mac', | |
| 98 'third_party/WebKit/Source/WebCore/platform/text/transcoder', | |
| 99 'third_party/WebKit/Source/WebCore/plugins', | |
| 100 'third_party/WebKit/Source/WebCore/plugins/chromium', | |
| 101 'third_party/WebKit/Source/WebCore/rendering', | |
| 102 'third_party/WebKit/Source/WebCore/rendering/style', | |
| 103 'third_party/WebKit/Source/WebCore/rendering/svg', | |
| 104 'third_party/WebKit/Source/WebCore/storage', | |
| 105 'third_party/WebKit/Source/WebCore/storage/chromium', | |
| 106 'third_party/WebKit/Source/WebCore/svg', | |
| 107 'third_party/WebKit/Source/WebCore/svg/animation', | |
| 108 'third_party/WebKit/Source/WebCore/svg/graphics', | |
| 109 'third_party/WebKit/Source/WebCore/svg/graphics/filters', | |
| 110 'third_party/WebKit/Source/WebCore/svg/properties', | |
| 111 'third_party/WebKit/Source/WebCore/webaudio', | |
| 112 'third_party/WebKit/Source/WebCore/websockets', | |
| 113 'third_party/WebKit/Source/WebCore/workers', | |
| 114 'third_party/WebKit/Source/WebCore/xml', | |
| 115 'third_party/WebKit/Source/WebKit/chromium/public', | |
| 116 'third_party/WebKit/Source/WebKit/chromium/src', | |
| 117 'third_party/WebKit/Source/WebKit/mac/WebCoreSupport', | |
| 118 'third_party/WebKit/WebKitLibraries', | |
| 119 'third_party/cld', | |
| 120 'third_party/icu/public/common', | |
| 121 'third_party/icu/public/i18n', | |
| 122 'third_party/npapi', | |
| 123 'third_party/npapi/bindings', | |
| 124 'third_party/protobuf', | |
| 125 'third_party/protobuf/src', | |
| 126 'third_party/skia/gpu/include', | |
| 127 'third_party/skia/include/config', | |
| 128 'third_party/skia/include/core', | |
| 129 'third_party/skia/include/effects', | |
| 130 'third_party/skia/include/gpu', | |
| 131 'third_party/skia/include/pdf', | |
| 132 'third_party/skia/include/ports', | |
| 133 'v8/include', | |
| 134 'xcodebuild/Debug/include', | |
| 135 'xcodebuild/DerivedSources/Debug/chrome', | |
| 136 'xcodebuild/DerivedSources/Debug/policy', | |
| 137 'xcodebuild/DerivedSources/Debug/protoc_out', | |
| 138 'xcodebuild/DerivedSources/Debug/webkit', | |
| 139 'xcodebuild/DerivedSources/Debug/webkit/bindings', | |
| 140 ] | |
| 141 | |
| 142 def Exists(p): | |
| 143 return os.path.exists(p) | |
| 144 | |
| 145 def Walk(seen, filename, parent, indent): | |
|
Evan Martin
2011/04/18 21:05:55
docstrings?
Nico
2011/04/18 21:20:23
Done.
| |
| 146 total_bytes = 0 | |
| 147 # .proto(devel) filename translation | |
| 148 if filename.endswith('.pb.h'): | |
| 149 basename = filename[:-5] | |
| 150 if Exists(basename + '.proto'): | |
| 151 filename = basename + '.proto' | |
| 152 else: | |
| 153 print 'could not find ', filename | |
| 154 # show and count only once | |
| 155 if filename in seen: | |
| 156 return total_bytes | |
| 157 seen.add(filename) | |
| 158 # display the paths | |
| 159 print ' ' * indent + filename | |
| 160 # skip these | |
| 161 if filename == 'base/stl_decl.h' or filename[0] == '<': | |
| 162 return total_bytes | |
| 163 # recursion | |
| 164 resolved_filename = filename | |
| 165 for root in INCLUDE_PATHS + [os.path.dirname(parent)]: | |
| 166 if Exists(os.path.join(root, filename)): | |
| 167 resolved_filename = os.path.join(root, filename) | |
| 168 break | |
| 169 if Exists(resolved_filename): | |
| 170 lines = open(resolved_filename).readlines() | |
| 171 else: | |
| 172 print ' ' * (indent + 2) + "-- not found" | |
| 173 lines = [] | |
| 174 for line in lines: | |
| 175 line = line.strip() | |
| 176 if line.startswith('#include "'): | |
| 177 total_bytes += Walk( | |
| 178 seen, line.split('"')[1], resolved_filename, indent + 2) | |
| 179 elif line.startswith('#include '): | |
| 180 include = '<' + line.split('<')[1].split('>')[0] + '>' | |
| 181 total_bytes += Walk( | |
| 182 seen, include, resolved_filename, indent + 2) | |
| 183 elif line.startswith('import '): | |
| 184 total_bytes += Walk( | |
| 185 seen, line.split('"')[1], resolved_filename, indent + 2) | |
| 186 return total_bytes + len("".join(lines)) | |
|
Evan Martin
2011/04/18 21:05:55
Can you add some whitespace to this function? It
Nico
2011/04/18 21:20:23
Done.
| |
| 187 | |
| 188 bytes = Walk(set(), sys.argv[1], '', 0) | |
| 189 print | |
| 190 print float(bytes) / (1 << 20), "megabytes of chrome source" | |
| OLD | NEW |