| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/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 | 5 |
| 6 """Prints the size of each given file and optionally computes the size of | 6 """Prints the size of each given file and optionally computes the size of |
| 7 libchrome.so without the dependencies added for building with android NDK. | 7 libchrome.so without the dependencies added for building with android NDK. |
| 8 Also breaks down the contents of the APK to determine the installed size | 8 Also breaks down the contents of the APK to determine the installed size |
| 9 and assign size contributions to different classes of file. | 9 and assign size contributions to different classes of file. |
| 10 """ | 10 """ |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 # Matches [ 2] .hash HASH 00000000006681f0 0001f0 003154 04 A 3 0 8 | 153 # Matches [ 2] .hash HASH 00000000006681f0 0001f0 003154 04 A 3 0 8 |
| 154 for match in re.finditer(r'\[[\s\d]+\] (\..*)$', stdout, re.MULTILINE): | 154 for match in re.finditer(r'\[[\s\d]+\] (\..*)$', stdout, re.MULTILINE): |
| 155 items = match.group(1).split() | 155 items = match.group(1).split() |
| 156 section_sizes[items[0]] = int(items[4], 16) | 156 section_sizes[items[0]] = int(items[4], 16) |
| 157 | 157 |
| 158 return section_sizes | 158 return section_sizes |
| 159 | 159 |
| 160 | 160 |
| 161 def _ParseLibBuildId(so_path, tools_prefix): | 161 def _ParseLibBuildId(so_path, tools_prefix): |
| 162 """Returns the Build ID of the given native library.""" | 162 """Returns the Build ID of the given native library.""" |
| 163 stdout = _RunReadelf(so_path, ['n'], tools_prefix) | 163 stdout = _RunReadelf(so_path, ['-n'], tools_prefix) |
| 164 match = re.search(r'Build ID: (\w+)', stdout) | 164 match = re.search(r'Build ID: (\w+)', stdout) |
| 165 return match.group(1) if match else None | 165 return match.group(1) if match else None |
| 166 | 166 |
| 167 | 167 |
| 168 def CountStaticInitializers(so_path, tools_prefix): | 168 def CountStaticInitializers(so_path, tools_prefix): |
| 169 # Static initializers expected in official builds. Note that this list is | 169 # Static initializers expected in official builds. Note that this list is |
| 170 # built using 'nm' on libchrome.so which results from a GCC official build | 170 # built using 'nm' on libchrome.so which results from a GCC official build |
| 171 # (i.e. Clang is not supported currently). | 171 # (i.e. Clang is not supported currently). |
| 172 def get_elf_section_size(readelf_stdout, section_name): | 172 def get_elf_section_size(readelf_stdout, section_name): |
| 173 # Matches: .ctors PROGBITS 000000000516add0 5169dd0 000010 00 WA 0 0 8 | 173 # Matches: .ctors PROGBITS 000000000516add0 5169dd0 000010 00 WA 0 0 8 |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 args.apk, tools_prefix, chartjson=chartjson) | 780 args.apk, tools_prefix, chartjson=chartjson) |
| 781 if chartjson: | 781 if chartjson: |
| 782 results_path = os.path.join(args.output_dir, 'results-chart.json') | 782 results_path = os.path.join(args.output_dir, 'results-chart.json') |
| 783 logging.critical('Dumping json to %s', results_path) | 783 logging.critical('Dumping json to %s', results_path) |
| 784 with open(results_path, 'w') as json_file: | 784 with open(results_path, 'w') as json_file: |
| 785 json.dump(chartjson, json_file) | 785 json.dump(chartjson, json_file) |
| 786 | 786 |
| 787 | 787 |
| 788 if __name__ == '__main__': | 788 if __name__ == '__main__': |
| 789 sys.exit(main()) | 789 sys.exit(main()) |
| OLD | NEW |