diff options
author | 2017-03-22 15:32:39 +0000 | |
---|---|---|
committer | 2017-03-23 09:47:16 +0000 | |
commit | 832548dd91747cf8cef360c7bcb5a5f1e5ecf28e (patch) | |
tree | 2819632ebce826c2ff731b7988a4a3aa3a262129 /tools | |
parent | 01eb89a6b6823dcbb0971ec9e3010c84a3318dc6 (diff) |
cc_configure: more generic msys_root discovery
See https://github.com/bazelbuild/bazel/issues/2725
Related to https://github.com/bazelbuild/bazel/issues/2447
--
Change-Id: I5cc7fba43ae46bc9ef47bcaf9efaf2a0b9911bc4
Reviewed-on: https://cr.bazel.build/9468
PiperOrigin-RevId: 150881196
MOS_MIGRATED_REVID=150881196
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cpp/cc_configure.bzl | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index 744e0ed249..eddf060253 100644 --- a/tools/cpp/cc_configure.bzl +++ b/tools/cpp/cc_configure.bzl @@ -306,19 +306,13 @@ def _get_windows_msys_crosstool_content(repository_ctx): 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 tokens[0].endswith("/usr/bin"): + msys_root = tokens[0][:len(tokens[0]) - len("usr/bin")] + elif tokens[0].endswith("/bin"): + msys_root = tokens[0][:len(tokens[0]) - len("bin")] if not msys_root: auto_configure_fail( - "Could not determine MSYS root from BAZEL_SH (%s)" % bazel_sh) + "Could not determine MSYS/Cygwin root from BAZEL_SH (%s)" % bazel_sh) return ( ' abi_version: "local"\n' + ' abi_libc_version: "local"\n' + |