Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: tools/binary_size/libsupersize/archive.py

Issue 2817813003: supersize: Add "diff" command (Closed)
Patch Set: review commetns Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/binary_size/README.md ('k') | tools/binary_size/libsupersize/console.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Main Python API for analyzing binary size.""" 5 """Main Python API for analyzing binary size."""
6 6
7 import argparse 7 import argparse
8 import calendar 8 import calendar
9 import collections 9 import collections
10 import datetime 10 import datetime
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 def Run(args, parser): 452 def Run(args, parser):
453 if not args.size_file.endswith('.size'): 453 if not args.size_file.endswith('.size'):
454 parser.error('size_file must end with .size') 454 parser.error('size_file must end with .size')
455 455
456 elf_path = args.elf_file 456 elf_path = args.elf_file
457 map_path = args.map_file 457 map_path = args.map_file
458 apk_path = args.apk_file 458 apk_path = args.apk_file
459 any_input = apk_path or elf_path or map_path 459 any_input = apk_path or elf_path or map_path
460 if not any_input: 460 if not any_input:
461 parser.error('Most pass at least one of --apk-file, --elf-file, --map-file') 461 parser.error('Most pass at least one of --apk-file, --elf-file, --map-file')
462 lazy_paths = paths.LazyPaths(args=args, input_file=any_input) 462 lazy_paths = paths.LazyPaths(tool_prefix=args.tool_prefix,
463 463 output_directory=args.output_directory,
464 any_path_within_output_directory=any_input)
464 if apk_path: 465 if apk_path:
465 with zipfile.ZipFile(apk_path) as z: 466 with zipfile.ZipFile(apk_path) as z:
466 lib_infos = [f for f in z.infolist() 467 lib_infos = [f for f in z.infolist()
467 if f.filename.endswith('.so') and f.file_size > 0] 468 if f.filename.endswith('.so') and f.file_size > 0]
468 assert lib_infos, 'APK has no .so files.' 469 assert lib_infos, 'APK has no .so files.'
469 # TODO(agrieve): Add support for multiple .so files, and take into account 470 # TODO(agrieve): Add support for multiple .so files, and take into account
470 # secondary architectures. 471 # secondary architectures.
471 apk_so_path = max(lib_infos, key=lambda x:x.file_size).filename 472 apk_so_path = max(lib_infos, key=lambda x:x.file_size).filename
472 logging.debug('Sub-apk path=%s', apk_so_path) 473 logging.debug('Sub-apk path=%s', apk_so_path)
473 if not elf_path: 474 if not elf_path:
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 logging.warning('Packed section not present: %s', packed_section_name) 550 logging.warning('Packed section not present: %s', packed_section_name)
550 else: 551 else:
551 size_info.section_sizes['%s (unpacked)' % packed_section_name] = ( 552 size_info.section_sizes['%s (unpacked)' % packed_section_name] = (
552 unstripped_section_sizes.get(packed_section_name)) 553 unstripped_section_sizes.get(packed_section_name))
553 554
554 logging.info('Recording metadata: \n %s', 555 logging.info('Recording metadata: \n %s',
555 '\n '.join(describe.DescribeMetadata(size_info.metadata))) 556 '\n '.join(describe.DescribeMetadata(size_info.metadata)))
556 logging.info('Saving result to %s', args.size_file) 557 logging.info('Saving result to %s', args.size_file)
557 file_format.SaveSizeInfo(size_info, args.size_file) 558 file_format.SaveSizeInfo(size_info, args.size_file)
558 logging.info('Done') 559 logging.info('Done')
OLDNEW
« no previous file with comments | « tools/binary_size/README.md ('k') | tools/binary_size/libsupersize/console.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698