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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« third_party/mac_sdk/package.py ('K') | « third_party/mac_sdk/package.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/mac_sdk/update.py
diff --git a/third_party/mac_sdk/update.py b/third_party/mac_sdk/update.py
new file mode 100755
index 0000000000000000000000000000000000000000..a36ae31a25748bed999bcc4e7b10b44c3db12e97
--- /dev/null
+++ b/third_party/mac_sdk/update.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 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.
+
+"""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.
+
+import os
+import shutil
+import subprocess
+import sys
+import tarfile
+import time
+import tempfile
+import urllib2
+
+SDK_REVISION = '7D152p'
+SDK_SUB_REVISION = 1
+PACKAGE_VERSION = "%s-%s" % (SDK_REVISION, SDK_SUB_REVISION)
+
+THIS_DIR = os.path.abspath(os.path.dirname(__file__))
+SDK_BUILD_DIR = os.path.join(THIS_DIR, 'Xcode.app')
+STAMP_FILE = os.path.join(SDK_BUILD_DIR, 'sdk_build_revision')
+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
+
+def ReadStampFile():
+ """Return the contents of the stamp file, or '' if it doesn't exist."""
+ try:
+ with open(STAMP_FILE, 'r') as f:
+ return f.read().rstrip()
+ except IOError:
+ return ''
+
+
+def WriteStampFile(s):
+ """Write s to the stamp file."""
+ EnsureDirExists(os.path.dirname(STAMP_FILE))
+ with open(STAMP_FILE, 'w') as f:
+ f.write(s)
+ f.write('\n')
+
+
+def EnsureDirExists(path):
+ if not os.path.exists(path):
+ print "Creating directory %s" % path
+ os.makedirs(path)
+
+
+def DownloadAndUnpack(url, output_dir):
+ 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.
+ subprocess.check_call(['gsutil.py', '--force-version', '4.15', '--', 'cp',
+ url, temp_name])
+ EnsureDirExists(output_dir)
+ print 'Unpacking SDK'
+ 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.
+ zipfile.ZipFile(temp_name).extractall(path=output_dir)
+ else:
+ tarfile.open(mode='r:gz', name=temp_name).extractall(path=output_dir)
+
+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.
+ print 'Updating SDK to %s...' % PACKAGE_VERSION
+ if ReadStampFile() == PACKAGE_VERSION:
+ print 'SDK is already up to date.'
+ return 0
+
+ # Reset the stamp file in case the build is unsuccessful.
+ WriteStampFile('')
+
+ sdk_file = "%s.tgz" % PACKAGE_VERSION
+ sdk_full_url = SDK_URL + sdk_file
+
+ print 'Downloading mac SDK.'
+ if os.path.exists(SDK_BUILD_DIR):
+ shutil.rmtree(SDK_BUILD_DIR)
+ try:
+ sdk_file = "sdk-%s.tgz" % PACKAGE_VERSION
+ sdk_full_url = SDK_URL + sdk_file
+ DownloadAndUnpack(sdk_full_url, SDK_BUILD_DIR)
+ print 'SDK %s unpacked.' % PACKAGE_VERSION
+ WriteStampFile(PACKAGE_VERSION)
+
+ 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.
+ subprocess.check_call(['/usr/bin/xcode-select', '-s', SDK_BUILD_DIR])
+
+ print 'Accepting license if necessary'
+ subprocess.check_call(['/usr/bin/xcodebuild', '-license', 'accept'])
+
+ return 0
+ except:
+ print 'Failed to download SDK %s.' % sdk_file
+ print 'Exiting.'
+ return 1
+
+if __name__ == '__main__':
+ sys.exit(main())
« 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