roll GN
Update fetch-gn to fetch gn CIPD packages.
The hashing seemed unimportant... we could add it back.
Change-Id: I56be8a62d11be20100be41e0889d2088baefbcf0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280707
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
diff --git a/bin/fetch-gn b/bin/fetch-gn
index e7cc923..ee150e2 100755
--- a/bin/fetch-gn
+++ b/bin/fetch-gn
@@ -5,11 +5,12 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import hashlib
import os
import shutil
import stat
import sys
+import tempfile
+import zipfile
if sys.version_info[0] < 3:
from urllib2 import urlopen
@@ -18,30 +19,28 @@
os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
-dst = 'bin/gn.exe' if 'win32' in sys.platform else 'bin/gn'
+gnzip = os.path.join(tempfile.mkdtemp(), 'gn.zip')
+with open(gnzip, 'wb') as f:
+ pkg = 'linux-amd64' if 'linux' in sys.platform else \
+ 'mac-amd64' if 'darwin' in sys.platform else \
+ 'windows-amd64'
+ rev = '82d673acb802cee21534c796a59f8cdf26500f53'
+ url = 'https://chrome-infra-packages.appspot.com/dl/gn/gn/{}/+/git_revision:{}'.format(pkg,rev)
+ f.write(urlopen(url).read())
-sha1 = '3523d50538357829725d4ed74b777a572ce0ac74' if 'linux' in sys.platform else \
- 'd43122f6140d0711518aa909980cb009c4fbce3d' if 'darwin' in sys.platform else \
- 'e20768d93a6b4400de0d03bb8ceb46facdbe3883' # Windows
+gn = 'gn.exe' if 'win32' in sys.platform else 'gn'
+with zipfile.ZipFile(gnzip, 'r') as f:
+ f.extract(gn, 'bin')
-def sha1_of_file(path):
- h = hashlib.sha1()
- if os.path.isfile(path):
- with open(path, 'rb') as f:
- h.update(f.read())
- return h.hexdigest()
+gn = os.path.join('bin', gn)
-if sha1_of_file(dst) != sha1:
- with open(dst, 'wb') as f:
- f.write(urlopen('https://chromium-gn.storage-download.googleapis.com/' + sha1).read())
-
- os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
- stat.S_IRGRP | stat.S_IXGRP |
- stat.S_IROTH | stat.S_IXOTH )
+os.chmod(gn, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
+ stat.S_IRGRP | stat.S_IXGRP |
+ stat.S_IROTH | stat.S_IXOTH )
# We'll also copy to a path that depot_tools' GN wrapper will expect to find the binary.
copy_path = 'buildtools/linux64/gn' if 'linux' in sys.platform else \
'buildtools/mac/gn' if 'darwin' in sys.platform else \
'buildtools/win/gn.exe'
if os.path.isdir(os.path.dirname(copy_path)):
- shutil.copy(dst, copy_path)
+ shutil.copy(gn, copy_path)