File indexing completed on 2024-12-01 03:34:52
0001 #!/bin/bash 0002 0003 # Variable that will hold the name of the clang-format command 0004 FMT="" 0005 0006 FOLDERS=("src/backend" "src/commonfrontend" "src/kdefrontend" "src/tools" "tests") 0007 0008 # Some distros just call it clang-format. Others (e.g. Ubuntu) are insistent 0009 # that the version number be part of the command. We prefer clang-format-13 if 0010 # that's present, otherwise we check clang-format 0011 for clangfmt in clang-format{-13,}; do 0012 if which "$clangfmt" &>/dev/null; then 0013 echo "$($clangfmt --version)" 0014 FMT="$clangfmt" 0015 break 0016 fi 0017 done 0018 0019 # Check if we found a working clang-format 0020 if [ -z "$FMT" ]; then 0021 echo "failed to find clang-format. Please install clang-format version 13 or above" 0022 exit 1 0023 fi 0024 0025 function format() { 0026 # ignore getRSS.h file 0027 for f in $(find $@ -name '*.h' ! -iname 'getRSS.h' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp'); do 0028 echo "format ${f}"; 0029 ${FMT} -i ${f}; 0030 done 0031 0032 echo "~~~ $@ Done ~~~"; 0033 } 0034 0035 # Check all of the arguments first to make sure they're all directories 0036 for dir in ${FOLDERS[@]}; do 0037 if [ ! -d "${dir}" ]; then 0038 echo "${dir} is not a directory"; 0039 else 0040 format ${dir}; 0041 fi 0042 done