xref: /aosp_15_r20/external/bazel-skylib/docs/versions_doc.md (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2
3Skylib module containing functions for checking Bazel versions.
4
5<a id="versions.check"></a>
6
7## versions.check
8
9<pre>
10versions.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>)
11</pre>
12
13Check that the version of Bazel is valid within the specified range.
14
15**PARAMETERS**
16
17
18| Name  | Description | Default Value |
19| :------------- | :------------- | :------------- |
20| <a id="versions.check-minimum_bazel_version"></a>minimum_bazel_version |  minimum version of Bazel expected   |  none |
21| <a id="versions.check-maximum_bazel_version"></a>maximum_bazel_version |  maximum version of Bazel expected   |  `None` |
22| <a id="versions.check-bazel_version"></a>bazel_version |  the version of Bazel to check. Used for testing, defaults to native.bazel_version   |  `None` |
23
24
25<a id="versions.get"></a>
26
27## versions.get
28
29<pre>
30versions.get()
31</pre>
32
33Returns the current Bazel version
34
35
36
37<a id="versions.is_at_least"></a>
38
39## versions.is_at_least
40
41<pre>
42versions.is_at_least(<a href="#versions.is_at_least-threshold">threshold</a>, <a href="#versions.is_at_least-version">version</a>)
43</pre>
44
45Check that a version is higher or equals to a threshold.
46
47**PARAMETERS**
48
49
50| Name  | Description | Default Value |
51| :------------- | :------------- | :------------- |
52| <a id="versions.is_at_least-threshold"></a>threshold |  the minimum version string   |  none |
53| <a id="versions.is_at_least-version"></a>version |  the version string to be compared to the threshold   |  none |
54
55**RETURNS**
56
57True if version >= threshold.
58
59
60<a id="versions.is_at_most"></a>
61
62## versions.is_at_most
63
64<pre>
65versions.is_at_most(<a href="#versions.is_at_most-threshold">threshold</a>, <a href="#versions.is_at_most-version">version</a>)
66</pre>
67
68Check that a version is lower or equals to a threshold.
69
70**PARAMETERS**
71
72
73| Name  | Description | Default Value |
74| :------------- | :------------- | :------------- |
75| <a id="versions.is_at_most-threshold"></a>threshold |  the maximum version string   |  none |
76| <a id="versions.is_at_most-version"></a>version |  the version string to be compared to the threshold   |  none |
77
78**RETURNS**
79
80True if version <= threshold.
81
82
83<a id="versions.parse"></a>
84
85## versions.parse
86
87<pre>
88versions.parse(<a href="#versions.parse-bazel_version">bazel_version</a>)
89</pre>
90
91Parses a version string into a 3-tuple of ints
92
93int tuples can be compared directly using binary operators (<, >).
94
95For a development build of Bazel, this returns an unspecified version tuple
96that compares higher than any released version.
97
98
99**PARAMETERS**
100
101
102| Name  | Description | Default Value |
103| :------------- | :------------- | :------------- |
104| <a id="versions.parse-bazel_version"></a>bazel_version |  the Bazel version string   |  none |
105
106**RETURNS**
107
108An int 3-tuple of a (major, minor, patch) version.
109
110
111