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 |
11 import os | 11 import os |
12 import struct | 12 import struct |
13 import sys | 13 import sys |
14 import time | 14 import time |
15 | 15 |
16 | 16 |
17 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 17 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
18 | 18 |
19 | 19 |
20 def get_files_to_compare(build_dir, recursive=False): | 20 def get_files_to_compare(build_dir, recursive=False): |
21 """Get the list of files to compare.""" | 21 """Get the list of files to compare.""" |
22 allowed = frozenset( | 22 allowed = frozenset( |
23 ('', '.apk', '.app', '.dll', '.dylib', '.exe', '.nexe', '.so')) | 23 ('', '.apk', '.app', '.dll', '.dylib', '.exe', '.nexe', '.so')) |
| 24 non_x_ok_exts = frozenset(('.apk', '.isolated')) |
24 def check(f): | 25 def check(f): |
25 if not os.path.isfile(f): | 26 if not os.path.isfile(f): |
26 return False | 27 return False |
27 if os.path.basename(f).startswith('.'): | 28 if os.path.basename(f).startswith('.'): |
28 return False | 29 return False |
29 ext = os.path.splitext(f)[1] | 30 ext = os.path.splitext(f)[1] |
30 if ext == '.isolated': | 31 if ext in non_x_ok_exts: |
31 return True | 32 return True |
32 return ext in allowed and os.access(f, os.X_OK) | 33 return ext in allowed and os.access(f, os.X_OK) |
33 | 34 |
34 ret_files = set() | 35 ret_files = set() |
35 for root, dirs, files in os.walk(build_dir): | 36 for root, dirs, files in os.walk(build_dir): |
36 if not recursive: | 37 if not recursive: |
37 dirs[:] = [d for d in dirs if d.endswith('_apk')] | 38 dirs[:] = [d for d in dirs if d.endswith('_apk')] |
38 for f in (f for f in files if check(os.path.join(root, f))): | 39 for f in (f for f in files if check(os.path.join(root, f))): |
39 ret_files.add(os.path.relpath(os.path.join(root, f), build_dir)) | 40 ret_files.add(os.path.relpath(os.path.join(root, f), build_dir)) |
40 return ret_files | 41 return ret_files |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 if not options.second_build_dir: | 182 if not options.second_build_dir: |
182 parser.error('--second-build-dir is required') | 183 parser.error('--second-build-dir is required') |
183 | 184 |
184 return compare_build_artifacts(os.path.abspath(options.first_build_dir), | 185 return compare_build_artifacts(os.path.abspath(options.first_build_dir), |
185 os.path.abspath(options.second_build_dir), | 186 os.path.abspath(options.second_build_dir), |
186 options.recursive) | 187 options.recursive) |
187 | 188 |
188 | 189 |
189 if __name__ == '__main__': | 190 if __name__ == '__main__': |
190 sys.exit(main()) | 191 sys.exit(main()) |
OLD | NEW |