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

Side by Side Diff: build/win/copy_cdb_to_output.py

Issue 1884303005: Ported cdb copying from GYP to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 | chrome/chrome_tests.gypi » ('j') | 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 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 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 import hashlib 6 import hashlib
7 import os 7 import os
8 import shutil 8 import shutil
9 import sys 9 import sys
10 10
11 script_dir = os.path.dirname(os.path.realpath(__file__)) 11 script_dir = os.path.dirname(os.path.realpath(__file__))
12 src_build_dir = os.path.abspath(os.path.join(script_dir, os.pardir)) 12 src_build_dir = os.path.abspath(os.path.join(script_dir, os.pardir))
13 sys.path.insert(0, src_build_dir) 13 sys.path.insert(0, src_build_dir)
14 14
15 import vs_toolchain 15 import vs_toolchain
16 16
17 17
18 def _HexDigest(file_name): 18 def _HexDigest(file_name):
19 hasher = hashlib.sha256() 19 hasher = hashlib.sha256()
20 afile = open(file_name, 'rb') 20 afile = open(file_name, 'rb')
21 blocksize = 65536 21 blocksize = 65536
22 buf = afile.read(blocksize) 22 buf = afile.read(blocksize)
23 while len(buf) > 0: 23 while len(buf) > 0:
24 hasher.update(buf) 24 hasher.update(buf)
25 buf = afile.read(blocksize) 25 buf = afile.read(blocksize)
26 afile.close() 26 afile.close()
27 return hasher.hexdigest() 27 return hasher.hexdigest()
28 28
29 29
30 def _CopyImpl(file_name, target_dir, source_dir, verbose=True): 30 def _CopyImpl(file_name, target_dir, source_dir, verbose=False):
31 """Copy |source| to |target| if it doesn't already exist or if it 31 """Copy |source| to |target| if it doesn't already exist or if it
32 needs to be updated. 32 needs to be updated.
33 """ 33 """
34 target = os.path.join(target_dir, file_name) 34 target = os.path.join(target_dir, file_name)
35 source = os.path.join(source_dir, file_name) 35 source = os.path.join(source_dir, file_name)
36 if (os.path.isdir(os.path.dirname(target)) and 36 if (os.path.isdir(os.path.dirname(target)) and
37 ((not os.path.isfile(target)) or 37 ((not os.path.isfile(target)) or
38 _HexDigest(source) != _HexDigest(target))): 38 _HexDigest(source) != _HexDigest(target))):
39 if verbose: 39 if verbose:
40 print 'Copying %s to %s...' % (source, target) 40 print 'Copying %s to %s...' % (source, target)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 def main(): 75 def main():
76 if len(sys.argv) < 2: 76 if len(sys.argv) < 2:
77 print >>sys.stderr, 'Usage: copy_cdb_to_output.py <output_dir> ' + \ 77 print >>sys.stderr, 'Usage: copy_cdb_to_output.py <output_dir> ' + \
78 '<target_arch>' 78 '<target_arch>'
79 return 1 79 return 1
80 return _CopyCDBToOutput(sys.argv[1], sys.argv[2]) 80 return _CopyCDBToOutput(sys.argv[1], sys.argv[2])
81 81
82 82
83 if __name__ == '__main__': 83 if __name__ == '__main__':
84 sys.exit(main()) 84 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698