aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-02-01 12:31:01 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-02-01 14:31:18 +0000
commit46d31b5f1e3201651bf621da2674ff2f070ce824 (patch)
treed261e304b25060d8891f14ce0a5823f3e13c5447 /tools
parentfe90b36498085142c40f2226a6a8f3798272bae6 (diff)
Windows, cc_configure: use BAZEL_SH, not cygpath
Use the BAZEL_SH envvar while creating the Windows CROSSTOOL file, instead of calling "cygpath -m /". The latter is based on the assumption that we are running under MSYS. Fixes https://github.com/bazelbuild/bazel/issues/2463 See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 146227581 MOS_MIGRATED_REVID=146227581
Diffstat (limited to 'tools')
-rw-r--r--tools/cpp/cc_configure.bzl17
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl
index 0ae4483492..f7eb191a7d 100644
--- a/tools/cpp/cc_configure.bzl
+++ b/tools/cpp/cc_configure.bzl
@@ -298,7 +298,22 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin):
# TODO(pcloudy): Remove this after MSVC CROSSTOOL becomes default on Windows
def _get_windows_crosstool_content(repository_ctx):
"""Return the content of msys crosstool which is still the default CROSSTOOL on Windows."""
- msys_root = _execute(repository_ctx, ["cygpath", "-m", "/"])
+ bazel_sh = _get_env_var(repository_ctx, "BAZEL_SH").replace("\\", "/").lower()
+ tokens = bazel_sh.rsplit("/", 1)
+ msys_root = None
+ # while-loops are not supported in order to avoid Turing-completeness.
+ # Use a for-loop, we know it'll halt in at most len(tokens[0]) steps.
+ for _ in range(len(tokens[0])):
+ if len(tokens) < 2:
+ break
+ if tokens[1].startswith("msys"):
+ msys_root = tokens[0] + "/" + tokens[1] + "/"
+ break
+ else:
+ tokens = tokens[0].rsplit("/", 1)
+ if not msys_root:
+ auto_configure_fail(
+ "Could not determine MSYS root from BAZEL_SH (%s)" % bazel_sh)
return (
' abi_version: "local"\n' +
' abi_libc_version: "local"\n' +