bazel_features
v1.20.0
published 4 weeks ago
19 stars
15 forks
7 watchers
Apache License 2.0
public
1 assets
14,779,659 downloads
15 KB
Compatability level unknown
wllplM9jUTvUQYBBGkrDrpXTK/WRSPy2CHpGQrP/7xE=
v1.20.0
October 25, 2024

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.20.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 = "c2596994cf63513bd44180411a4ac3ae95d32bf59148fcb6087a4642b3ffef11",
    strip_prefix = "bazel_features-1.20.0",
    url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.20.0/bazel_features-v1.20.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.19.0...v1.20.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.