Chromium Code Reviews| Index: win_toolchain/get_toolchain_if_necessary.py |
| diff --git a/win_toolchain/get_toolchain_if_necessary.py b/win_toolchain/get_toolchain_if_necessary.py |
| index 127506ba2f9221af535f9395ff4a2e843411d443..535d989a999aa916612b2a6391bb36fa2aacfcbf 100755 |
| --- a/win_toolchain/get_toolchain_if_necessary.py |
| +++ b/win_toolchain/get_toolchain_if_necessary.py |
| @@ -26,7 +26,6 @@ future when a hypothetical VS2015 is released, the 2013 script will be |
| maintained, and a new 2015 script would be added. |
| """ |
| -import ctypes.wintypes |
| import hashlib |
| import json |
| import optparse |
| @@ -38,15 +37,17 @@ import time |
| BASEDIR = os.path.dirname(os.path.abspath(__file__)) |
| -sys.path.append(os.path.join(BASEDIR, '..')) |
| +DEPOT_TOOLS_PATH = os.path.join(BASEDIR, '..') |
| +sys.path.append(DEPOT_TOOLS_PATH) |
| import download_from_google_storage |
| - |
| -GetFileAttributes = ctypes.windll.kernel32.GetFileAttributesW |
| -GetFileAttributes.argtypes = (ctypes.wintypes.LPWSTR,) |
| -GetFileAttributes.restype = ctypes.wintypes.DWORD |
| -FILE_ATTRIBUTE_HIDDEN = 0x2 |
| -FILE_ATTRIBUTE_SYSTEM = 0x4 |
| +if sys.platform != 'cygwin': |
| + import ctypes.wintypes |
| + GetFileAttributes = ctypes.windll.kernel32.GetFileAttributesW |
| + GetFileAttributes.argtypes = (ctypes.wintypes.LPWSTR,) |
| + GetFileAttributes.restype = ctypes.wintypes.DWORD |
| + FILE_ATTRIBUTE_HIDDEN = 0x2 |
| + FILE_ATTRIBUTE_SYSTEM = 0x4 |
| def IsHidden(file_path): |
| @@ -194,6 +195,19 @@ def main(): |
| help='write information about toolchain to FILE') |
| options, args = parser.parse_args() |
| + if sys.platform == 'cygwin': |
| + # This script requires Windows Python, so invoke with depot_tools' Python. |
| + def winpath(path): |
| + return subprocess.check_output(['cygpath', '-w', path]).strip() |
| + python = os.path.join(DEPOT_TOOLS_PATH, 'python.bat') |
| + subprocess_command = [python, winpath(__file__)] |
|
iannucci
2014/04/11 11:01:33
nit: `cmd` would be a fine name for this variable,
Mike Wittman
2014/04/11 17:58:04
Done.
|
| + if options.output_json: |
| + subprocess_command.extend(['--output-json', winpath(options.output_json)]) |
| + subprocess_command.extend(args) |
| + p = subprocess.Popen(subprocess_command, shell=False) |
| + p.communicate() |
| + sys.exit(p.returncode) |
|
iannucci
2014/04/11 11:01:33
this should be
sys.exit(subprocess.call(subproces
Mike Wittman
2014/04/11 17:58:04
Done.
|
| + |
| # We assume that the Pro hash is the first one. |
| desired_hashes = args |
| if len(desired_hashes) == 0: |