Index: tools/dart/update.py |
diff --git a/tools/dart/update.py b/tools/dart/update.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..be70ff2ab2cdb84945039d0a1edb451c3cb3ed1f |
--- /dev/null |
+++ b/tools/dart/update.py |
@@ -0,0 +1,51 @@ |
+#!/usr/bin/python |
+# Copyright 2015 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""Pulls down the current dart sdk to third_party/dart-sdk/.""" |
+ |
+import os |
+import subprocess |
+import sys |
+ |
+# Path constants. (All of these should be absolute paths.) |
+THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
+CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..')) |
+DART_SDK_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'dart-sdk') |
+ |
+# TODO(erg): We might want 32 bit linux too? I don't know of anyone who still |
+# uses that though. It looks like clang isn't built 32 bit. |
+LINUX_64_SDK = ('https://storage.googleapis.com/dart-archive/channels/' + |
+ '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
|
+ |
+OUTPUT_FILE = os.path.join(DART_SDK_DIR, 'dartsdk-linux-x64-release.zip') |
+ |
+def RunCommand(command, fail_hard=True): |
+ """Run command and return success (True) or failure; or if fail_hard is |
+ True, exit on failure.""" |
+ |
+ print 'Running %s' % (str(command)) |
+ if subprocess.call(' '.join(command), shell=True) == 0: |
+ return True |
+ print 'Failed.' |
+ if fail_hard: |
+ sys.exit(1) |
+ return False |
+ |
+def main(): |
zra
2015/02/17 23:06:06
Would it be worthwhile to include an easy way to t
|
+ # For version one, we don't actually redownload if the sdk is already |
+ # present. This will be replaced with download_from_google_storage once |
+ # it supports tarballs. |
+ if not os.path.exists(OUTPUT_FILE): |
+ wget_command = ['wget', '-N', '-c', LINUX_64_SDK, '-P', DART_SDK_DIR] |
+ if not RunCommand(wget_command, fail_hard=False): |
+ print "Failed to get dart sdk from server." |
+ return |
+ |
+ unzip_command = ['unzip', OUTPUT_FILE, '-d', DART_SDK_DIR] |
+ if not RunCommand(unzip_command, fail_hard=False): |
+ print "Failed to unzip the dart sdk." |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |