blob: 9233a230c91b1fc17b344b1f606128a4f9fc23b7 [file] [log] [blame]
Craig Tillerddf3a512015-09-24 13:03:44 -07001#!/bin/bash
Jan Tattermusch7897ae92017-06-07 22:57:36 +02002# Copyright 2015 gRPC authors.
Craig Tillercb6ce542015-12-22 15:03:40 -08003#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02004# 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
Craig Tillercb6ce542015-12-22 15:03:40 -08007#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02008# http://www.apache.org/licenses/LICENSE-2.0
Craig Tillercb6ce542015-12-22 15:03:40 -08009#
Jan Tattermusch7897ae92017-06-07 22:57:36 +020010# 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.
Craig Tillerddf3a512015-09-24 13:03:44 -070015
16set -ex
17
18# change to root directory
19cd $(dirname $0)/../..
Jan Tattermusch7dd2cc62016-12-20 17:15:39 +010020REPO_ROOT=$(pwd)
Craig Tillerddf3a512015-09-24 13:03:44 -070021
Jan Tattermusch7dd2cc62016-12-20 17:15:39 +010022if [ "$CLANG_FORMAT_SKIP_DOCKER" == "" ]
23then
24 # build clang-format docker image
25 docker build -t grpc_clang_format tools/dockerfile/grpc_clang_format
Craig Tillerddf3a512015-09-24 13:03:44 -070026
Jan Tattermusch7dd2cc62016-12-20 17:15:39 +010027 # run clang-format against the checked out codebase
28 docker run -e TEST=$TEST -e CHANGED_FILES="$CHANGED_FILES" -e CLANG_FORMAT_ROOT="/local-code" --rm=true -v "${REPO_ROOT}":/local-code -t grpc_clang_format /clang_format_all_the_things.sh
29else
30 CLANG_FORMAT_ROOT="${REPO_ROOT}" tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh
31fi