Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 """Windows can't run .sh files, so this is a Python implementation of | 6 """Windows can't run .sh files, so this is a Python implementation of |
| 7 update.sh. This script should replace update.sh on all platforms eventually.""" | 7 update.sh. This script should replace update.sh on all platforms eventually.""" |
| 8 | 8 |
| 9 import json | |
| 9 import os | 10 import os |
| 10 import re | 11 import re |
| 11 import shutil | 12 import shutil |
| 12 import subprocess | 13 import subprocess |
| 13 import sys | 14 import sys |
| 14 | 15 |
| 15 # Do NOT CHANGE this if you don't know what you're doing -- see | 16 # Do NOT CHANGE this if you don't know what you're doing -- see |
| 16 # https://code.google.com/p/chromium/wiki/UpdatingClang | 17 # https://code.google.com/p/chromium/wiki/UpdatingClang |
| 17 # Reverting problematic clang rolls is safe, though. | 18 # Reverting problematic clang rolls is safe, though. |
| 18 # Note: this revision is only used for Windows. Other platforms use update.sh. | 19 # Note: this revision is only used for Windows. Other platforms use update.sh. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 if os.path.isdir(d): | 130 if os.path.isdir(d): |
| 130 os.environ['PATH'] = os.environ.get('PATH', '') + os.pathsep + d | 131 os.environ['PATH'] = os.environ.get('PATH', '') + os.pathsep + d |
| 131 return | 132 return |
| 132 print 'Failed to find CMake!' | 133 print 'Failed to find CMake!' |
| 133 sys.exit(1) | 134 sys.exit(1) |
| 134 | 135 |
| 135 | 136 |
| 136 vs_version = None | 137 vs_version = None |
| 137 def GetVSVersion(): | 138 def GetVSVersion(): |
| 138 global vs_version | 139 global vs_version |
| 139 if not vs_version: | 140 if vs_version: |
| 140 # TODO(hans): Find a less hacky way to find the MSVS installation. | 141 return vs_version |
| 141 sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) | 142 |
| 142 import gyp.MSVSVersion | 143 # Try using the toolchain in depot_tools. |
| 143 # We request VS 2013 because Clang won't build with 2010, and 2013 will be | 144 json_data_file = os.path.join(CHROMIUM_DIR, 'build', 'win_toolchain.json') |
|
scottmg
2014/09/22 18:59:48
could you import vs_toolchain and call SetEnvironm
hans
2014/09/22 19:52:39
Done.
| |
| 144 # the default for Chromium soon anyway. | 145 if os.path.exists(json_data_file): |
| 145 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion('2013') | 146 with open(json_data_file, 'r') as tempf: |
| 147 toolchain_data = json.load(tempf) | |
| 148 # gyp's MSVSVersion will look at these environment variables. | |
| 149 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain_data['path'] | |
| 150 os.environ['GYP_MSVS_VERSION'] = toolchain_data['version'] | |
| 151 os.environ['WINDOWSSDKDIR'] = toolchain_data['win8sdk'] | |
| 152 | |
| 153 # Use gyp to find the MSVS installation, either in depot_tools as per above, | |
| 154 # or a system-wide installation otherwise. | |
| 155 sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) | |
| 156 import gyp.MSVSVersion | |
| 157 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion('2013') | |
| 146 return vs_version | 158 return vs_version |
| 147 | 159 |
| 148 | 160 |
| 149 def UpdateClang(): | 161 def UpdateClang(): |
| 150 print 'Updating Clang to %s...' % (LLVM_WIN_REVISION) | 162 print 'Updating Clang to %s...' % (LLVM_WIN_REVISION) |
| 151 if LLVM_WIN_REVISION != 'HEAD' and ReadStampFile() == LLVM_WIN_REVISION: | 163 if LLVM_WIN_REVISION != 'HEAD' and ReadStampFile() == LLVM_WIN_REVISION: |
| 152 print 'Already up to date.' | 164 print 'Already up to date.' |
| 153 return 0 | 165 return 0 |
| 154 | 166 |
| 155 AddCMakeToPath() | 167 AddCMakeToPath() |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 | 252 |
| 241 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): | 253 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): |
| 242 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' | 254 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' |
| 243 return 0 | 255 return 0 |
| 244 | 256 |
| 245 return UpdateClang() | 257 return UpdateClang() |
| 246 | 258 |
| 247 | 259 |
| 248 if __name__ == '__main__': | 260 if __name__ == '__main__': |
| 249 sys.exit(main()) | 261 sys.exit(main()) |
| OLD | NEW |