bazel_features
v1.27.0
published 4 days ago
21 stars
18 forks
7 watchers
Apache License 2.0
public
1 assets
20,116,085 downloads
16 KB
Compatibility level unknown
LaCqzL1yWtYfTjXW117UIb9z7B3hZ0WLAP/s7zzXj20=
v1.27.0
March 27, 2025

Using Bzlmod with Bazel 6

  1. Enable with common --enable_bzlmod in .bazelrc.
  2. Add to your MODULE.bazel file:
bazel_dep(name = "bazel_features", version = "1.27.0")

Using WORKSPACE

Paste this snippet into your file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "bazel_features",
    sha256 = "2da0aaccbd725ad61f4e35d6d75ed421bf73ec1de167458b00ffecef3cd78f6d",
    strip_prefix = "bazel_features-1.27.0",
    url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.27.0/bazel_features-v1.27.0.tar.gz",
)
load("@bazel_features//:deps.bzl", "bazel_features_deps")
bazel_features_deps()

What's Changed

New Contributors

Full Changelog: https://github.com/bazel-contrib/bazel_features/compare/v1.26.0...v1.27.0

Deps:
Assets:

Bazel Features

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.

Accessing globals

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.