diff options
author | juliexxia <juliexxia@google.com> | 2018-07-10 08:02:39 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-10 08:05:21 -0700 |
commit | 45f1da197a7fa8f91efca99315432d6d97a88ccd (patch) | |
tree | d09def61df3b4861600d5995ba16401abda51e81 /tools | |
parent | ba76255ea973d22c3cf5456eda93d301ed4b4626 (diff) |
When using find_cpp_toolchain, make sure the relevant attribute, '_cc_toolchain' exists on the ctx being passed to this function. (I broke TAP once because I forgot to add the attribute. Perhaps not that helpful this late in the migration but doesn't hurt.)
RELNOTES: None.
PiperOrigin-RevId: 203947282
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cpp/toolchain_utils.bzl | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/cpp/toolchain_utils.bzl b/tools/cpp/toolchain_utils.bzl index e879299cd1..be6f665877 100644 --- a/tools/cpp/toolchain_utils.bzl +++ b/tools/cpp/toolchain_utils.bzl @@ -33,6 +33,8 @@ def find_cpp_toolchain(ctx): Returns: A CcToolchainProvider. """ + if not hasattr(ctx.attr, "_cc_toolchain"): + fail("In order to use find_cpp_toolchain, you must define the '_cc_toolchain' attribute on your rule or aspect.") if Label("@bazel_tools//tools/cpp:toolchain_type") in ctx.fragments.platform.enabled_toolchain_types: return ctx.toolchains["@bazel_tools//tools/cpp:toolchain_type"] |