Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: tools/dart/update.py

Issue 955483002: Update the script that downloads the dart sdk so we can roll it. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Pulls down the current dart sdk to third_party/dart-sdk/.""" 6 """Pulls down the current dart sdk to third_party/dart-sdk/.
7
8 You can manually force this to run again by removing
9 third_party/dart-sdk/STAMP_FILE, which contains the URL of the SDK that
10 was downloaded. Rolling works by updating LINUX_64_SDK to a new URL.
11 """
7 12
8 import os 13 import os
14 import shutil
9 import subprocess 15 import subprocess
10 import sys 16 import sys
11 17
18 # How to roll the dart sdk: Just change this url! We write this to the stamp
19 # file after we download, and then check the stamp file for differences.
20 LINUX_64_SDK = ('http://gsdview.appspot.com/dart-archive/channels/dev/' +
21 'raw/43903/sdk/dartsdk-linux-x64-release.zip')
22
12 # Path constants. (All of these should be absolute paths.) 23 # Path constants. (All of these should be absolute paths.)
13 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) 24 THIS_DIR = os.path.abspath(os.path.dirname(__file__))
14 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..')) 25 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..'))
15 DART_SDK_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'dart-sdk') 26 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') 27 OUTPUT_FILE = os.path.join(DART_SDK_DIR, 'dartsdk-linux-x64-release.zip')
28 STAMP_FILE = os.path.join(DART_SDK_DIR, 'STAMP_FILE')
24 29
25 def RunCommand(command, fail_hard=True): 30 def RunCommand(command, fail_hard=True):
26 """Run command and return success (True) or failure; or if fail_hard is 31 """Run command and return success (True) or failure; or if fail_hard is
27 True, exit on failure.""" 32 True, exit on failure."""
28 33
29 print 'Running %s' % (str(command)) 34 print 'Running %s' % (str(command))
30 if subprocess.call(command, shell=False) == 0: 35 if subprocess.call(command, shell=False) == 0:
31 return True 36 return True
32 print 'Failed.' 37 print 'Failed.'
33 if fail_hard: 38 if fail_hard:
34 sys.exit(1) 39 sys.exit(1)
35 return False 40 return False
36 41
37 def main(): 42 def main():
38 # For version one, we don't actually redownload if the sdk is already 43 # Only get the SDK if we don't have a stamp for or have an out of date stamp
39 # present. This will be replaced with download_from_google_storage once 44 # file.
40 # it supports tarballs. 45 get_sdk = False
41 # 46 if not os.path.exists(STAMP_FILE):
42 # You can explicitly redownload this by blowing away your 47 get_sdk = True
43 # third_party/dart-sdk/ directory. 48 else:
44 if not os.path.exists(OUTPUT_FILE): 49 # Get the contents of the stamp file.
50 with open(STAMP_FILE, "r") as stamp_file:
51 stamp_url = stamp_file.read().replace('\n', '')
52 if stamp_url != LINUX_64_SDK:
53 get_sdk = True
54
55 if get_sdk:
56 # Completely remove all traces of the previous SDK.
57 shutil.rmtree(DART_SDK_DIR)
58 os.mkdir(DART_SDK_DIR)
59
45 wget_command = ['wget', '-N', '-c', LINUX_64_SDK, '-P', DART_SDK_DIR] 60 wget_command = ['wget', '-N', '-c', LINUX_64_SDK, '-P', DART_SDK_DIR]
46 if not RunCommand(wget_command, fail_hard=False): 61 if not RunCommand(wget_command, fail_hard=False):
47 print "Failed to get dart sdk from server." 62 print "Failed to get dart sdk from server."
48 return 63 return
49 64
50 unzip_command = ['unzip', '-q', OUTPUT_FILE, '-d', DART_SDK_DIR] 65 unzip_command = ['unzip', '-o', '-q', OUTPUT_FILE, '-d', DART_SDK_DIR]
51 if not RunCommand(unzip_command, fail_hard=False): 66 if not RunCommand(unzip_command, fail_hard=False):
52 print "Failed to unzip the dart sdk." 67 print "Failed to unzip the dart sdk."
53 68
69 # Write our stamp file so we don't redownload the sdk.
70 with open(STAMP_FILE, "w") as stamp_file:
71 stamp_file.write(LINUX_64_SDK)
72
54 if __name__ == '__main__': 73 if __name__ == '__main__':
55 sys.exit(main()) 74 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698