From f43c6d68f2a28f477a81817e1e795d1336b71837 Mon Sep 17 00:00:00 2001 From: spycrab Date: Thu, 7 Mar 2019 15:10:41 +0100 Subject: [PATCH] Tools/lint.sh: Look for specific versions of clang-format first --- Tools/lint.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Tools/lint.sh b/Tools/lint.sh index 4a2eb22709..5a00def4e3 100755 --- a/Tools/lint.sh +++ b/Tools/lint.sh @@ -11,8 +11,14 @@ fi REQUIRED_CLANG_FORMAT_MAJOR=5 REQUIRED_CLANG_FORMAT_MINOR=0 +CLANG_FORMAT=clang-format +CLANG_FORMAT_MAJOR=clang-format-${REQUIRED_CLANG_FORMAT_MAJOR} +CLANG_FORMAT_MAJOR_MINOR=${CLANG_FORMAT_MAJOR}.${REQUIRED_CLANG_FORMAT_MINOR} -if ! [ -x "$(command -v clang-format)" ]; then +if [ -x "$(command -v $CLANG_FORMAT_MAJOR)" ]; then CLANG_FORMAT=$CLANG_FORMAT_MAJOR; fi +if [ -x "$(command -v $CLANG_FORMAT_MAJOR_MINOR)" ]; then CLANG_FORMAT=$CLANG_FORMAT_MAJOR_MINOR; fi + +if ! [ -x "$(command -v $CLANG_FORMAT)" ]; then echo >&2 "error: clang-format is not installed" echo >&2 "Install clang-format version ${REQUIRED_CLANG_FORMAT_MAJOR}.${REQUIRED_CLANG_FORMAT_MINOR}.*" exit 1 @@ -30,7 +36,7 @@ if [ $# -gt 0 ]; then fi if [ $FORCE -eq 0 ]; then - CLANG_FORMAT_VERSION=$(clang-format -version | cut -d' ' -f3) + CLANG_FORMAT_VERSION=$($CLANG_FORMAT -version | cut -d' ' -f3) CLANG_FORMAT_MAJOR=$(echo $CLANG_FORMAT_VERSION | cut -d'.' -f1) CLANG_FORMAT_MINOR=$(echo $CLANG_FORMAT_VERSION | cut -d'.' -f2) @@ -96,7 +102,7 @@ for f in ${modified_files}; do fi # Check for clang-format issues. - d=$(clang-format ${f} | (diff -u "${f}" - || true)) + d=$($CLANG_FORMAT ${f} | (diff -u "${f}" - || true)) if ! [ -z "${d}" ]; then echo "!!! ${f} not compliant to coding style, here is the fix:" echo "${d}"