mirror of https://github.com/grpc/grpc.git
Add Documentation for Supported Bazel Versions (#29191)
* Create Bazel support range docs * Review comments * Move supported versions filepull/29226/head
parent
bf72db4180
commit
e79b2a9b32
13 changed files with 176 additions and 6 deletions
@ -0,0 +1,3 @@ |
||||
5.0.0 |
||||
4.2.2 |
||||
3.7.2 |
@ -0,0 +1,44 @@ |
||||
# Bazel Support |
||||
|
||||
## Basic Usage |
||||
|
||||
The `grpc/grpc` repository's primary build system is Bazel. Rules are provided |
||||
for C++, Python, and Objective-C. While C++ supports other build systems such as |
||||
CMake, these rules are actually generated from the Bazel definitions. |
||||
|
||||
Projects built with Bazel may use the `grpc/grpc` repo not only to add a |
||||
dependency on the library itself, but also to generate protobuf, stub, and |
||||
servicer code. To do so, one must invoke the `grpc_deps` and `grpc_extra_deps` |
||||
repository rules in their `WORKSPACE` file: |
||||
|
||||
```starlark |
||||
workspace(name = "example_workspace") |
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
||||
|
||||
http_archive( |
||||
name = "com_github_grpc_grpc", |
||||
strip_prefix = "grpc-1.45.0", |
||||
sha256 = "ec19657a677d49af59aa806ec299c070c882986c9fcc022b1c22c2a3caf01bcd"k |
||||
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.45.0.tar.gz"], |
||||
) |
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") |
||||
|
||||
grpc_deps() |
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") |
||||
|
||||
grpc_extra_deps() |
||||
``` |
||||
|
||||
## Supported Versions |
||||
|
||||
In general, gRPC supports building with the latest patch release of the most |
||||
recent two major versions of Bazel. However individual releases may have a |
||||
broader compatibility range. The currently supported versions are captured by |
||||
the following list: |
||||
|
||||
- [`5.0.0`](https://github.com/bazelbuild/bazel/releases/tag/5.0.0) |
||||
- [`4.2.2`](https://github.com/bazelbuild/bazel/releases/tag/4.2.2) |
||||
- [`3.7.2`](https://github.com/bazelbuild/bazel/releases/tag/3.7.2) |
@ -0,0 +1,46 @@ |
||||
%YAML 1.2 |
||||
--- | |
||||
# Bazel Support |
||||
|
||||
${ '##' } Basic Usage |
||||
|
||||
The `grpc/grpc` repository's primary build system is Bazel. Rules are provided |
||||
for C++, Python, and Objective-C. While C++ supports other build systems such as |
||||
CMake, these rules are actually generated from the Bazel definitions. |
||||
|
||||
Projects built with Bazel may use the `grpc/grpc` repo not only to add a |
||||
dependency on the library itself, but also to generate protobuf, stub, and |
||||
servicer code. To do so, one must invoke the `grpc_deps` and `grpc_extra_deps` |
||||
repository rules in their `WORKSPACE` file: |
||||
|
||||
```starlark |
||||
workspace(name = "example_workspace") |
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
||||
|
||||
http_archive( |
||||
name = "com_github_grpc_grpc", |
||||
strip_prefix = "grpc-1.45.0", |
||||
sha256 = "ec19657a677d49af59aa806ec299c070c882986c9fcc022b1c22c2a3caf01bcd"k |
||||
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.45.0.tar.gz"], |
||||
) |
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") |
||||
|
||||
grpc_deps() |
||||
|
||||
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") |
||||
|
||||
grpc_extra_deps() |
||||
``` |
||||
|
||||
${ '##' } Supported Versions |
||||
|
||||
In general, gRPC supports building with the latest patch release of the most |
||||
recent two major versions of Bazel. However individual releases may have a |
||||
broader compatibility range. The currently supported versions are captured by |
||||
the following list: |
||||
|
||||
% for version in supported_bazel_versions: |
||||
- [`${version}`](https://github.com/bazelbuild/bazel/releases/tag/${version}) |
||||
% endfor |
@ -0,0 +1,28 @@ |
||||
# Copyright 2022 The gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
"""Retrieves supported bazel versions from plaintext file.""" |
||||
|
||||
_SUPPORTED_VERSIONS_FILE = "bazel/supported_versions.txt" |
||||
|
||||
|
||||
def _get_supported_bazel_versions(): |
||||
versions = [] |
||||
with open(_SUPPORTED_VERSIONS_FILE, "r") as f: |
||||
for line in f: |
||||
versions.append(line.strip()) |
||||
return versions |
||||
|
||||
|
||||
def mako_plugin(dictionary): |
||||
dictionary["supported_bazel_versions"] = _get_supported_bazel_versions() |
@ -0,0 +1,46 @@ |
||||
#!/bin/bash |
||||
#Copyright 2022 The gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
# This script can be used to manually update the specific versions of Bazel |
||||
# tested by the Bazel distribtests and advertised as supported in documentation. |
||||
# This will update the supported_versions.txt file, which will be templated into |
||||
# the bazel_support.md document. |
||||
|
||||
# This script selects the latest patch release of the two most recent major |
||||
# versions of Bazel. If you want to include other versions in the set of |
||||
# supported versions, then you will need to manually edit the ifle. |
||||
|
||||
set -xeuo pipefail |
||||
|
||||
cd "$(dirname "$0")/../.." |
||||
|
||||
# The number of most recent supported major Bazel versions. |
||||
SUPPORT_RANGE="2" |
||||
|
||||
# Retrieve all git tags from the Bazel git repo. |
||||
TAGS=$(git ls-remote --tags git@github.com:bazelbuild/bazel.git | awk '{print $2;}' | sed 's|refs/tags/||g') |
||||
|
||||
# Find the n most recent major versions. |
||||
MAJOR_VERSIONS=$(echo "$TAGS" | egrep '^[0-9]+\.[0-9]+\.[0-9]+$' | cut -d'.' -f1 | sort -r | uniq | head -n"$SUPPORT_RANGE") |
||||
|
||||
SUPPORTED_VERSIONS="" |
||||
|
||||
# For each major version selected, find the most recent patch release. |
||||
while read -r MAJOR_VERSION; do |
||||
LATEST_PATCH=$(echo "$TAGS" | egrep "^${MAJOR_VERSION}\.[0-9]+\.[0-9]+$" | sort -nr | head -n1) |
||||
SUPPORTED_VERSIONS="$SUPPORTED_VERSIONS$LATEST_PATCH\n" |
||||
done<<<"$MAJOR_VERSIONS" |
||||
|
||||
printf "$SUPPORTED_VERSIONS" | tee bazel/supported_versions.txt |
Loading…
Reference in new issue