From 7d6ffa55da29eeb36da556e0adb5dcd8a3d8ae45 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Thu, 5 Dec 2013 18:43:11 +0000 Subject: [PATCH] Detect cygwin as Win32 for the purposes of running GN and downloading from google storage. This normalizes sys.platform so people running cygwin are treated like Windows. Review URL: https://codereview.chromium.org/104763003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@238999 0039d316-1c4b-4281-b951-d872f2087c98 --- download_from_google_storage.py | 10 +++++++++- gn.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/download_from_google_storage.py b/download_from_google_storage.py index 766a2b855..f98557773 100755 --- a/download_from_google_storage.py +++ b/download_from_google_storage.py @@ -32,6 +32,14 @@ class InvalidFileError(IOError): pass +def GetNormalizedPlatform(): + """Returns the result of sys.platform accounting for cygwin. + Under cygwin, this will always return "win32" like the native Python.""" + if sys.platform == 'cygwin': + return 'win32' + return sys.platform + + # Common utilities class Gsutil(object): """Call gsutil with some predefined settings. This is a convenience object, @@ -197,7 +205,7 @@ def _downloader_worker_thread(thread_num, q, force, base_url, # TODO(hinoka): It is supposedly faster to use "gsutil stat" but that # doesn't appear to be supported by the gsutil currently in our tree. When # we update, this code should use that instead of "gsutil ls -L". - if not sys.platform.startswith('win'): + if sys.platform != 'win32': code, out, _ = gsutil.check_call('ls', '-L', file_url) if code != 0: out_q.put('%d> %s' % (thread_num, err)) diff --git a/gn.py b/gn.py index c8af3302e..23521e3ab 100644 --- a/gn.py +++ b/gn.py @@ -43,7 +43,7 @@ def FindSourceRootOnPath(): def RunGN(sourceroot): # The binaries in platform-specific subdirectories in src/tools/gn/bin. gnpath = sourceroot + '/tools/gn/bin/' - if sys.platform == 'win32': + if sys.platform in ('cygwin', 'win32'): gnpath += 'win/gn.exe' elif sys.platform.startswith('linux'): gnpath += 'linux/gn'