1#!/bin/bash 2# Copyright 2023 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# Generate linux RBE configs using rbe_configs_gen. 17# See https://github.com/bazelbuild/bazel-toolchains#rbe_configs_gen---cli-tool-to-generate-configs 18 19set -ex 20 21cd $(dirname $0)/../.. 22 23REPO_ROOT="$(pwd)" 24 25TEMP_DIR="$(mktemp -d)" 26pushd "${TEMP_DIR}" 27# Build the "rbe_configs_gen" binary using the official instructions. 28git clone https://github.com/bazelbuild/bazel-toolchains.git 29cd bazel-toolchains 30# Build "rbe_configs_gen" binary under docker and put it to the current directory. 31docker run --rm -v $PWD:/srcdir -w /srcdir golang:1.16 go build -o rbe_configs_gen ./cmd/rbe_configs_gen/rbe_configs_gen.go 32popd 33 34# location of the "rbe_config_gen" binary as build by the previous step. 35RBE_CONFIGS_GEN_TOOL_PATH="${TEMP_DIR}/bazel-toolchains/rbe_configs_gen" 36 37# Actions on RBE will run under a dedicated docker image from our collection of testing docker images. 38LINUX_RBE_DOCKERFILE_DIR=tools/dockerfile/test/rbe_ubuntu2004 39# Use the "current version" of the above dockerfile. 40LINUX_RBE_DOCKER_IMAGE=$(cat ${LINUX_RBE_DOCKERFILE_DIR}.current_version) 41 42# RBE currently has problems pulling images for Google Artifact Registry ("us-docker.pkg.dev/grpc-testing") 43# so to workaround this, the original image was manually pushed to Google Container Registry ("gcr.io/grpc-testing") 44# as well and RBE will use the mirrored image instead. See b/275571385 45# TODO(jtattermusch): get rid of this hack. 46LINUX_RBE_DOCKER_IMAGE_IN_GCR=$(echo -n "${LINUX_RBE_DOCKER_IMAGE}" | sed 's|^us-docker.pkg.dev/grpc-testing/testing-images-public/|gcr.io/grpc-testing/rbe_images_mirror/|') 47 48# Bazel version used for configuring 49# Needs to be one of the versions from bazel/supported_versions.txt chosen so that the result is compatible 50# with other supported bazel versions. 51BAZEL_VERSION=5.4.0 52 53# TODO(jtattermusch): experiment with --cpp_env_json to simplify bazel build configuration. 54 55# Where to store the generated configs (relative to repo root) 56CONFIG_OUTPUT_PATH=third_party/toolchains/rbe_ubuntu2004 57 58# Delete old generated configs. 59rm -rf "${REPO_ROOT}/${CONFIG_OUTPUT_PATH}" 60 61${RBE_CONFIGS_GEN_TOOL_PATH} \ 62 --bazel_version="${BAZEL_VERSION}" \ 63 --toolchain_container="${LINUX_RBE_DOCKER_IMAGE_IN_GCR}" \ 64 --output_src_root="${REPO_ROOT}" \ 65 --output_config_path="${CONFIG_OUTPUT_PATH}" \ 66 --exec_os=linux \ 67 --target_os=linux \ 68 --generate_java_configs=false 69