Currently, rules that require the CC toolchain via toolchain resolution use this syntax:
foo = rule(
...
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
)
(Possibly with other toolchain types present)
With optional toolchains, the syntax is changing, and will wait on a Bazel release.
We should provide a simple helper function that rules can use to be forward compatible when the new optional toolchains are release:
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "use_cpp_toolchain")
foo = rule(
...
toolchains = [other toolchains] + use_cpp_toolchain(mandatory = True),
)
The implemenation of use_cpp_toolchain will update with Bazel and will either return the bare-string toolchain type (as used currently) or the more complicated config.toolchain_type call. Rules won't need to make changes (beyond changing the value of mandatory if desired).
The only parameter will be mandatory, which will default to True for backwards compatibility.
Currently, rules that require the CC toolchain via toolchain resolution use this syntax:
(Possibly with other toolchain types present)
With optional toolchains, the syntax is changing, and will wait on a Bazel release.
We should provide a simple helper function that rules can use to be forward compatible when the new optional toolchains are release:
The implemenation of
use_cpp_toolchainwill update with Bazel and will either return the bare-string toolchain type (as used currently) or the more complicatedconfig.toolchain_typecall. Rules won't need to make changes (beyond changing the value ofmandatoryif desired).The only parameter will be
mandatory, which will default toTruefor backwards compatibility.