Skip to content

Commit ef6a5b9

Browse files
authored
[build] Automatic BUILD dependency generation (grpc#29597)
* [build] Automatic dependency analysis * add to sanity * Automated change: Fix sanity tests * review feedback Co-authored-by: ctiller <[email protected]>
1 parent ff90d97 commit ef6a5b9

File tree

5 files changed

+495
-4
lines changed

5 files changed

+495
-4
lines changed

BUILD

+2-1
Original file line numberDiff line numberDiff line change
@@ -2506,10 +2506,11 @@ grpc_cc_library(
25062506
"src/core/lib/surface/channel_init.h",
25072507
],
25082508
language = "c++",
2509+
tags = ["grpc-autodeps"],
25092510
deps = [
25102511
"channel_stack_builder",
25112512
"channel_stack_type",
2512-
"gpr_base",
2513+
"gpr_platform",
25132514
],
25142515
)
25152516

tools/buildgen/generate_projects.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ if [[ "${YAML_OK}" != "True" ]]; then
2626
python3 -m pip install --upgrade --ignore-installed PyYAML==5.3.1 --user
2727
fi
2828

29+
cd `dirname $0`/../..
30+
31+
tools/distrib/fix_build_deps.py
32+
2933
echo "Generating build_autogenerated.yaml from bazel BUILD file"
3034
rm -f build_autogenerated.yaml
3135
python3 tools/buildgen/extract_metadata_from_bazel_xml.py
3236

33-
cd `dirname $0`/../..
34-
3537
tools/buildgen/build_cleaner.py build_handwritten.yaml
3638

3739
# check build_autogenerated.yaml is already in its "clean" form

tools/distrib/buildozer.sh

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#! /bin/bash
2+
# Copyright 2019 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+
set -e
17+
18+
BUILDOZER_VERSION="4.2.2"
19+
TEMP_BUILDOZER_PATH="/tmp/buildozer-for-grpc"
20+
21+
function error_handling() {
22+
error=$1
23+
if [[ -x "$error" ]]; then
24+
echo "${error}"
25+
exit 1
26+
fi
27+
}
28+
29+
function download_buildozer() {
30+
platform="$(uname -s)"
31+
case "${platform}" in
32+
Linux*) download_link="https://github.com/bazelbuild/buildtools/releases/download/${BUILDOZER_VERSION}/buildozer-linux-amd64";;
33+
Darwin*) download_link="https://github.com/bazelbuild/buildtools/releases/download/${BUILDOZER_VERSION}/buildozer-darwin-amd64";;
34+
*) error_handling "Unsupported platform: ${platform}";;
35+
esac
36+
37+
if [ -x "$(command -v curl)" ]; then
38+
curl -L -o ${TEMP_BUILDOZER_PATH} ${download_link}
39+
elif [ -x "$(command -v wget)" ]; then
40+
wget -O ${TEMP_BUILDOZER_PATH} ${download_link}
41+
else
42+
error_handling "Download failed: curl and wget not available"
43+
fi
44+
45+
chmod +x ${TEMP_BUILDOZER_PATH}
46+
}
47+
48+
49+
# Get the correct version of buildozer
50+
if [ -x "$(command -v buildozer)" ]; then
51+
existing_buildozer_version="$(buildozer -version 2>&1 | head -n1 | cut -d" " -f3)"
52+
if [[ "${existing_buildozer_version}" != "${BUILDOZER_VERSION}" ]]; then
53+
download_buildozer
54+
buildozer_bin="${TEMP_BUILDOZER_PATH}"
55+
else
56+
buildozer_bin="buildozer"
57+
fi
58+
else
59+
if [ -x ${TEMP_BUILDOZER_PATH} ]; then
60+
existing_buildozer_version="$(${TEMP_BUILDOZER_PATH} -version 2>&1 | head -n1 | cut -d" " -f3)"
61+
if [[ "${existing_buildozer_version}" != "${BUILDOZER_VERSION}" ]]; then
62+
download_buildozer
63+
fi
64+
else
65+
download_buildozer
66+
fi
67+
buildozer_bin="${TEMP_BUILDOZER_PATH}"
68+
fi
69+
70+
# cd to repo root
71+
dir=$(dirname "${0}")
72+
cd "${dir}/../.."
73+
74+
set -ex
75+
76+
# shellcheck disable=SC2086,SC2068
77+
${buildozer_bin} "$@"

0 commit comments

Comments
 (0)