| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2016 The Dart project authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import os | |
| 7 import subprocess | |
| 8 import sys | |
| 9 import tarfile | |
| 10 import urllib | |
| 11 import utils | |
| 12 | |
| 13 HOST_OS = utils.GuessOS() | |
| 14 HOST_ARCH = utils.GuessArchitecture() | |
| 15 SCRIPT_DIR = os.path.dirname(sys.argv[0]) | |
| 16 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) | |
| 17 | |
| 18 BUCKET_NAME = 'dart-dependencies' | |
| 19 | |
| 20 def host_os_for_sdk(host_os): | |
| 21 if host_os.startswith('macos'): | |
| 22 return 'mac' | |
| 23 if host_os.startswith('win'): | |
| 24 return 'win' | |
| 25 return host_os | |
| 26 | |
| 27 def main(argv): | |
| 28 host_os = host_os_for_sdk(HOST_OS) | |
| 29 sdk_path = os.path.join(DART_ROOT, 'tools', 'sdks', host_os) | |
| 30 stamp_path = os.path.join(sdk_path, 'dart-sdk.tar.gz.stamp') | |
| 31 sha_path = os.path.join(sdk_path, 'dart-sdk.tar.gz.sha1') | |
| 32 tgz_path = os.path.join(sdk_path, 'dart-sdk.tar.gz') | |
| 33 | |
| 34 stamp = '' | |
| 35 if os.path.isfile(stamp_path): | |
| 36 with open(stamp_path, 'r') as fp: | |
| 37 stamp = fp.read() | |
| 38 | |
| 39 with open(sha_path, 'r') as fp: | |
| 40 sha = fp.read() | |
| 41 | |
| 42 if stamp != sha: | |
| 43 url = ('https://%s.storage.googleapis.com/%s' % (BUCKET_NAME, sha)) | |
| 44 print 'Downloading prebuilt Dart SDK from: ' + url | |
| 45 urllib.urlretrieve(url, tgz_path) | |
| 46 with tarfile.open(tgz_path) as tar: | |
| 47 tar.extractall(sdk_path) | |
| 48 with open(stamp_path, 'w') as fp: | |
| 49 fp.write(sha) | |
| 50 | |
| 51 if __name__ == '__main__': | |
| 52 sys.exit(main(sys.argv)) | |
| OLD | NEW |