From 15d1edc449e6923fa4a6778c7ef96bd864598d8b Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 7 Aug 2017 13:38:54 -0700 Subject: Add ability to override clang format, including disable. To disable check, specify CLANG_FORMAT as off, no, or skip. --- etc/format-check.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/etc/format-check.sh b/etc/format-check.sh index b3e0da3f..c98ac586 100755 --- a/etc/format-check.sh +++ b/etc/format-check.sh @@ -14,11 +14,18 @@ # uncrustify.cfg located in the same directory as this script. It only handles # C language at this point. # +CLANG_FORMAT=${CLANG_FORMAT:-clang-format} +case "${CLANG_FORMAT}" in +no|off|skip|NO|OFF|SKIP) + echo "format checks skipped" + exit 0 + ;; +esac mydir=`dirname $0` srcdir=${mydir}/../src failed= -vers=$(clang-format -version) +vers=$(${CLANG_FORMAT} -version) if [ $? -ne 0 ]; then echo "clang format not found? Skipping checks." exit 0 @@ -53,7 +60,7 @@ mytmpdir=`mktemp -d` diffprog=${DIFF:-diff} if [ -t 1 ]; then - if colordiff -q /dev/null /dev/null; then + if colordiff -q /dev/null > /dev/null 2>&1; then diffprog=${DIFF:-colordiff} fi fi @@ -67,7 +74,7 @@ do # If we do not understand the format file, then do nothing # Our style requires a relatively modern clang-format, which is # older than is found on some Linux distros. - clang-format -fallback-style=none -style=file ${oldf} > ${newf} + ${CLANG_FORMAT} -fallback-style=none -style=file ${oldf} > ${newf} cmp -s ${oldf} ${newf} if [ $? -ne 0 ] then -- cgit v1.2.3-70-g09d2