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