Debian Codegraph @

tools/distrib/format_bazel.sh

raw
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=-ex
17
18 VIRTUAL_ENV=bazel_format_virtual_environment
19
20 CONFIG_PATH="$(dirname ${0})/bazel_style.cfg"
21
22 python -m virtualenv ${VIRTUAL_ENV}
23 PYTHON=${VIRTUAL_ENV}/bin/python
24 "$PYTHON" -m pip install --upgrade pip==19.3.1
25 "$PYTHON" -m pip install yapf==0.30.0
26
27 pushd "$(dirname "${0}")/../.."
28 FILES=$(find . -path ./third_party -prune -o -name '*.bzl' -print)
29 echo "${FILES}" | xargs "$PYTHON" -m yapf -i --style="${CONFIG_PATH}"
30
31 if ! which buildifier &>/dev/null; then
32 echo 'buildifer must be installed.' >/dev/stderr
33 exit 1
34 fi
35
36 echo "${FILES}" | xargs buildifier --type=bzl
37
38 popd