clang-tidy.sh (1593B)
1 #!/usr/bin/env bash 2 3 # Use clang-tidy to brace if statements and loops. This should be a feature of clang-format. 4 # The brace check is the only check being applied right now, 5 # but other checks (like naming scheme) may be added at a later time. 6 7 # '--fix-errors` due to generated text_strings.h as well as the enhancement inc.c files 8 TIDY_OPTS="-p . --fix --fix-errors" 9 COMPILER_OPTS="-nostdinc -fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C" 10 VERSIONS="-DVERSION_US -DVERSION_JP -DVERSION_EU" 11 12 # run script from the root of the repository 13 cd "$( dirname $0 )" >/dev/null 2>&1; cd ../ 14 15 if (( $# > 0 )); then 16 printf "Tidy file(s) $*" 17 echo 18 for VER in ${VERSIONS}; do 19 echo "with compiler version flag ${VER}" 20 clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} ${VER} 21 done 22 printf "Done tidying file(s) $*" 23 echo 24 exit 25 fi 26 27 echo "Tidying all C files for all versions. This will take a bit" 28 for VER in ${VERSIONS}; do 29 echo "Tidying for compiler version flag ${VER}" 30 # Don't run clang-tidy on behaviors 31 clang-tidy ${TIDY_OPTS} src/audio/*.c -- ${COMPILER_OPTS} ${VER} 32 clang-tidy ${TIDY_OPTS} src/engine/*.c -- ${COMPILER_OPTS} ${VER} 33 clang-tidy ${TIDY_OPTS} src/game/*.c -- ${COMPILER_OPTS} ${VER} 34 clang-tidy ${TIDY_OPTS} src/goddard/*.c -- ${COMPILER_OPTS} ${VER} 35 clang-tidy ${TIDY_OPTS} lib/src/*.c -- ${COMPILER_OPTS} ${VER} 36 clang-tidy ${TIDY_OPTS} enhancements/*.inc.c -- ${COMPILER_OPTS} ${VER} 37 done 38 echo "Done tidying all C files. Hope you did something fun during the tidying"