Skip to content

Commit

Permalink
Add support for Visual Studio 2017 in cc_configure auto-detection and…
Browse files Browse the repository at this point in the history
… our Python tests.

RELNOTES: None.

Change-Id: I76c4f11323b1c0690e20d54f129abd671275acb0
PiperOrigin-RevId: 161934858
  • Loading branch information
philwo authored and laszlocsomor committed Jul 14, 2017
1 parent ddc180a commit ecb15d3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
14 changes: 9 additions & 5 deletions src/test/py/bazel/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,16 @@ def _Visit(result, _, names):
'BAZEL_SH': 'c:\\tools\\msys64\\usr\\bin\\bash.exe',
# TODO(pcloudy): Remove this after no longer need to debug
# https://github.com/bazelbuild/bazel/issues/3273
'CC_CONFIGURE_DEBUG': '1',
# TODO(pcloudy): Remove this hardcoded path after resolving
# https://github.com/bazelbuild/bazel/issues/3273
'BAZEL_VC':
'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC',
'CC_CONFIGURE_DEBUG': '1'
}

# TODO(pcloudy): Remove this hardcoded path after resolving
# https://github.com/bazelbuild/bazel/issues/3273
vc_path = (r'C:\Program Files (x86)\Microsoft Visual '
r'Studio\2017\Professional\VC')
if not os.path.exists(vc_path):
vc_path = r'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC'
env['BAZEL_VC'] = vc_path
else:
env = {'HOME': os.path.join(self._temp, 'home')}

Expand Down
27 changes: 14 additions & 13 deletions tools/cpp/windows_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,19 @@ def _find_vc_path(repository_ctx):
auto_configure_warning("Looking for Visual C++ through registry")
reg_binary = _get_system_root(repository_ctx) + "\\system32\\reg.exe"
vc_dir = None
for version in ["15.0", "14.0", "12.0", "11.0", "10.0", "9.0", "8.0"]:
if vc_dir:
break
result = repository_ctx.execute([reg_binary, "query", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7", "/v", version])
if is_cc_configure_debug(repository_ctx):
auto_configure_warning("registry query result for VC %s:\n\nSTDOUT(start)\n%s\nSTDOUT(end)\nSTDERR(start):\n%s\nSTDERR(end)\n" %
(version, result.stdout, result.stderr))
if not result.stderr:
for line in result.stdout.split("\n"):
line = line.strip()
if line.startswith(version) and line.find("REG_SZ") != -1:
vc_dir = line[line.find("REG_SZ") + len("REG_SZ"):].strip()
for key, suffix in (("VC7", ""), ("VS7", "\\VC")):
for version in ["15.0", "14.0", "12.0", "11.0", "10.0", "9.0", "8.0"]:
if vc_dir:
break
result = repository_ctx.execute([reg_binary, "query", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\" + key, "/v", version])
if is_cc_configure_debug(repository_ctx):
auto_configure_warning("registry query result for VC %s:\n\nSTDOUT(start)\n%s\nSTDOUT(end)\nSTDERR(start):\n%s\nSTDERR(end)\n" %
(version, result.stdout, result.stderr))
if not result.stderr:
for line in result.stdout.split("\n"):
line = line.strip()
if line.startswith(version) and line.find("REG_SZ") != -1:
vc_dir = line[line.find("REG_SZ") + len("REG_SZ"):].strip() + suffix

if not vc_dir:
auto_configure_fail("Visual C++ build tools not found on your machine.")
Expand All @@ -183,7 +184,7 @@ def _find_vcvarsall_bat_script(repository_ctx, vc_path):
vcvarsall = vc_path + "\\VCVARSALL.BAT"

if not repository_ctx.path(vcvarsall).exists:
auto_configure_fail("vcvarsall.bat doesn't exist, please check your VC++ installation")
auto_configure_fail(vcvarsall + " doesn't exist, please check your VC++ installation")
return vcvarsall


Expand Down

0 comments on commit ecb15d3

Please sign in to comment.