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

Side by Side Diff: win_toolchain/get_toolchain_if_necessary.py

Issue 233563003: Run get_toolchain_if_necessary.py with depot_tools Python under Cygwin (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: address comments Created 6 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 | 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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Downloads and unpacks a toolchain for building on Windows. The contents are 6 """Downloads and unpacks a toolchain for building on Windows. The contents are
7 matched by sha1 which will be updated when the toolchain is updated. 7 matched by sha1 which will be updated when the toolchain is updated.
8 8
9 Having a toolchain script in depot_tools means that it's not versioned 9 Having a toolchain script in depot_tools means that it's not versioned
10 directly with the source code. That is, if the toolchain is upgraded, but 10 directly with the source code. That is, if the toolchain is upgraded, but
11 you're trying to build an historical version of Chromium from before the 11 you're trying to build an historical version of Chromium from before the
12 toolchain upgrade, this will cause you to build with a newer toolchain than 12 toolchain upgrade, this will cause you to build with a newer toolchain than
13 was available when that code was committed. This is done for a two main 13 was available when that code was committed. This is done for a two main
14 reasons: 1) it would likely be annoying to have the up-to-date toolchain 14 reasons: 1) it would likely be annoying to have the up-to-date toolchain
15 removed and replaced by one without a service pack applied); 2) it would 15 removed and replaced by one without a service pack applied); 2) it would
16 require maintaining scripts that can build older not-up-to-date revisions of 16 require maintaining scripts that can build older not-up-to-date revisions of
17 the toolchain. This is likely to be a poorly tested code path that probably 17 the toolchain. This is likely to be a poorly tested code path that probably
18 won't be properly maintained. See http://crbug.com/323300. 18 won't be properly maintained. See http://crbug.com/323300.
19 19
20 This does not extend to major versions of the toolchain however, on the 20 This does not extend to major versions of the toolchain however, on the
21 assumption that there are more likely to be source incompatibilities between 21 assumption that there are more likely to be source incompatibilities between
22 major revisions. This script calls a subscript (currently, toolchain2013.py) 22 major revisions. This script calls a subscript (currently, toolchain2013.py)
23 to do the main work. It is expected that toolchain2013.py will always be able 23 to do the main work. It is expected that toolchain2013.py will always be able
24 to acquire/build the most current revision of a VS2013-based toolchain. In the 24 to acquire/build the most current revision of a VS2013-based toolchain. In the
25 future when a hypothetical VS2015 is released, the 2013 script will be 25 future when a hypothetical VS2015 is released, the 2013 script will be
26 maintained, and a new 2015 script would be added. 26 maintained, and a new 2015 script would be added.
27 """ 27 """
28 28
29 import ctypes.wintypes
30 import hashlib 29 import hashlib
31 import json 30 import json
32 import optparse 31 import optparse
33 import os 32 import os
34 import shutil 33 import shutil
35 import subprocess 34 import subprocess
36 import sys 35 import sys
37 import time 36 import time
38 37
39 38
40 BASEDIR = os.path.dirname(os.path.abspath(__file__)) 39 BASEDIR = os.path.dirname(os.path.abspath(__file__))
41 sys.path.append(os.path.join(BASEDIR, '..')) 40 DEPOT_TOOLS_PATH = os.path.join(BASEDIR, '..')
41 sys.path.append(DEPOT_TOOLS_PATH)
42 import download_from_google_storage 42 import download_from_google_storage
43 43
44 44 if sys.platform != 'cygwin':
45 GetFileAttributes = ctypes.windll.kernel32.GetFileAttributesW 45 import ctypes.wintypes
46 GetFileAttributes.argtypes = (ctypes.wintypes.LPWSTR,) 46 GetFileAttributes = ctypes.windll.kernel32.GetFileAttributesW
47 GetFileAttributes.restype = ctypes.wintypes.DWORD 47 GetFileAttributes.argtypes = (ctypes.wintypes.LPWSTR,)
48 FILE_ATTRIBUTE_HIDDEN = 0x2 48 GetFileAttributes.restype = ctypes.wintypes.DWORD
49 FILE_ATTRIBUTE_SYSTEM = 0x4 49 FILE_ATTRIBUTE_HIDDEN = 0x2
50 FILE_ATTRIBUTE_SYSTEM = 0x4
50 51
51 52
52 def IsHidden(file_path): 53 def IsHidden(file_path):
53 """Returns whether the given |file_path| has the 'system' or 'hidden' 54 """Returns whether the given |file_path| has the 'system' or 'hidden'
54 attribute set.""" 55 attribute set."""
55 p = GetFileAttributes(file_path) 56 p = GetFileAttributes(file_path)
56 assert p != 0xffffffff 57 assert p != 0xffffffff
57 return bool(p & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) 58 return bool(p & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM))
58 59
59 60
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 188
188 def main(): 189 def main():
189 if not sys.platform.startswith(('cygwin', 'win32')): 190 if not sys.platform.startswith(('cygwin', 'win32')):
190 return 0 191 return 0
191 192
192 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) 193 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
193 parser.add_option('--output-json', metavar='FILE', 194 parser.add_option('--output-json', metavar='FILE',
194 help='write information about toolchain to FILE') 195 help='write information about toolchain to FILE')
195 options, args = parser.parse_args() 196 options, args = parser.parse_args()
196 197
198 if sys.platform == 'cygwin':
199 # This script requires Windows Python, so invoke with depot_tools' Python.
200 def winpath(path):
201 return subprocess.check_output(['cygpath', '-w', path]).strip()
202 python = os.path.join(DEPOT_TOOLS_PATH, 'python.bat')
203 cmd = [python, winpath(__file__)]
204 if options.output_json:
205 cmd.extend(['--output-json', winpath(options.output_json)])
206 cmd.extend(args)
207 sys.exit(subprocess.call(cmd))
208
197 # We assume that the Pro hash is the first one. 209 # We assume that the Pro hash is the first one.
198 desired_hashes = args 210 desired_hashes = args
199 if len(desired_hashes) == 0: 211 if len(desired_hashes) == 0:
200 sys.exit('Desired hashes are required.') 212 sys.exit('Desired hashes are required.')
201 213
202 # Move to depot_tools\win_toolchain where we'll store our files, and where 214 # Move to depot_tools\win_toolchain where we'll store our files, and where
203 # the downloader script is. 215 # the downloader script is.
204 os.chdir(os.path.normpath(os.path.join(BASEDIR))) 216 os.chdir(os.path.normpath(os.path.join(BASEDIR)))
205 toolchain_dir = '.' 217 toolchain_dir = '.'
206 target_dir = os.path.normpath(os.path.join(toolchain_dir, 'vs2013_files')) 218 target_dir = os.path.normpath(os.path.join(toolchain_dir, 'vs2013_files'))
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 260
249 if options.output_json: 261 if options.output_json:
250 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), 262 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'),
251 options.output_json) 263 options.output_json)
252 264
253 return 0 265 return 0
254 266
255 267
256 if __name__ == '__main__': 268 if __name__ == '__main__':
257 sys.exit(main()) 269 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