OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 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 """ | 6 """ |
7 If should_use_hermetic_xcode.py emits "1", and the current toolchain is out of | 7 If should_use_hermetic_xcode.py emits "1", and the current toolchain is out of |
8 date: | 8 date: |
9 * Downloads the hermetic mac toolchain | 9 * Downloads the hermetic mac toolchain |
10 * Requires gsutil to be configured. | 10 * Requires gsutil to be configured. |
11 * Accepts the license. | 11 * Accepts the license. |
12 * If xcode-select and xcodebuild are not passwordless in sudoers, requires | 12 * If xcode-select and xcodebuild are not passwordless in sudoers, requires |
13 user interaction. | 13 user interaction. |
14 """ | 14 """ |
15 | 15 |
16 import os | 16 import os |
17 import platform | |
18 import plistlib | 17 import plistlib |
19 import shutil | 18 import shutil |
20 import subprocess | 19 import subprocess |
21 import sys | 20 import sys |
22 import tarfile | 21 import tarfile |
23 import time | 22 import time |
24 import tempfile | 23 import tempfile |
25 import urllib2 | 24 import urllib2 |
26 | 25 |
27 # This can be changed after running /build/package_mac_toolchain.py. | 26 # This can be changed after running /build/package_mac_toolchain.py. |
28 MAC_TOOLCHAIN_VERSION = '8E2002' | 27 MAC_TOOLCHAIN_VERSION = '5B1008' |
29 MAC_TOOLCHAIN_SUB_REVISION = 3 | 28 MAC_TOOLCHAIN_SUB_REVISION = 3 |
30 MAC_TOOLCHAIN_VERSION = '%s-%s' % (MAC_TOOLCHAIN_VERSION, | 29 MAC_TOOLCHAIN_VERSION = '%s-%s' % (MAC_TOOLCHAIN_VERSION, |
31 MAC_TOOLCHAIN_SUB_REVISION) | 30 MAC_TOOLCHAIN_SUB_REVISION) |
32 # The toolchain will not be downloaded if the minimum OS version is not met. | |
33 # 16 is the major version number for macOS 10.12. | |
34 MAC_MINIMUM_OS_VERSION = 16 | |
35 | |
36 IOS_TOOLCHAIN_VERSION = '8C1002' | 31 IOS_TOOLCHAIN_VERSION = '8C1002' |
37 IOS_TOOLCHAIN_SUB_REVISION = 1 | 32 IOS_TOOLCHAIN_SUB_REVISION = 1 |
38 IOS_TOOLCHAIN_VERSION = '%s-%s' % (IOS_TOOLCHAIN_VERSION, | 33 IOS_TOOLCHAIN_VERSION = '%s-%s' % (IOS_TOOLCHAIN_VERSION, |
39 IOS_TOOLCHAIN_SUB_REVISION) | 34 IOS_TOOLCHAIN_SUB_REVISION) |
40 | 35 |
41 # Absolute path to src/ directory. | 36 # Absolute path to src/ directory. |
42 REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 37 REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
43 | 38 |
44 # Absolute path to a file with gclient solutions. | 39 # Absolute path to a file with gclient solutions. |
45 GCLIENT_CONFIG = os.path.join(os.path.dirname(REPO_ROOT), '.gclient') | 40 GCLIENT_CONFIG = os.path.join(os.path.dirname(REPO_ROOT), '.gclient') |
46 | 41 |
47 BASE_DIR = os.path.abspath(os.path.dirname(__file__)) | 42 BASE_DIR = os.path.abspath(os.path.dirname(__file__)) |
48 TOOLCHAIN_BUILD_DIR = os.path.join(BASE_DIR, '%s_files', 'Xcode.app') | 43 TOOLCHAIN_BUILD_DIR = os.path.join(BASE_DIR, '%s_files', 'Xcode.app') |
49 STAMP_FILE = os.path.join(BASE_DIR, '%s_files', 'toolchain_build_revision') | 44 STAMP_FILE = os.path.join(BASE_DIR, '%s_files', 'toolchain_build_revision') |
50 TOOLCHAIN_URL = 'gs://chrome-mac-sdk/' | 45 TOOLCHAIN_URL = 'gs://chrome-mac-sdk/' |
51 | 46 |
52 | |
53 def PlatformMeetsHermeticXcodeRequirements(target_os): | |
54 if target_os == 'ios': | |
55 return True | |
56 return int(platform.release().split('.')[0]) >= MAC_MINIMUM_OS_VERSION | |
57 | |
58 | |
59 def GetPlatforms(): | 47 def GetPlatforms(): |
60 default_target_os = ["mac"] | 48 default_target_os = ["mac"] |
61 try: | 49 try: |
62 env = {} | 50 env = {} |
63 execfile(GCLIENT_CONFIG, env, env) | 51 execfile(GCLIENT_CONFIG, env, env) |
64 return env.get('target_os', default_target_os) | 52 return env.get('target_os', default_target_os) |
65 except: | 53 except: |
66 pass | 54 pass |
67 return default_target_os | 55 return default_target_os |
68 | 56 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 print 'Exception %s' % e | 225 print 'Exception %s' % e |
238 print 'Exiting.' | 226 print 'Exiting.' |
239 return 1 | 227 return 1 |
240 | 228 |
241 | 229 |
242 def main(): | 230 def main(): |
243 if sys.platform != 'darwin': | 231 if sys.platform != 'darwin': |
244 return 0 | 232 return 0 |
245 | 233 |
246 for target_os in GetPlatforms(): | 234 for target_os in GetPlatforms(): |
247 if not PlatformMeetsHermeticXcodeRequirements(target_os): | |
248 print 'OS version does not support toolchain.' | |
249 continue | |
250 | |
251 if target_os == 'ios': | 235 if target_os == 'ios': |
252 default_version = IOS_TOOLCHAIN_VERSION | 236 default_version = IOS_TOOLCHAIN_VERSION |
253 toolchain_filename = 'ios-toolchain-%s.tgz' | 237 toolchain_filename = 'ios-toolchain-%s.tgz' |
254 else: | 238 else: |
255 default_version = MAC_TOOLCHAIN_VERSION | 239 default_version = MAC_TOOLCHAIN_VERSION |
256 toolchain_filename = 'toolchain-%s.tgz' | 240 toolchain_filename = 'toolchain-%s.tgz' |
257 | 241 |
258 return_value = DownloadHermeticBuild( | 242 return_value = DownloadHermeticBuild( |
259 target_os, default_version, toolchain_filename) | 243 target_os, default_version, toolchain_filename) |
260 if return_value: | 244 if return_value: |
261 return return_value | 245 return return_value |
262 | 246 |
263 return 0 | 247 return 0 |
264 | 248 |
265 | 249 |
266 if __name__ == '__main__': | 250 if __name__ == '__main__': |
267 sys.exit(main()) | 251 sys.exit(main()) |
OLD | NEW |