Skip to content

Commit e79b2a9

Browse files
authored
Add Documentation for Supported Bazel Versions (grpc#29191)
* Create Bazel support range docs * Review comments * Move supported versions file
1 parent bf72db4 commit e79b2a9

13 files changed

+176
-6
lines changed

bazel/supported_versions.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
5.0.0
2+
4.2.2
3+
3.7.2

doc/bazel_support.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Bazel Support
2+
3+
## Basic Usage
4+
5+
The `grpc/grpc` repository's primary build system is Bazel. Rules are provided
6+
for C++, Python, and Objective-C. While C++ supports other build systems such as
7+
CMake, these rules are actually generated from the Bazel definitions.
8+
9+
Projects built with Bazel may use the `grpc/grpc` repo not only to add a
10+
dependency on the library itself, but also to generate protobuf, stub, and
11+
servicer code. To do so, one must invoke the `grpc_deps` and `grpc_extra_deps`
12+
repository rules in their `WORKSPACE` file:
13+
14+
```starlark
15+
workspace(name = "example_workspace")
16+
17+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18+
19+
http_archive(
20+
name = "com_github_grpc_grpc",
21+
strip_prefix = "grpc-1.45.0",
22+
sha256 = "ec19657a677d49af59aa806ec299c070c882986c9fcc022b1c22c2a3caf01bcd"k
23+
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.45.0.tar.gz"],
24+
)
25+
26+
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
27+
28+
grpc_deps()
29+
30+
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
31+
32+
grpc_extra_deps()
33+
```
34+
35+
## Supported Versions
36+
37+
In general, gRPC supports building with the latest patch release of the most
38+
recent two major versions of Bazel. However individual releases may have a
39+
broader compatibility range. The currently supported versions are captured by
40+
the following list:
41+
42+
- [`5.0.0`](https://github.com/bazelbuild/bazel/releases/tag/5.0.0)
43+
- [`4.2.2`](https://github.com/bazelbuild/bazel/releases/tag/4.2.2)
44+
- [`3.7.2`](https://github.com/bazelbuild/bazel/releases/tag/3.7.2)
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
%YAML 1.2
2+
--- |
3+
# Bazel Support
4+
5+
${ '##' } Basic Usage
6+
7+
The `grpc/grpc` repository's primary build system is Bazel. Rules are provided
8+
for C++, Python, and Objective-C. While C++ supports other build systems such as
9+
CMake, these rules are actually generated from the Bazel definitions.
10+
11+
Projects built with Bazel may use the `grpc/grpc` repo not only to add a
12+
dependency on the library itself, but also to generate protobuf, stub, and
13+
servicer code. To do so, one must invoke the `grpc_deps` and `grpc_extra_deps`
14+
repository rules in their `WORKSPACE` file:
15+
16+
```starlark
17+
workspace(name = "example_workspace")
18+
19+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
20+
21+
http_archive(
22+
name = "com_github_grpc_grpc",
23+
strip_prefix = "grpc-1.45.0",
24+
sha256 = "ec19657a677d49af59aa806ec299c070c882986c9fcc022b1c22c2a3caf01bcd"k
25+
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.45.0.tar.gz"],
26+
)
27+
28+
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
29+
30+
grpc_deps()
31+
32+
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
33+
34+
grpc_extra_deps()
35+
```
36+
37+
${ '##' } Supported Versions
38+
39+
In general, gRPC supports building with the latest patch release of the most
40+
recent two major versions of Bazel. However individual releases may have a
41+
broader compatibility range. The currently supported versions are captured by
42+
the following list:
43+
44+
% for version in supported_bazel_versions:
45+
- [`${version}`](https://github.com/bazelbuild/bazel/releases/tag/${version})
46+
% endfor

test/distrib/bazel/run_bazel_distrib_test.sh

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@ set -ex
1818
cd "$(dirname "$0")"
1919

2020
# TODO(jtattermusch): make build work with bazel 2.2.0 and bazel 1.2.1 if that's reasonably simple.
21-
SUPPORTED_VERSIONS=(
22-
"3.7.2"
23-
"4.0.0"
24-
"5.0.0"
25-
)
21+
VERSIONS=$(cat ../../../bazel/supported_versions.txt)
2622

2723
FAILED_VERSIONS=""
28-
for VERSION in "${SUPPORTED_VERSIONS[@]}"; do
24+
for VERSION in $VERSIONS; do
2925
echo "Running bazel distribtest with bazel version ${VERSION}"
3026
./test_single_bazel_version.sh "${VERSION}" || FAILED_VERSIONS="${FAILED_VERSIONS}${VERSION} "
3127
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2022 The gRPC authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Retrieves supported bazel versions from plaintext file."""
15+
16+
_SUPPORTED_VERSIONS_FILE = "bazel/supported_versions.txt"
17+
18+
19+
def _get_supported_bazel_versions():
20+
versions = []
21+
with open(_SUPPORTED_VERSIONS_FILE, "r") as f:
22+
for line in f:
23+
versions.append(line.strip())
24+
return versions
25+
26+
27+
def mako_plugin(dictionary):
28+
dictionary["supported_bazel_versions"] = _get_supported_bazel_versions()

tools/doxygen/Doxyfile.c++

+1
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ WARN_LOGFILE =
762762
763763
INPUT = doc/PROTOCOL-HTTP2.md \
764764
doc/PROTOCOL-WEB.md \
765+
doc/bazel_support.md \
765766
doc/binary-logging.md \
766767
doc/c-style-guide.md \
767768
doc/command_line_tool.md \

tools/doxygen/Doxyfile.c++.internal

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/doxygen/Doxyfile.core

+1
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ WARN_LOGFILE =
762762

763763
INPUT = doc/PROTOCOL-HTTP2.md \
764764
doc/PROTOCOL-WEB.md \
765+
doc/bazel_support.md \
765766
doc/binary-logging.md \
766767
doc/c-style-guide.md \
767768
doc/command_line_tool.md \

tools/doxygen/Doxyfile.core.internal

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/doxygen/Doxyfile.objc

+1
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ WARN_LOGFILE =
762762

763763
INPUT = doc/PROTOCOL-HTTP2.md \
764764
doc/PROTOCOL-WEB.md \
765+
doc/bazel_support.md \
765766
doc/binary-logging.md \
766767
doc/c-style-guide.md \
767768
doc/command_line_tool.md \

tools/doxygen/Doxyfile.objc.internal

+1
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ WARN_LOGFILE =
762762

763763
INPUT = doc/PROTOCOL-HTTP2.md \
764764
doc/PROTOCOL-WEB.md \
765+
doc/bazel_support.md \
765766
doc/binary-logging.md \
766767
doc/c-style-guide.md \
767768
doc/command_line_tool.md \

tools/doxygen/Doxyfile.php

+1
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@
762762

763763
INPUT = doc/PROTOCOL-HTTP2.md \
764764
doc/PROTOCOL-WEB.md \
765+
doc/bazel_support.md \
765766
doc/binary-logging.md \
766767
doc/c-style-guide.md \
767768
doc/command_line_tool.md \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
#Copyright 2022 The gRPC authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# This script can be used to manually update the specific versions of Bazel
17+
# tested by the Bazel distribtests and advertised as supported in documentation.
18+
# This will update the supported_versions.txt file, which will be templated into
19+
# the bazel_support.md document.
20+
21+
# This script selects the latest patch release of the two most recent major
22+
# versions of Bazel. If you want to include other versions in the set of
23+
# supported versions, then you will need to manually edit the ifle.
24+
25+
set -xeuo pipefail
26+
27+
cd "$(dirname "$0")/../.."
28+
29+
# The number of most recent supported major Bazel versions.
30+
SUPPORT_RANGE="2"
31+
32+
# Retrieve all git tags from the Bazel git repo.
33+
TAGS=$(git ls-remote --tags [email protected]:bazelbuild/bazel.git | awk '{print $2;}' | sed 's|refs/tags/||g')
34+
35+
# Find the n most recent major versions.
36+
MAJOR_VERSIONS=$(echo "$TAGS" | egrep '^[0-9]+\.[0-9]+\.[0-9]+$' | cut -d'.' -f1 | sort -r | uniq | head -n"$SUPPORT_RANGE")
37+
38+
SUPPORTED_VERSIONS=""
39+
40+
# For each major version selected, find the most recent patch release.
41+
while read -r MAJOR_VERSION; do
42+
LATEST_PATCH=$(echo "$TAGS" | egrep "^${MAJOR_VERSION}\.[0-9]+\.[0-9]+$" | sort -nr | head -n1)
43+
SUPPORTED_VERSIONS="$SUPPORTED_VERSIONS$LATEST_PATCH\n"
44+
done<<<"$MAJOR_VERSIONS"
45+
46+
printf "$SUPPORTED_VERSIONS" | tee bazel/supported_versions.txt

0 commit comments

Comments
 (0)