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

Side by Side Diff: scripts/slave/recipe_modules/isolate/resources/remove_build_metadata.py

Issue 673723002: Deterministic recipe: Print the list of files for which zap_timestamp failed. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 6 years, 2 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 optparse 8 import optparse
9 import os 9 import os
10 import subprocess 10 import subprocess
(...skipping 10 matching lines...) Expand all
21 return subprocess.call([zap_timestamp_exe, filename]) 21 return subprocess.call([zap_timestamp_exe, filename])
22 22
23 23
24 def RemovePEMetadata(build_dir, src_dir): 24 def RemovePEMetadata(build_dir, src_dir):
25 """Remove the build metadata from a PE file.""" 25 """Remove the build metadata from a PE file."""
26 files = (i for i in os.listdir(build_dir) if i.endswith(('.dll', '.exe'))) 26 files = (i for i in os.listdir(build_dir) if i.endswith(('.dll', '.exe')))
27 27
28 with open(os.path.join(BASE_DIR, 'deterministic_build_blacklist.json')) as f: 28 with open(os.path.join(BASE_DIR, 'deterministic_build_blacklist.json')) as f:
29 blacklist = frozenset(json.load(f)) 29 blacklist = frozenset(json.load(f))
30 30
31 failed = []
31 for filename in files: 32 for filename in files:
32 # Ignore the blacklisted files. 33 # Ignore the blacklisted files.
33 if filename in blacklist: 34 if filename in blacklist:
34 print 'Ignoring blacklisted file %s' % filename 35 print 'Ignoring blacklisted file %s' % filename
35 continue 36 continue
36 # Only run zap_timestamp on the PE files for which we have a PDB. 37 # Only run zap_timestamp on the PE files for which we have a PDB.
37 if os.path.exists(os.path.join(build_dir, filename + '.pdb')): 38 if os.path.exists(os.path.join(build_dir, filename + '.pdb')):
38 ret = RunZapTimestamp(src_dir, os.path.join(build_dir, filename)) 39 ret = RunZapTimestamp(src_dir, os.path.join(build_dir, filename))
39 if ret != 0: 40 if ret != 0:
40 print "zap_timestamp.exe failed for %s." % filename 41 failed.append(filename)
41 return ret 42
43 if failed:
44 print >> sys.stderr, 'zap_timestamp.exe failed for the following files:'
45 print >> sys.stderr, '\n'.join(' ' + i for i in sorted(failed))
46 return 1
42 47
M-A Ruel 2014/10/23 02:01:21 add a "return 0" at the end of the function
Sébastien Marchand 2014/10/23 02:03:53 k, I thought it was implicit.
43 48
44 def main(): 49 def main():
45 parser = optparse.OptionParser(usage='%prog [options]') 50 parser = optparse.OptionParser(usage='%prog [options]')
46 # TODO(sebmarchand): Add support for reading the list of artifact from a 51 # TODO(sebmarchand): Add support for reading the list of artifact from a
47 # .isolated file. 52 # .isolated file.
48 parser.add_option('--build-dir', help='The build directory.') 53 parser.add_option('--build-dir', help='The build directory.')
49 parser.add_option('--src-dir', help='The source directory.') 54 parser.add_option('--src-dir', help='The source directory.')
50 options, _ = parser.parse_args() 55 options, _ = parser.parse_args()
51 56
52 if not options.build_dir: 57 if not options.build_dir:
53 parser.error('--build-dir is required') 58 parser.error('--build-dir is required')
54 if not options.src_dir: 59 if not options.src_dir:
55 parser.error('--src-dir is required') 60 parser.error('--src-dir is required')
56 61
57 # There's nothing to do for the non-Windows platform yet. 62 # There's nothing to do for the non-Windows platform yet.
58 if sys.platform == 'win32': 63 if sys.platform == 'win32':
59 return RemovePEMetadata(options.build_dir, options.src_dir) 64 return RemovePEMetadata(options.build_dir, options.src_dir)
60 65
61 66
62 if __name__ == '__main__': 67 if __name__ == '__main__':
63 sys.exit(main()) 68 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