| 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 """Remove the build metadata embedded in the artifacts of a build.""" | 5 """Remove the build metadata embedded in the artifacts of a build.""" |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import multiprocessing | 8 import multiprocessing |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 if not os.path.isfile(f) or os.path.basename(f).startswith('.'): | 33 if not os.path.isfile(f) or os.path.basename(f).startswith('.'): |
| 34 return False | 34 return False |
| 35 if os.path.getmtime(os.path.join(build_dir, f)) < min_timestamp: | 35 if os.path.getmtime(os.path.join(build_dir, f)) < min_timestamp: |
| 36 return False | 36 return False |
| 37 ext = os.path.splitext(f)[1] | 37 ext = os.path.splitext(f)[1] |
| 38 return (ext in non_x_ok_exts) or (ext in allowed and os.access(f, os.X_OK)) | 38 return (ext in non_x_ok_exts) or (ext in allowed and os.access(f, os.X_OK)) |
| 39 | 39 |
| 40 ret_files = set() | 40 ret_files = set() |
| 41 for root, dirs, files in os.walk(build_dir): | 41 for root, dirs, files in os.walk(build_dir): |
| 42 if not recursive: | 42 if not recursive: |
| 43 dirs[:] = [d for d in dirs if d.endswith('_apk')] | 43 dirs[:] = [d for d in dirs |
| 44 if d.endswith('_apk') or d == 'apks'] |
| 44 for f in (f for f in files if check(os.path.join(root, f))): | 45 for f in (f for f in files if check(os.path.join(root, f))): |
| 45 ret_files.add(os.path.relpath(os.path.join(root, f), build_dir)) | 46 ret_files.add(os.path.relpath(os.path.join(root, f), build_dir)) |
| 46 return ret_files | 47 return ret_files |
| 47 | 48 |
| 48 | 49 |
| 49 def run_zap_timestamp(src_dir, filepath): | 50 def run_zap_timestamp(src_dir, filepath): |
| 50 """Run zap_timestamp.exe on a PE binary.""" | 51 """Run zap_timestamp.exe on a PE binary.""" |
| 51 assert sys.platform == 'win32' | 52 assert sys.platform == 'win32' |
| 52 syzygy_dir = os.path.join( | 53 syzygy_dir = os.path.join( |
| 53 src_dir, 'third_party', 'syzygy', 'binaries', 'exe') | 54 src_dir, 'third_party', 'syzygy', 'binaries', 'exe') |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 parser.error('--build-dir is required') | 151 parser.error('--build-dir is required') |
| 151 | 152 |
| 152 if sys.platform == 'win32' and not options.src_dir: | 153 if sys.platform == 'win32' and not options.src_dir: |
| 153 parser.error('--src-dir is required') | 154 parser.error('--src-dir is required') |
| 154 | 155 |
| 155 return remove_metadata(options.build_dir, options.src_dir, options.recursive) | 156 return remove_metadata(options.build_dir, options.src_dir, options.recursive) |
| 156 | 157 |
| 157 | 158 |
| 158 if __name__ == '__main__': | 159 if __name__ == '__main__': |
| 159 sys.exit(main()) | 160 sys.exit(main()) |
| OLD | NEW |