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

Side by Side Diff: tools/determinism/remove_build_metadata.py

Issue 2280513003: Add a blacklist for the files that should be processed by zap_timestamps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import Queue 11 import Queue
12 import shutil 12 import shutil
13 import subprocess 13 import subprocess
14 import sys 14 import sys
15 import tempfile 15 import tempfile
16 import threading 16 import threading
17 import zipfile 17 import zipfile
18 18
19 19
20 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 20 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
21 SRC_DIR = os.path.dirname(os.path.dirname(BASE_DIR)) 21 SRC_DIR = os.path.dirname(os.path.dirname(BASE_DIR))
22 22
23 # Files that can't be processed by zap_timestamp.exe.
24 _ZAP_TIMESTAMP_BLACKLIST = {
25 'mini_installer.exe',
26 }
23 27
24 def get_files_to_clean(build_dir, recursive=False): 28 def get_files_to_clean(build_dir, recursive=False):
25 """Get the list of files to clean.""" 29 """Get the list of files to clean."""
26 allowed = frozenset( 30 allowed = frozenset(
27 ('', '.apk', '.app', '.dll', '.dylib', '.exe', '.nexe', '.so')) 31 ('', '.apk', '.app', '.dll', '.dylib', '.exe', '.nexe', '.so'))
28 non_x_ok_exts = frozenset(('.apk', '.isolated')) 32 non_x_ok_exts = frozenset(('.apk', '.isolated'))
29 min_timestamp = 0 33 min_timestamp = 0
30 if os.path.exists(os.path.join(build_dir, 'build.ninja')): 34 if os.path.exists(os.path.join(build_dir, 'build.ninja')):
31 min_timestamp = os.path.getmtime(os.path.join(build_dir, 'build.ninja')) 35 min_timestamp = os.path.getmtime(os.path.join(build_dir, 'build.ninja'))
32 36
(...skipping 27 matching lines...) Expand all
60 log, _ = proc.communicate() 64 log, _ = proc.communicate()
61 if proc.returncode != 0: 65 if proc.returncode != 0:
62 sys.stderr.write('%s failed:\n%s\n' % (os.path.basename(filepath), log)) 66 sys.stderr.write('%s failed:\n%s\n' % (os.path.basename(filepath), log))
63 return proc.returncode 67 return proc.returncode
64 68
65 69
66 def remove_pe_metadata(filename): 70 def remove_pe_metadata(filename):
67 """Remove the build metadata from a PE file.""" 71 """Remove the build metadata from a PE file."""
68 # Only run zap_timestamp on the PE files for which we have a PDB. 72 # Only run zap_timestamp on the PE files for which we have a PDB.
69 ret = 0 73 ret = 0
70 if os.path.exists(filename + '.pdb'): 74 if ((not os.path.basename(filename) in _ZAP_TIMESTAMP_BLACKLIST) and
75 os.path.exists(filename + '.pdb')):
71 ret = run_zap_timestamp(filename) 76 ret = run_zap_timestamp(filename)
72 return ret 77 return ret
73 78
74 79
75 def remove_apk_timestamps(filename): 80 def remove_apk_timestamps(filename):
76 """Remove the timestamps embedded in an apk archive.""" 81 """Remove the timestamps embedded in an apk archive."""
77 sys.stdout.write('Processing: %s\n' % os.path.basename(filename)) 82 sys.stdout.write('Processing: %s\n' % os.path.basename(filename))
78 with zipfile.ZipFile(filename, 'r') as zf: 83 with zipfile.ZipFile(filename, 'r') as zf:
79 # Creates a temporary file. 84 # Creates a temporary file.
80 out_file, out_filename = tempfile.mkstemp(prefix='remote_apk_timestamp') 85 out_file, out_filename = tempfile.mkstemp(prefix='remote_apk_timestamp')
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 options, _ = parser.parse_args() 150 options, _ = parser.parse_args()
146 151
147 if not options.build_dir: 152 if not options.build_dir:
148 parser.error('--build-dir is required') 153 parser.error('--build-dir is required')
149 154
150 return remove_metadata(options.build_dir, options.recursive) 155 return remove_metadata(options.build_dir, options.recursive)
151 156
152 157
153 if __name__ == '__main__': 158 if __name__ == '__main__':
154 sys.exit(main()) 159 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698