Chromium Code Reviews| Index: tools/clang/scripts/update.py |
| diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py |
| index af3df5aac680307b3721420e6e7a0e49d9a2958d..7bb3c1f7e7c02af76537fae186da90907b022e62 100755 |
| --- a/tools/clang/scripts/update.py |
| +++ b/tools/clang/scripts/update.py |
| @@ -6,6 +6,7 @@ |
| """Windows can't run .sh files, so this is a Python implementation of |
| update.sh. This script should replace update.sh on all platforms eventually.""" |
| +import json |
| import os |
| import re |
| import shutil |
| @@ -136,13 +137,24 @@ def AddCMakeToPath(): |
| vs_version = None |
| def GetVSVersion(): |
| global vs_version |
| - if not vs_version: |
| - # TODO(hans): Find a less hacky way to find the MSVS installation. |
| - sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) |
| - import gyp.MSVSVersion |
| - # We request VS 2013 because Clang won't build with 2010, and 2013 will be |
| - # the default for Chromium soon anyway. |
| - vs_version = gyp.MSVSVersion.SelectVisualStudioVersion('2013') |
| + if vs_version: |
| + return vs_version |
| + |
| + # Try using the toolchain in depot_tools. |
| + 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.
|
| + if os.path.exists(json_data_file): |
| + with open(json_data_file, 'r') as tempf: |
| + toolchain_data = json.load(tempf) |
| + # gyp's MSVSVersion will look at these environment variables. |
| + os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain_data['path'] |
| + os.environ['GYP_MSVS_VERSION'] = toolchain_data['version'] |
| + os.environ['WINDOWSSDKDIR'] = toolchain_data['win8sdk'] |
| + |
| + # Use gyp to find the MSVS installation, either in depot_tools as per above, |
| + # or a system-wide installation otherwise. |
| + sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) |
| + import gyp.MSVSVersion |
| + vs_version = gyp.MSVSVersion.SelectVisualStudioVersion('2013') |
| return vs_version |