Permit toggling the toolchain type migrations with --repo_env (#168) The value for the toolchain migration features now comes from the `BAZEL_INCOMPATIBLE_TOOLCHAIN_TYPES_IN_RULES` environment variable, which can be set with `--repo_env` and defaults to `0` for now. The default will be flipped based on the Bazel version, with the variable remaining available as an escape hatch, e.g. for testing development builds of Bazel or if the migration turns out to be more breaking than expected. The value is recorded in the existing `bazel_features_version` repo, which now also reruns when the variable changes.
Use this to determine the availability of a Bazel feature in your ruleset. It works under the hood by comparing the Bazel version against a known range in which the feature is available. Example usage:
load("@bazel_features//:features.bzl", "bazel_features") if bazel_features.toolchains.has_optional_toolchains: # Do something
The features.bzl file contains the list of features.
References to global Starlark symbols that do not exist cause load time errors, which means that their availability in Bazel cannot be tested via a regular feature. Instead, use bazel_features.globals.<symbol>, which is <symbol> if the symbol is available and None else.
See globals.bzl for the list of symbols that can be checked for in this way.