OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Windows can't run .sh files, so this is a Python implementation of | 6 """Windows can't run .sh files, so this is a Python implementation of |
7 update.sh. This script should replace update.sh on all platforms eventually.""" | 7 update.sh. This script should replace update.sh on all platforms eventually.""" |
8 | 8 |
9 import argparse | 9 import argparse |
10 import contextlib | 10 import contextlib |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 sys.stdout.write('.' * (num_dots - dots_printed)) | 90 sys.stdout.write('.' * (num_dots - dots_printed)) |
91 sys.stdout.flush() | 91 sys.stdout.flush() |
92 dots_printed = num_dots | 92 dots_printed = num_dots |
93 print ' Done.' | 93 print ' Done.' |
94 | 94 |
95 | 95 |
96 def ReadStampFile(): | 96 def ReadStampFile(): |
97 """Return the contents of the stamp file, or '' if it doesn't exist.""" | 97 """Return the contents of the stamp file, or '' if it doesn't exist.""" |
98 try: | 98 try: |
99 with open(STAMP_FILE, 'r') as f: | 99 with open(STAMP_FILE, 'r') as f: |
100 return f.read() | 100 return f.read().rstrip() |
101 except IOError: | 101 except IOError: |
102 return '' | 102 return '' |
103 | 103 |
104 | 104 |
105 def WriteStampFile(s): | 105 def WriteStampFile(s): |
106 """Write s to the stamp file.""" | 106 """Write s to the stamp file.""" |
107 if not os.path.exists(os.path.dirname(STAMP_FILE)): | 107 if not os.path.exists(os.path.dirname(STAMP_FILE)): |
108 os.makedirs(os.path.dirname(STAMP_FILE)) | 108 os.makedirs(os.path.dirname(STAMP_FILE)) |
109 with open(STAMP_FILE, 'w') as f: | 109 with open(STAMP_FILE, 'w') as f: |
110 f.write(s) | 110 f.write(s) |
| 111 f.write('\n') |
111 | 112 |
112 | 113 |
113 def GetSvnRevision(svn_repo): | 114 def GetSvnRevision(svn_repo): |
114 """Returns current revision of the svn repo at svn_repo.""" | 115 """Returns current revision of the svn repo at svn_repo.""" |
115 svn_info = subprocess.check_output('svn info ' + svn_repo, shell=True) | 116 svn_info = subprocess.check_output('svn info ' + svn_repo, shell=True) |
116 m = re.search(r'Revision: (\d+)', svn_info) | 117 m = re.search(r'Revision: (\d+)', svn_info) |
117 return m.group(1) | 118 return m.group(1) |
118 | 119 |
119 | 120 |
120 def RmTree(dir): | 121 def RmTree(dir): |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 print 'Updating Clang to %s...' % PACKAGE_VERSION | 275 print 'Updating Clang to %s...' % PACKAGE_VERSION |
275 if ReadStampFile() == PACKAGE_VERSION: | 276 if ReadStampFile() == PACKAGE_VERSION: |
276 print 'Already up to date.' | 277 print 'Already up to date.' |
277 return 0 | 278 return 0 |
278 | 279 |
279 # Reset the stamp file in case the build is unsuccessful. | 280 # Reset the stamp file in case the build is unsuccessful. |
280 WriteStampFile('') | 281 WriteStampFile('') |
281 | 282 |
282 if not args.force_local_build: | 283 if not args.force_local_build: |
283 cds_file = "clang-%s.tgz" % PACKAGE_VERSION | 284 cds_file = "clang-%s.tgz" % PACKAGE_VERSION |
284 cds_full_url = CDS_URL + '/Win/' + cds_file | 285 if sys.platform == 'win32': |
| 286 cds_full_url = CDS_URL + '/Win/' + cds_file |
| 287 elif sys.platform == 'darwin': |
| 288 cds_full_url = CDS_URL + '/Mac/' + cds_file |
| 289 else: |
| 290 assert sys.platform.startswith('linux') |
| 291 cds_full_url = CDS_URL + '/Linux_x64/' + cds_file |
285 | 292 |
286 # Check if there's a prebuilt binary and if so just fetch that. That's | 293 # Check if there's a prebuilt binary and if so just fetch that. That's |
287 # faster, and goma relies on having matching binary hashes on client and | 294 # faster, and goma relies on having matching binary hashes on client and |
288 # server too. | 295 # server too. |
289 print 'Trying to download prebuilt clang' | 296 print 'Trying to download prebuilt clang' |
290 | 297 |
291 # clang packages are smaller than 50 MB, small enough to keep in memory. | 298 # clang packages are smaller than 50 MB, small enough to keep in memory. |
292 with contextlib.closing(cStringIO.StringIO()) as f: | 299 with contextlib.closing(cStringIO.StringIO()) as f: |
293 try: | 300 try: |
294 DownloadUrl(cds_full_url, f) | 301 DownloadUrl(cds_full_url, f) |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL) | 691 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL) |
685 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0' | 692 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0' |
686 | 693 |
687 args.force_local_build = True | 694 args.force_local_build = True |
688 | 695 |
689 return UpdateClang(args) | 696 return UpdateClang(args) |
690 | 697 |
691 | 698 |
692 if __name__ == '__main__': | 699 if __name__ == '__main__': |
693 sys.exit(main()) | 700 sys.exit(main()) |
OLD | NEW |