3 # Copyright 2016 Google Inc.
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
15 os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
17 gn_path = 'buildtools/linux64/gn' if 'linux' in sys.platform else \
18 'buildtools/mac/gn' if 'darwin' in sys.platform else \
19 'buildtools/win/gn.exe'
21 sha1 = open(gn_path + '.sha1').read().strip()
23 def sha1_of_file(path):
25 if os.path.isfile(path):
26 with open(path, 'rb') as f:
30 if sha1_of_file(gn_path) != sha1:
31 with open(gn_path, 'wb') as f:
32 f.write(urllib2.urlopen('https://chromium-gn.storage-download.googleapis.com/' + sha1).read())
34 os.chmod(gn_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
35 stat.S_IRGRP | stat.S_IXGRP |
36 stat.S_IROTH | stat.S_IXOTH )
38 gn_copy_path = os.path.join('bin', os.path.basename(gn_path))
39 if sha1_of_file(gn_copy_path) != sha1:
40 shutil.copy(gn_path, gn_copy_path)