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

Side by Side Diff: third_party/mac_sdk/package.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) 2016 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 """Compress and upload Xcode sdk files."""
7
8 import argparse
9 import glob
10 import os
11 import plistlib
12 import re
13 import subprocess
14 import sys
15 import tarfile
16 import tempfile
17
18
19 SDK_URL = "gs://chrome-mac-sdk"
20
21
22
23 EXCLUDE_FOLDERS = [
erikchen 2016/03/03 01:45:47 This will need to be manually updated with each ro
justincohen 2016/03/03 18:58:33 Added a comment explaining. /Platforms!MacOsx giv
24 'Contents/Applications',
25 'Contents/Developer/Documentation',
26 'Contents/Developer/Platforms/AppleTVOS.platform',
27 'Contents/Developer/Platforms/AppleTVSimulator.platform',
28 'Contents/Developer/Platforms/WatchOS.platform',
29 'Contents/Developer/Platforms/WatchSimulator.platform',
30 'Contents/Developer/Platforms/iPhoneOS.platform',
31 'Contents/Developer/Platforms/iPhoneSimulator.platform',
32 'Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator',
33 'Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift',
34 'Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr /share/man',
35 'Contents/Developer/Library/Xcode/Templates'
36 ]
37
38 def PrintTarProgress(tarinfo):
39 print 'Adding', tarinfo.name
erikchen 2016/03/03 01:45:47 I'm not a python guru, but I think it's good pract
justincohen 2016/03/03 18:58:33 Removed.
40 return tarinfo
41
42
43 def main():
44 parser = argparse.ArgumentParser()
45 parser.add_argument('target_dir',
46 help="Xcode installation contents directory.")
47 parser.add_argument('args', nargs='*', help="run ibtool command")
48 args = parser.parse_args()
49
50 contents_dir = os.path.join(args.target_dir, 'Contents')
51 plist_file = os.path.join(contents_dir, 'version.plist')
52 try:
53 info = plistlib.readPlist(plist_file)
54 except:
55 print "Invalid Xcode contents dir."
56 return 0
57 build_version = info['ProductBuildVersion']
58
59 p = subprocess.Popen(['gsutil.py', '--force-version', '4.15', '--', 'ls',
erikchen 2016/03/03 01:45:46 why --force-version?
justincohen 2016/03/03 18:58:33 Removed.
60 '%s/sdk-%s-*.tgz' % (SDK_URL, build_version)],
61 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
62
63 output = p.communicate()[0]
64 next_count = 1
65 if p.returncode == 0:
66 next_count = len(output.split('\n'))
67 sys.stdout.write("%s already exists %s times. "
68 "Do you want to create another? [y/n] "
69 % (build_version, next_count - 1))
70
71 if raw_input().lower() not in set(['yes','y', 'ye']):
72 print "Skipping additional upload."
73 return 0
74
75 os.chdir(args.target_dir)
76 sdk_file_name = "sdk-%s-%s" % (build_version, next_count)
77 sdk_name = tempfile.mktemp(suffix='sdk.tgz')
erikchen 2016/03/03 01:45:47 caller is responsible for cleaning up directory af
justincohen 2016/03/03 18:58:33 Done.
78 print "Creating %s (%s)." % (sdk_file_name, sdk_name)
79 os.environ["COPYFILE_DISABLE"] = "1"
80 args = ['tar', '-cvpzf', sdk_name]
erikchen 2016/03/03 01:45:47 preserve permissions? How does that work when you
justincohen 2016/03/03 18:58:33 Removed 'p'
81 args.extend(map('--exclude={0}'.format, EXCLUDE_FOLDERS))
82 args.extend(['.'])
83 subprocess.check_call(args)
84
85 print "Uploading %s SDK." % sdk_file_name
86 subprocess.check_call(['gsutil.py', '--force-version', '4.15', '--', 'cp',
87 '-n', '-a', 'public-read', sdk_name,
88 '%s/%s.tgz' % (SDK_URL, sdk_file_name)])
89 print "Done with %s upload." % sdk_file_name
90 return 0
91
92 if __name__ == '__main__':
93 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698