clang_format_code.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. # Copyright 2015 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. set -ex
  16. # change to root directory
  17. cd $(dirname $0)/../..
  18. REPO_ROOT=$(pwd)
  19. if [ "$CLANG_FORMAT_SKIP_DOCKER" == "" ]
  20. then
  21. # build clang-format docker image
  22. docker build -t grpc_clang_format tools/dockerfile/grpc_clang_format
  23. # run clang-format against the checked out codebase
  24. # when modifying the checked-out files, the current user will be impersonated
  25. # so that the updated files don't end up being owned by "root".
  26. docker run -e TEST="$TEST" -e CHANGED_FILES="$CHANGED_FILES" -e CLANG_FORMAT_ROOT="/local-code" --rm=true -v "${REPO_ROOT}":/local-code --user "$(id -u):$(id -g)" -t grpc_clang_format /clang_format_all_the_things.sh
  27. else
  28. CLANG_FORMAT_ROOT="${REPO_ROOT}" tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh
  29. fi