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

Side by Side Diff: third_party/mac_sdk/update.py

Issue 1759793003: Scripts to upload and update the mac toolchain. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use full path Created 4 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 """This script is used to download prebuilt clang binaries."""
erikchen 2016/03/03 01:45:47 out of date.
justincohen 2016/03/03 18:58:33 Done.
7
8 import os
9 import shutil
10 import subprocess
11 import sys
12 import tarfile
13 import time
14 import tempfile
15 import urllib2
16
17 SDK_REVISION = '7D152p'
18 SDK_SUB_REVISION = 1
19 PACKAGE_VERSION = "%s-%s" % (SDK_REVISION, SDK_SUB_REVISION)
20
21 THIS_DIR = os.path.abspath(os.path.dirname(__file__))
22 SDK_BUILD_DIR = os.path.join(THIS_DIR, 'Xcode.app')
23 STAMP_FILE = os.path.join(SDK_BUILD_DIR, 'sdk_build_revision')
24 SDK_URL = 'gs://chrome-mac-sdk/'
erikchen 2016/03/03 01:45:47 this url could be shared with other file?
justincohen 2016/03/03 18:58:33 Holding off on this change now to determine what e
25
26 def ReadStampFile():
27 """Return the contents of the stamp file, or '' if it doesn't exist."""
28 try:
29 with open(STAMP_FILE, 'r') as f:
30 return f.read().rstrip()
31 except IOError:
32 return ''
33
34
35 def WriteStampFile(s):
36 """Write s to the stamp file."""
37 EnsureDirExists(os.path.dirname(STAMP_FILE))
38 with open(STAMP_FILE, 'w') as f:
39 f.write(s)
40 f.write('\n')
41
42
43 def EnsureDirExists(path):
44 if not os.path.exists(path):
45 print "Creating directory %s" % path
46 os.makedirs(path)
47
48
49 def DownloadAndUnpack(url, output_dir):
50 temp_name = tempfile.mktemp(prefix='mac_sdk')
erikchen 2016/03/03 01:45:47 clean up temp file.
justincohen 2016/03/03 18:58:33 Done.
51 subprocess.check_call(['gsutil.py', '--force-version', '4.15', '--', 'cp',
52 url, temp_name])
53 EnsureDirExists(output_dir)
54 print 'Unpacking SDK'
55 if url.endswith('.zip'):
erikchen 2016/03/03 01:45:47 shouldn't we control the extension? why not standa
justincohen 2016/03/03 18:58:33 Done.
56 zipfile.ZipFile(temp_name).extractall(path=output_dir)
57 else:
58 tarfile.open(mode='r:gz', name=temp_name).extractall(path=output_dir)
59
60 def main():
justincohen 2016/03/03 01:24:54 I removed the GYP_DEFINE check, that needs to be r
erikchen 2016/03/03 01:45:47 as does checking if xcode already exists (or whate
justincohen 2016/03/03 18:58:33 added.
justincohen 2016/03/03 18:58:33 re-added.
61 print 'Updating SDK to %s...' % PACKAGE_VERSION
62 if ReadStampFile() == PACKAGE_VERSION:
63 print 'SDK is already up to date.'
64 return 0
65
66 # Reset the stamp file in case the build is unsuccessful.
67 WriteStampFile('')
68
69 sdk_file = "%s.tgz" % PACKAGE_VERSION
70 sdk_full_url = SDK_URL + sdk_file
71
72 print 'Downloading mac SDK.'
73 if os.path.exists(SDK_BUILD_DIR):
74 shutil.rmtree(SDK_BUILD_DIR)
75 try:
76 sdk_file = "sdk-%s.tgz" % PACKAGE_VERSION
77 sdk_full_url = SDK_URL + sdk_file
78 DownloadAndUnpack(sdk_full_url, SDK_BUILD_DIR)
79 print 'SDK %s unpacked.' % PACKAGE_VERSION
80 WriteStampFile(PACKAGE_VERSION)
81
82 print 'Setting xcode-select'
justincohen 2016/03/03 01:24:54 This is wrong, as I still want to run xcode-select
justincohen 2016/03/03 18:58:33 Done.
83 subprocess.check_call(['/usr/bin/xcode-select', '-s', SDK_BUILD_DIR])
84
85 print 'Accepting license if necessary'
86 subprocess.check_call(['/usr/bin/xcodebuild', '-license', 'accept'])
87
88 return 0
89 except:
90 print 'Failed to download SDK %s.' % sdk_file
91 print 'Exiting.'
92 return 1
93
94 if __name__ == '__main__':
95 sys.exit(main())
OLDNEW
« third_party/mac_sdk/package.py ('K') | « third_party/mac_sdk/package.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698