check-formatting.sh 760 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # The files that need to be properly formatted. We'll grow this incrementally
  3. # until it includes all the jemalloc source files (as we convert things over),
  4. # and then just replace it with
  5. # find -name '*.c' -o -name '*.h' -o -name '*.cpp
  6. FILES=(
  7. )
  8. if command -v clang-format &> /dev/null; then
  9. CLANG_FORMAT="clang-format"
  10. elif command -v clang-format-8 &> /dev/null; then
  11. CLANG_FORMAT="clang-format-8"
  12. else
  13. echo "Couldn't find clang-format."
  14. fi
  15. if ! $CLANG_FORMAT -version | grep "version 8\." &> /dev/null; then
  16. echo "clang-format is the wrong version."
  17. exit 1
  18. fi
  19. for file in ${FILES[@]}; do
  20. if ! cmp --silent $file <($CLANG_FORMAT $file) &> /dev/null; then
  21. echo "Error: $file is not clang-formatted"
  22. exit 1
  23. fi
  24. done