Chromium Code Reviews| 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 """Download necessary mac toolchain files under certain conditions. If | 6 """Download necessary mac toolchain files under certain conditions. If |
| 7 xcode-select is already set and points to an external folder | 7 xcode-select is already set and points to an external folder |
| 8 (e.g. /Application/Xcode.app), this script only runs if the GYP_DEFINE | 8 (e.g. /Application/Xcode.app), this script only runs if the GYP_DEFINE |
| 9 |force_mac_toolchain| is set. To override the values in | 9 |force_mac_toolchain| is set. To override the values in |
| 10 |TOOLCHAIN_REVISION|-|TOOLCHAIN_SUB_REVISION| below, GYP_DEFINE | 10 |TOOLCHAIN_REVISION|-|TOOLCHAIN_SUB_REVISION| below, GYP_DEFINE |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 def CanAccessToolchainBucket(): | 93 def CanAccessToolchainBucket(): |
| 94 """Checks whether the user has access to |TOOLCHAIN_URL|.""" | 94 """Checks whether the user has access to |TOOLCHAIN_URL|.""" |
| 95 proc = subprocess.Popen(['gsutil.py', 'ls', TOOLCHAIN_URL], | 95 proc = subprocess.Popen(['gsutil.py', 'ls', TOOLCHAIN_URL], |
| 96 stdout=subprocess.PIPE) | 96 stdout=subprocess.PIPE) |
| 97 proc.communicate() | 97 proc.communicate() |
| 98 return proc.returncode == 0 | 98 return proc.returncode == 0 |
| 99 | 99 |
| 100 | 100 |
| 101 def AcceptLicense(directory): | 101 def AcceptLicense(directory): |
| 102 """Use xcodebuild to accept new toolchain license. This only | 102 """Use xcodebuild to accept new toolchain license. This only |
| 103 works if xcodebuild and xcode-select are in sudoers.""" | 103 works if xcodebuild and xcode-select are passwordless in sudoers.""" |
| 104 xcodebuild_dir = os.path.join(TOOLCHAIN_BUILD_DIR, 'Contents/Developer') | 104 build_dir = os.path.join(TOOLCHAIN_BUILD_DIR, 'Contents/Developer') |
| 105 old_path = subprocess.Popen(['/usr/bin/xcode-select', '-p'], | 105 old_path = subprocess.Popen(['/usr/bin/xcode-select', '-p'], |
| 106 stdout=subprocess.PIPE).communicate()[0].strip() | 106 stdout=subprocess.PIPE).communicate()[0].strip() |
| 107 subprocess.check_call(['sudo', '/usr/bin/xcode-select', '-s', xcodebuild_dir]) | 107 try: |
| 108 subprocess.check_call(['sudo', '/usr/bin/xcodebuild', '-license', 'accept']) | 108 subprocess.check_call(['sudo', '/usr/bin/xcode-select', '-s', build_dir]) |
| 109 subprocess.check_call(['sudo', '/usr/bin/xcode-select', '-s', old_path]) | 109 subprocess.check_call(['sudo', '/usr/bin/xcodebuild', '-license', 'accept']) |
| 110 finally: | |
| 111 # Normally accepting a toolchain license doesn't unaccept the other | |
| 112 # toolchain license. However, something about using passwordless sudo seems | |
| 113 # to do just that. Re-accept the |old_path| toolchain just incase. | |
|
erikchen
2016/05/08 17:56:26
accepting the old license doesn't unaccept the new
| |
| 114 subprocess.check_call(['sudo', '/usr/bin/xcode-select', '-s', old_path]) | |
| 115 subprocess.check_call(['sudo', '/usr/bin/xcodebuild', '-license', 'accept']) | |
| 110 | 116 |
| 111 | 117 |
| 112 def UseLocalMacSDK(): | 118 def UseLocalMacSDK(): |
| 113 force_pull = os.environ.has_key('FORCE_MAC_TOOLCHAIN') | 119 force_pull = os.environ.has_key('FORCE_MAC_TOOLCHAIN') |
| 114 | 120 |
| 115 # Don't update the toolchain if there's already one installed outside of the | 121 # Don't update the toolchain if there's already one installed outside of the |
| 116 # expected location for a Chromium mac toolchain, unless |force_pull| is set. | 122 # expected location for a Chromium mac toolchain, unless |force_pull| is set. |
| 117 proc = subprocess.Popen(['xcode-select', '-p'], stdout=subprocess.PIPE) | 123 proc = subprocess.Popen(['xcode-select', '-p'], stdout=subprocess.PIPE) |
| 118 xcode_select_dir = proc.communicate()[0] | 124 xcode_select_dir = proc.communicate()[0] |
| 119 rc = proc.returncode | 125 rc = proc.returncode |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 print 'Toolchain %s unpacked.' % toolchain_revision | 163 print 'Toolchain %s unpacked.' % toolchain_revision |
| 158 WriteStampFile(toolchain_revision) | 164 WriteStampFile(toolchain_revision) |
| 159 return 0 | 165 return 0 |
| 160 except: | 166 except: |
| 161 print 'Failed to download toolchain %s.' % toolchain_file | 167 print 'Failed to download toolchain %s.' % toolchain_file |
| 162 print 'Exiting.' | 168 print 'Exiting.' |
| 163 return 1 | 169 return 1 |
| 164 | 170 |
| 165 if __name__ == '__main__': | 171 if __name__ == '__main__': |
| 166 sys.exit(main()) | 172 sys.exit(main()) |
| OLD | NEW |