OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """Compare the artifacts from two builds.""" | 6 """Compare the artifacts from two builds.""" |
7 | 7 |
8 import difflib | 8 import difflib |
9 import json | 9 import json |
10 import optparse | 10 import optparse |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 with open(first_filepath, 'rb') as lhs: | 445 with open(first_filepath, 'rb') as lhs: |
446 with open(second_filepath, 'rb') as rhs: | 446 with open(second_filepath, 'rb') as rhs: |
447 # Skip part of Win32 COFF header if timestamps are different. | 447 # Skip part of Win32 COFF header if timestamps are different. |
448 # | 448 # |
449 # COFF header: | 449 # COFF header: |
450 # 0 - 1: magic. | 450 # 0 - 1: magic. |
451 # 2 - 3: # sections. | 451 # 2 - 3: # sections. |
452 # 4 - 7: timestamp. | 452 # 4 - 7: timestamp. |
453 # .... | 453 # .... |
454 COFF_HEADER_TO_COMPARE_SIZE = 8 | 454 COFF_HEADER_TO_COMPARE_SIZE = 8 |
455 if (sys.platform == 'win32' and first_filepath.endswith('.obj') | 455 if (sys.platform == 'win32' |
456 and os.path.splitext(first_filepath)[1] in ('.obj', '.o') | |
M-A Ruel
2016/09/13 14:20:22
I would prefer '.o', '.obj' so they are in order.
Yoshisato Yanagisawa
2016/09/14 01:04:36
Done.
| |
456 and file_len > COFF_HEADER_TO_COMPARE_SIZE): | 457 and file_len > COFF_HEADER_TO_COMPARE_SIZE): |
457 rhs_data = rhs.read(COFF_HEADER_TO_COMPARE_SIZE) | 458 rhs_data = rhs.read(COFF_HEADER_TO_COMPARE_SIZE) |
458 lhs_data = lhs.read(COFF_HEADER_TO_COMPARE_SIZE) | 459 lhs_data = lhs.read(COFF_HEADER_TO_COMPARE_SIZE) |
459 if lhs_data[0:4] == rhs_data[0:4] and lhs_data[4:8] != rhs_data[4:8]: | 460 if lhs_data[0:4] == rhs_data[0:4] and lhs_data[4:8] != rhs_data[4:8]: |
460 offset += COFF_HEADER_TO_COMPARE_SIZE | 461 offset += COFF_HEADER_TO_COMPARE_SIZE |
461 else: | 462 else: |
462 lhs.seek(0) | 463 lhs.seek(0) |
463 rhs.seek(0) | 464 rhs.seek(0) |
464 | 465 |
465 while True: | 466 while True: |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 parser.error('--target-platform is required') | 676 parser.error('--target-platform is required') |
676 | 677 |
677 return compare_build_artifacts(os.path.abspath(options.first_build_dir), | 678 return compare_build_artifacts(os.path.abspath(options.first_build_dir), |
678 os.path.abspath(options.second_build_dir), | 679 os.path.abspath(options.second_build_dir), |
679 options.target_platform, | 680 options.target_platform, |
680 options.recursive) | 681 options.recursive) |
681 | 682 |
682 | 683 |
683 if __name__ == '__main__': | 684 if __name__ == '__main__': |
684 sys.exit(main()) | 685 sys.exit(main()) |
OLD | NEW |