skia2/bin/fetch-gn
Mike Klein 4f4c064d5b roll gn to latest
Nice periodically, and this version also has a Mac arm64 binary.

Refine a few visibility rules from ":*" (any target in this file)
to "./*" (any target in any .gn file anywhere under this directory).

Use frameworks over libs where now required.

Change-Id: Ic19e1533e2810d18ae4684645d8555b422320b7f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/354536
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-01-15 15:34:00 +00:00

47 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python
# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import shutil
import stat
import sys
import tempfile
import zipfile
if sys.version_info[0] < 3:
from urllib2 import urlopen
else:
from urllib.request import urlopen
os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
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 = 'd62642c920e6a0d1756316d225a90fd6faa9e21e'
url = 'https://chrome-infra-packages.appspot.com/dl/gn/gn/{}/+/git_revision:{}'.format(pkg,rev)
f.write(urlopen(url).read())
gn = 'gn.exe' if 'win32' in sys.platform else 'gn'
with zipfile.ZipFile(gnzip, 'r') as f:
f.extract(gn, 'bin')
gn = os.path.join('bin', gn)
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(gn, copy_path)