mtklein | 6af0c95 | 2016-07-22 03:34:25 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Copyright 2016 Google Inc. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license that can be |
| 6 | # found in the LICENSE file. |
| 7 | |
Mike Klein | b621a35 | 2017-01-12 13:20:38 -0500 | [diff] [blame] | 8 | import os |
| 9 | import shutil |
| 10 | import stat |
mtklein | 6af0c95 | 2016-07-22 03:34:25 -0700 | [diff] [blame] | 11 | import sys |
Mike Klein | b621a35 | 2017-01-12 13:20:38 -0500 | [diff] [blame] | 12 | import urllib2 |
mtklein | 6af0c95 | 2016-07-22 03:34:25 -0700 | [diff] [blame] | 13 | |
| 14 | def gn_path(): |
| 15 | if 'linux' in sys.platform: |
| 16 | return 'buildtools/linux64/gn' |
| 17 | if 'darwin' in sys.platform: |
| 18 | return 'buildtools/mac/gn' |
| 19 | return 'buildtools/win/gn.exe' |
| 20 | |
Mike Klein | b621a35 | 2017-01-12 13:20:38 -0500 | [diff] [blame] | 21 | sha1 = open(gn_path() + '.sha1').read() |
| 22 | |
| 23 | with open(gn_path(), 'wb') as f: |
| 24 | f.write(urllib2.urlopen('https://chromium-gn.storage-download.googleapis.com/' + sha1).read()) |
| 25 | |
| 26 | os.chmod(gn_path(), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | |
| 27 | stat.S_IRGRP | stat.S_IXGRP | |
| 28 | stat.S_IROTH | stat.S_IXOTH ) |
| 29 | shutil.copy(gn_path(), 'bin'); |