OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
2 # Copyright 2015 The Chromium 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 """Pulls down the current dart sdk to third_party/dart-sdk/.""" | |
7 | |
8 import os | |
9 import subprocess | |
10 import sys | |
11 | |
12 # Path constants. (All of these should be absolute paths.) | |
13 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | |
14 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..')) | |
15 DART_SDK_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'dart-sdk') | |
16 | |
17 # TODO(erg): We might want 32 bit linux too? I don't know of anyone who still | |
18 # uses that though. It looks like clang isn't built 32 bit. | |
19 LINUX_64_SDK = ('https://storage.googleapis.com/dart-archive/channels/' + | |
20 'stable/release/latest/sdk/dartsdk-linux-x64-release.zip') | |
zra
2015/02/17 23:06:06
Even though we'll only be using this for a short t
Elliot Glaysher
2015/02/17 23:08:58
That's probably a good idea. What URL would I use
| |
21 | |
22 OUTPUT_FILE = os.path.join(DART_SDK_DIR, 'dartsdk-linux-x64-release.zip') | |
23 | |
24 def RunCommand(command, fail_hard=True): | |
25 """Run command and return success (True) or failure; or if fail_hard is | |
26 True, exit on failure.""" | |
27 | |
28 print 'Running %s' % (str(command)) | |
29 if subprocess.call(' '.join(command), shell=True) == 0: | |
30 return True | |
31 print 'Failed.' | |
32 if fail_hard: | |
33 sys.exit(1) | |
34 return False | |
35 | |
36 def main(): | |
zra
2015/02/17 23:06:06
Would it be worthwhile to include an easy way to t
| |
37 # For version one, we don't actually redownload if the sdk is already | |
38 # present. This will be replaced with download_from_google_storage once | |
39 # it supports tarballs. | |
40 if not os.path.exists(OUTPUT_FILE): | |
41 wget_command = ['wget', '-N', '-c', LINUX_64_SDK, '-P', DART_SDK_DIR] | |
42 if not RunCommand(wget_command, fail_hard=False): | |
43 print "Failed to get dart sdk from server." | |
44 return | |
45 | |
46 unzip_command = ['unzip', OUTPUT_FILE, '-d', DART_SDK_DIR] | |
47 if not RunCommand(unzip_command, fail_hard=False): | |
48 print "Failed to unzip the dart sdk." | |
49 | |
50 if __name__ == '__main__': | |
51 sys.exit(main()) | |
OLD | NEW |