diff --git a/test/lint/lint-cppcheck-dash.sh b/test/lint/lint-cppcheck-dash.sh index 3c6b9ddd93..202be43d14 100755 --- a/test/lint/lint-cppcheck-dash.sh +++ b/test/lint/lint-cppcheck-dash.sh @@ -80,10 +80,15 @@ ENABLED_CHECKS_REGEXP=$(join_array "|" "${ENABLED_CHECKS[@]}") IGNORED_WARNINGS_REGEXP=$(join_array "|" "${IGNORED_WARNINGS[@]}") FILES_REGEXP=$(join_array "|" "${FILES[@]}") SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -CPPCHECK_DIR=$SCRIPT_DIR/.cppcheck/ +# Check if CACHE_DIR is set and non-empty, otherwise use default .cppcheck/ directory +if [[ -n "$CACHE_DIR" ]]; then + CPPCHECK_DIR=$CACHE_DIR/cppcheck/ +else + CPPCHECK_DIR=$SCRIPT_DIR/.cppcheck/ +fi if [ ! -d $CPPCHECK_DIR ] then - mkdir $CPPCHECK_DIR + mkdir -p $CPPCHECK_DIR fi WARNINGS=$(echo "${FILES}" | \ xargs cppcheck --enable=all --inline-suppr --suppress=missingIncludeSystem --cppcheck-build-dir=$CPPCHECK_DIR -j "$(getconf _NPROCESSORS_ONLN)" --language=c++ --std=c++17 --template=gcc -D__cplusplus -DENABLE_WALLET -DCLIENT_VERSION_BUILD -DCLIENT_VERSION_IS_RELEASE -DCLIENT_VERSION_MAJOR -DCLIENT_VERSION_MINOR -DCOPYRIGHT_YEAR -DDEBUG -DUSE_EPOLL -DCHAR_BIT=8 -I src/ -q 2>&1 | sort -u | \