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 |
| 20 LINUX_64_SDK = ('http://gsdview.appspot.com/dart-archive/channels/dev/' + |
| 21 'raw/43808/sdk/dartsdk-linux-x64-release.zip') |
| 22 |
| 23 OUTPUT_FILE = os.path.join(DART_SDK_DIR, 'dartsdk-linux-x64-release.zip') |
| 24 |
| 25 def RunCommand(command, fail_hard=True): |
| 26 """Run command and return success (True) or failure; or if fail_hard is |
| 27 True, exit on failure.""" |
| 28 |
| 29 print 'Running %s' % (str(command)) |
| 30 if subprocess.call(command, shell=False) == 0: |
| 31 return True |
| 32 print 'Failed.' |
| 33 if fail_hard: |
| 34 sys.exit(1) |
| 35 return False |
| 36 |
| 37 def main(): |
| 38 # For version one, we don't actually redownload if the sdk is already |
| 39 # present. This will be replaced with download_from_google_storage once |
| 40 # it supports tarballs. |
| 41 # |
| 42 # You can explicitly redownload this by blowing away your |
| 43 # third_party/dart-sdk/ directory. |
| 44 if not os.path.exists(OUTPUT_FILE): |
| 45 wget_command = ['wget', '-N', '-c', LINUX_64_SDK, '-P', DART_SDK_DIR] |
| 46 if not RunCommand(wget_command, fail_hard=False): |
| 47 print "Failed to get dart sdk from server." |
| 48 return |
| 49 |
| 50 unzip_command = ['unzip', '-q', OUTPUT_FILE, '-d', DART_SDK_DIR] |
| 51 if not RunCommand(unzip_command, fail_hard=False): |
| 52 print "Failed to unzip the dart sdk." |
| 53 |
| 54 if __name__ == '__main__': |
| 55 sys.exit(main()) |
OLD | NEW |