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 yapf==0.30.0 26 27pushd "$(dirname "${0}")/../.." 28FILES=$(find . -path ./third_party -prune -o -name '*.bzl' -print) 29echo "${FILES}" | xargs "$PYTHON" -m yapf -i --style="${CONFIG_PATH}" 30 31if ! which buildifier &>/dev/null; then 32 echo 'buildifer must be installed.' >/dev/stderr 33 exit 1 34fi 35 36echo "${FILES}" | xargs buildifier --type=bzl 37 38popd 39