OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 | 5 |
6 """A tool to extract size information for chrome, executed by buildbot. | 6 """A tool to extract size information for chrome, executed by buildbot. |
7 | 7 |
8 When this is run, the current directory (cwd) should be the outer build | 8 When this is run, the current directory (cwd) should be the outer build |
9 directory (e.g., chrome-release/build/). | 9 directory (e.g., chrome-release/build/). |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 RESULT %(app_bundle)s: %(app_bundle)s= %(app_bundle_size)s bytes | 118 RESULT %(app_bundle)s: %(app_bundle)s= %(app_bundle_size)s bytes |
119 RESULT chrome-si: initializers= %(initializers)d files | 119 RESULT chrome-si: initializers= %(initializers)d files |
120 """) % ( | 120 """) % ( |
121 print_dict) | 121 print_dict) |
122 # Found a match, don't check the other base_names. | 122 # Found a match, don't check the other base_names. |
123 return result | 123 return result |
124 # If no base_names matched, fail script. | 124 # If no base_names matched, fail script. |
125 return 66 | 125 return 66 |
126 | 126 |
127 | 127 |
128 def check_linux_binary(target_dir, binary_name): | 128 def check_linux_binary(target_dir, binary_name, options): |
129 """Collect appropriate size information about the built Linux binary given. | 129 """Collect appropriate size information about the built Linux binary given. |
130 | 130 |
131 Returns a tuple (result, sizes). result is the first non-zero exit | 131 Returns a tuple (result, sizes). result is the first non-zero exit |
132 status of any command it executes, or zero on success. sizes is a list | 132 status of any command it executes, or zero on success. sizes is a list |
133 of tuples (name, identifier, totals_identifier, value, units). | 133 of tuples (name, identifier, totals_identifier, value, units). |
134 The printed line looks like: | 134 The printed line looks like: |
135 name: identifier= value units | 135 name: identifier= value units |
136 When this same data is used for totals across all the binaries, then | 136 When this same data is used for totals across all the binaries, then |
137 totals_identifier is the identifier to use, or '' to just use identifier. | 137 totals_identifier is the identifier to use, or '' to just use identifier. |
138 """ | 138 """ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 count = 0 | 182 count = 0 |
183 else: | 183 else: |
184 size_line = re.search('.ctors.*$', stdout, re.MULTILINE).group(0) | 184 size_line = re.search('.ctors.*$', stdout, re.MULTILINE).group(0) |
185 size = re.split('\W+', size_line)[5] | 185 size = re.split('\W+', size_line)[5] |
186 size = int(size, 16) | 186 size = int(size, 16) |
187 # The first entry is always 0 and the last is -1 as guards. | 187 # The first entry is always 0 and the last is -1 as guards. |
188 # So subtract 2 from the count. | 188 # So subtract 2 from the count. |
189 count = (size / word_size) - 2 | 189 count = (size / word_size) - 2 |
190 sizes.append((binary_name + '-si', 'initializers', '', count, 'files')) | 190 sizes.append((binary_name + '-si', 'initializers', '', count, 'files')) |
191 | 191 |
| 192 # For Release builds only, use dump-static-initializers.py to print the list |
| 193 # of static initializers. |
| 194 if count and options.target == 'Release': |
| 195 dump_static_initializers = os.path.join(options.build_dir, |
| 196 'tools', 'linux', |
| 197 'dump-static-initializers.py') |
| 198 result, stdout = run_process(result, [dump_static_initializers, |
| 199 '-d', binary_file]) |
| 200 print '\n# Static initializers in %s:' % binary_file |
| 201 print stdout |
| 202 |
192 # Determine if the binary has the DT_TEXTREL marker. | 203 # Determine if the binary has the DT_TEXTREL marker. |
193 result, stdout = run_process(result, ['readelf', '-Wd', binary_file]) | 204 result, stdout = run_process(result, ['readelf', '-Wd', binary_file]) |
194 if re.search(r'\bTEXTREL\b', stdout) is None: | 205 if re.search(r'\bTEXTREL\b', stdout) is None: |
195 # Nope, so the count is zero. | 206 # Nope, so the count is zero. |
196 count = 0 | 207 count = 0 |
197 else: | 208 else: |
198 # There are some, so count them. | 209 # There are some, so count them. |
199 result, stdout = run_process(result, ['eu-findtextrel', binary_file]) | 210 result, stdout = run_process(result, ['eu-findtextrel', binary_file]) |
200 count = stdout.count('\n') | 211 count = stdout.count('\n') |
201 sizes.append((binary_name + '-textrel', 'textrel', '', count, 'relocs')) | 212 sizes.append((binary_name + '-textrel', 'textrel', '', count, 'relocs')) |
(...skipping 18 matching lines...) Expand all Loading... |
220 'libgcflashplayer.so', | 231 'libgcflashplayer.so', |
221 'libpdf.so', | 232 'libpdf.so', |
222 'libppGoogleNaClPluginChrome.so', | 233 'libppGoogleNaClPluginChrome.so', |
223 ] | 234 ] |
224 | 235 |
225 result = 0 | 236 result = 0 |
226 | 237 |
227 totals = {} | 238 totals = {} |
228 | 239 |
229 for binary in binaries: | 240 for binary in binaries: |
230 this_result, this_sizes = check_linux_binary(target_dir, binary) | 241 this_result, this_sizes = check_linux_binary(target_dir, binary, options) |
231 if result == 0: | 242 if result == 0: |
232 result = this_result | 243 result = this_result |
233 for name, identifier, totals_id, value, units in this_sizes: | 244 for name, identifier, totals_id, value, units in this_sizes: |
234 print 'RESULT %s: %s= %s %s' % (name, identifier, value, units) | 245 print 'RESULT %s: %s= %s %s' % (name, identifier, value, units) |
235 totals_id = totals_id or identifier, units | 246 totals_id = totals_id or identifier, units |
236 totals[totals_id] = totals.get(totals_id, 0) + int(value) | 247 totals[totals_id] = totals.get(totals_id, 0) + int(value) |
237 | 248 |
238 files = [ | 249 files = [ |
239 'chrome.pak', | 250 'chrome.pak', |
240 'nacl_irt_x86_64.nexe', | 251 'nacl_irt_x86_64.nexe', |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 else: | 339 else: |
329 sys.stderr.write('Unknown platform %s.\n' % repr(options.platform)) | 340 sys.stderr.write('Unknown platform %s.\n' % repr(options.platform)) |
330 msg = 'Use the --platform= option to specify a supported platform:\n' | 341 msg = 'Use the --platform= option to specify a supported platform:\n' |
331 sys.stderr.write(msg + ' ' + ' '.join(platforms) + '\n') | 342 sys.stderr.write(msg + ' ' + ' '.join(platforms) + '\n') |
332 return 2 | 343 return 2 |
333 return real_main(options, args) | 344 return real_main(options, args) |
334 | 345 |
335 | 346 |
336 if '__main__' == __name__: | 347 if '__main__' == __name__: |
337 sys.exit(main()) | 348 sys.exit(main()) |
OLD | NEW |