bazel-contrib / bazel_features

Support Bazel "feature detection" from starlark

Home Page:https://docs.google.com/document/d/1HJf3gMYIrzmTRqbD4nWXH2eJRHXjLrOU0mmIeZplUzY/edit#heading=h.5mcn15i0e1ch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Support Bazel "feature detection" from starlark

https://docs.google.com/document/d/1HJf3gMYIrzmTRqbD4nWXH2eJRHXjLrOU0mmIeZplUzY/edit#heading=h.5mcn15i0e1ch

License:Apache License 2.0


Languages

Language:Starlark 100.0%