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