blob: d0c791d1c398b7c8a026505f9a01364de0bd6f56 [file] [log] [blame]
#!/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
from urllib.request import urlopen
os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
gnzip = os.path.join(tempfile.mkdtemp(), '')
with open(gnzip, 'wb') as f:
pkg = 'linux-amd64' if 'linux' in sys.platform else \
'mac-amd64' if 'darwin' in sys.platform else \
rev = '9e993e3da82a9f4bc5c50c190afbcffd61e3d9e0'
url = '{}/+/git_revision:{}'.format(pkg,rev)
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 \
if os.path.isdir(os.path.dirname(copy_path)):
shutil.copy(gn, copy_path)