Commit 9630aa2b authored by wittman@chromium.org's avatar wittman@chromium.org

Run get_toolchain_if_necessary.py with depot_tools Python under Cygwin

get_toolchain_if_necessary.py contains a number of Windows-isms, including
computing hashes on Windows-style path names, so does not work under
Cygwin. This change reruns it under depot_tools' Windows Python if run
from Cygwin Python.

Review URL: https://codereview.chromium.org/233563003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@263301 0039d316-1c4b-4281-b951-d872f2087c98
parent 3c669839
......@@ -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,17 @@ 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')
cmd = [python, winpath(__file__)]
if options.output_json:
cmd.extend(['--output-json', winpath(options.output_json)])
cmd.extend(args)
sys.exit(subprocess.call(cmd))
# We assume that the Pro hash is the first one.
desired_hashes = args
if len(desired_hashes) == 0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment