Skylib module containing functions for checking Bazel versions.

versions.check


load("@bazel_skylib//lib:versions.bzl", "versions") versions.check(<a href="#versions.check-minimum_bazel_version">minimum_bazel_version</a>, <a href="#versions.check-maximum_bazel_version">maximum_bazel_version</a>, <a href="#versions.check-bazel_version">bazel_version</a>)

Check that the version of Bazel is valid within the specified range.

PARAMETERS

NameDescriptionDefault Value
minimum_bazel_versionminimum version of Bazel expectednone
maximum_bazel_versionmaximum version of Bazel expectedNone
bazel_versionthe version of Bazel to check. Used for testing, defaults to native.bazel_versionNone

versions.get


load("@bazel_skylib//lib:versions.bzl", "versions") versions.get()

Returns the current Bazel version

versions.is_at_least


load("@bazel_skylib//lib:versions.bzl", "versions") versions.is_at_least(<a href="#versions.is_at_least-threshold">threshold</a>, <a href="#versions.is_at_least-version">version</a>)

Check that a version is higher or equals to a threshold.

PARAMETERS

NameDescriptionDefault Value
thresholdthe minimum version stringnone
versionthe version string to be compared to the thresholdnone

RETURNS

True if version >= threshold.

versions.is_at_most


load("@bazel_skylib//lib:versions.bzl", "versions") versions.is_at_most(<a href="#versions.is_at_most-threshold">threshold</a>, <a href="#versions.is_at_most-version">version</a>)

Check that a version is lower or equals to a threshold.

PARAMETERS

NameDescriptionDefault Value
thresholdthe maximum version stringnone
versionthe version string to be compared to the thresholdnone

RETURNS

True if version <= threshold.

versions.parse


load("@bazel_skylib//lib:versions.bzl", "versions") versions.parse(<a href="#versions.parse-bazel_version">bazel_version</a>)

Parses a version string into a 3-tuple of ints

int tuples can be compared directly using binary operators (<, >).

For a development build of Bazel, this returns an unspecified version tuple that compares higher than any released version.

PARAMETERS

NameDescriptionDefault Value
bazel_versionthe Bazel version stringnone

RETURNS

An int 3-tuple of a (major, minor, patch) version.