diff options
author | ulfjack <ulfjack@google.com> | 2018-04-25 08:51:31 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-25 08:53:14 -0700 |
commit | f0cd2d259833f3f8521b832051d425458ff316e9 (patch) | |
tree | b95ce7e3c5e814cb5860eb3daa1d074879484b59 /tools/cpp | |
parent | c122e47bd8386eb318ced9917d86e4c39378e222 (diff) |
Only print a warning if gcov cannot be found, not an error
We have some cases where clang is installed, but not gcc, and there is no convenience symlink for gcov to point to the corresponding clang tool. In this case, coverage won't work, but let's not error out. We can't tell here whether coverage is enabled or not.
Fixes #5066.
PiperOrigin-RevId: 194245346
Diffstat (limited to 'tools/cpp')
-rw-r--r-- | tools/cpp/unix_cc_configure.bzl | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl index b6dc67a9eb..e57d66d040 100644 --- a/tools/cpp/unix_cc_configure.bzl +++ b/tools/cpp/unix_cc_configure.bzl @@ -17,6 +17,8 @@ load( "@bazel_tools//tools/cpp:lib_cc_configure.bzl", + "auto_configure_warning", + "auto_configure_fail", "escape_string", "get_env_var", "split_escaped", @@ -384,7 +386,7 @@ def _coverage_feature(darwin): } """ -def _find_generic(repository_ctx, name, env_name, overriden_tools): +def _find_generic(repository_ctx, name, env_name, overriden_tools, warn = False): """Find a generic C++ toolchain tool. Doesn't %-escape the result.""" if name in overriden_tools: @@ -403,9 +405,12 @@ def _find_generic(repository_ctx, name, env_name, overriden_tools): return result result = repository_ctx.which(result) if result == None: - fail( - ("Cannot find %s or %s%s, either correct your path or set the %s" - + " environment variable") % (name, env_name, env_value_with_paren, env_name)) + msg = ("Cannot find %s or %s%s; either correct your path or set the %s" + + " environment variable") % (name, env_name, env_value_with_paren, env_name) + if warn: + auto_configure_warning(msg) + else: + auto_configure_fail(msg) return result def find_cc(repository_ctx, overriden_tools): @@ -419,7 +424,8 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): cc = _find_generic(repository_ctx, "gcc", "CC", overriden_tools) overriden_tools = dict(overriden_tools) overriden_tools["gcc"] = cc - overriden_tools["gcov"] = _find_generic(repository_ctx, "gcov", "GCOV", overriden_tools) + overriden_tools["gcov"] = _find_generic( + repository_ctx, "gcov", "GCOV", overriden_tools, warn = True) if darwin: overriden_tools["gcc"] = "cc_wrapper.sh" overriden_tools["ar"] = "/usr/bin/libtool" |