Loading scripts/check-format.sh +35 −8 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ if [ ! -d "lib_com" ]; then echo "not in root directory! - please run in IVAS root" exit 1 exit 255 fi CLANG_FORMAT=clang-format Loading @@ -58,7 +58,7 @@ Usage: $(basename "$0") [OPTIONS] [FILES] -p NUMPROCS run in parallel -h display help EOM exit 2 exit 254 } cl-format-check-version() { Loading Loading @@ -147,30 +147,43 @@ FILES="$@" if [ ! -d "lib_com" ]; then echo "not in root directory! - please run in IVAS root" exit 1 exit 253 fi if [ ! $NOVERSION ]; then if [[ $(cl-format-check-version) != "${CLANG_FORMAT_REQUIRED_VERSION}"* ]]; then echo "clang-format must be version ${CLANG_FORMAT_REQUIRED_VERSION} but is $(cl-format-check-version) !!!" echo "Executables for Win32 could be downloaded from https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/LLVM-13.0.1-win32.exe" exit 2 exit 252 fi fi if [ -z "$FILES" ]; then if [ $ALL ]; then FILES=$(ls lib*/*.[c,h] apps/*.[c,h]) else elif [ -d ".svn" ]; then if [ ! -x "$(command -v svn)" ]; then echo "Subversion doesn't seem to be installed. Please ensure svn is in your PATH" exit 3 exit 251 fi if [[ "$OSTYPE" == "darwin"* ]]; then FILES=$(svn st | grep '^M' | cut -b 9- | grep -E "\.c|\.h") else FILES=$(svn st | grep '^M' | cut -b 9- | grep '\.c$\|\.h$') fi elif [ -d ".git" ]; then if [ ! -x "$(command -v git)" ]; then echo "GIT doesn't seem to be installed. Please ensure git is in your PATH" exit 251 fi if [[ "$OSTYPE" == "darwin"* ]]; then FILES=$(git status | grep 'modified: ' | cut -b 14- | grep -E "\.c|\.h") else FILES=$(git status | grep 'modified: ' | cut -b 14- | grep '\.c$\|\.h$') fi else echo "Warning: no files checked (either no cmdl params or no modified files)" exit 0 fi for i in ${EXCLUDE_FILES}; do FILES=$(echo ${FILES} | xargs -n 1 | grep -v ${i} | tr '\n' ' ') Loading @@ -189,13 +202,21 @@ if [[ $NUMPROCS -lt 2 ]]; then done if [[ $NUMFAILS -gt 0 ]]; then echo "Total fails: $NUMFAILS" exit 1 # exit $NUMFAILS ## uncomment if script should have num fails as return code fi else NUMFAILS=0 NUMFAILSTMPFILE=$(mktemp) # parallel processing. Note that return code is always 0 then and fails are not counted for i in ${FILES}; do ( cl-format-check $i $COLOR RET=$? if [[ $RET -gt 0 ]] then echo "1" >> "$NUMFAILSTMPFILE" fi ((NUMFAILS+=RET)) if [ $FORMAT ]; then cl-format-apply $i fi ) & Loading @@ -204,6 +225,12 @@ else done done wait NUMFAILS=`cat $NUMFAILSTMPFILE | wc -l` rm "$NUMFAILSTMPFILE" if [[ $NUMFAILS -gt 0 ]]; then echo "Total fails: $NUMFAILS" # exit $NUMFAILS ## uncomment if script should have num fails as return code fi fi exit 0 Loading
scripts/check-format.sh +35 −8 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ if [ ! -d "lib_com" ]; then echo "not in root directory! - please run in IVAS root" exit 1 exit 255 fi CLANG_FORMAT=clang-format Loading @@ -58,7 +58,7 @@ Usage: $(basename "$0") [OPTIONS] [FILES] -p NUMPROCS run in parallel -h display help EOM exit 2 exit 254 } cl-format-check-version() { Loading Loading @@ -147,30 +147,43 @@ FILES="$@" if [ ! -d "lib_com" ]; then echo "not in root directory! - please run in IVAS root" exit 1 exit 253 fi if [ ! $NOVERSION ]; then if [[ $(cl-format-check-version) != "${CLANG_FORMAT_REQUIRED_VERSION}"* ]]; then echo "clang-format must be version ${CLANG_FORMAT_REQUIRED_VERSION} but is $(cl-format-check-version) !!!" echo "Executables for Win32 could be downloaded from https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/LLVM-13.0.1-win32.exe" exit 2 exit 252 fi fi if [ -z "$FILES" ]; then if [ $ALL ]; then FILES=$(ls lib*/*.[c,h] apps/*.[c,h]) else elif [ -d ".svn" ]; then if [ ! -x "$(command -v svn)" ]; then echo "Subversion doesn't seem to be installed. Please ensure svn is in your PATH" exit 3 exit 251 fi if [[ "$OSTYPE" == "darwin"* ]]; then FILES=$(svn st | grep '^M' | cut -b 9- | grep -E "\.c|\.h") else FILES=$(svn st | grep '^M' | cut -b 9- | grep '\.c$\|\.h$') fi elif [ -d ".git" ]; then if [ ! -x "$(command -v git)" ]; then echo "GIT doesn't seem to be installed. Please ensure git is in your PATH" exit 251 fi if [[ "$OSTYPE" == "darwin"* ]]; then FILES=$(git status | grep 'modified: ' | cut -b 14- | grep -E "\.c|\.h") else FILES=$(git status | grep 'modified: ' | cut -b 14- | grep '\.c$\|\.h$') fi else echo "Warning: no files checked (either no cmdl params or no modified files)" exit 0 fi for i in ${EXCLUDE_FILES}; do FILES=$(echo ${FILES} | xargs -n 1 | grep -v ${i} | tr '\n' ' ') Loading @@ -189,13 +202,21 @@ if [[ $NUMPROCS -lt 2 ]]; then done if [[ $NUMFAILS -gt 0 ]]; then echo "Total fails: $NUMFAILS" exit 1 # exit $NUMFAILS ## uncomment if script should have num fails as return code fi else NUMFAILS=0 NUMFAILSTMPFILE=$(mktemp) # parallel processing. Note that return code is always 0 then and fails are not counted for i in ${FILES}; do ( cl-format-check $i $COLOR RET=$? if [[ $RET -gt 0 ]] then echo "1" >> "$NUMFAILSTMPFILE" fi ((NUMFAILS+=RET)) if [ $FORMAT ]; then cl-format-apply $i fi ) & Loading @@ -204,6 +225,12 @@ else done done wait NUMFAILS=`cat $NUMFAILSTMPFILE | wc -l` rm "$NUMFAILSTMPFILE" if [[ $NUMFAILS -gt 0 ]]; then echo "Total fails: $NUMFAILS" # exit $NUMFAILS ## uncomment if script should have num fails as return code fi fi exit 0