diff options
Diffstat (limited to 'tools/ci/jobs/cpplint.sh')
-rwxr-xr-x | tools/ci/jobs/cpplint.sh | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/tools/ci/jobs/cpplint.sh b/tools/ci/jobs/cpplint.sh index 7bbccf271..b8331ff29 100755 --- a/tools/ci/jobs/cpplint.sh +++ b/tools/ci/jobs/cpplint.sh @@ -1,14 +1,21 @@ #!/usr/bin/env bash -export LOGFILE=cpplint.log +set -e # Fail if any command fails +set -u # Fail if any variable is unset when used +export LOGFILE=cpplint.log source ./tools/ci/scripts/init.sh # Re-download if not executable or older than a day if [[ ! -x cpplint.py \ || $(find cpplint.py -mtime 1 -print) ]]; then - tools/ci/scripts/retry.sh wget "https://raw.githubusercontent.com/google/styleguide/gh-pages/cpplint/cpplint.py" - chmod +x cpplint.py + #tools/ci/scripts/retry.sh wget "https://raw.githubusercontent.com/google/styleguide/gh-pages/cpplint/cpplint.py" + # Google no longer offers their cpplint and suggests using the following one, instead: + tools/ci/scripts/retry.sh wget "https://raw.githubusercontent.com/cpplint/cpplint/refs/tags/2.0.0/cpplint.py" + chmod +x cpplint.py + + # env python -> env python3 + sed -i -s -e '1s/python$/python3/' cpplint.py fi declare -a args @@ -40,19 +47,20 @@ args+=("--filter=\ -build/c++tr1"\ ) +# Cannot find a good way to handle execution errors +# (such cpplint.py demanding a version of Python that does not exist) +# So use || true here and assume any other problems will be exposed +# by the grep below. Addendum: no more grep. YMMV. find src \ -type f \ - -name "*.cpp" -o -name "*.hpp" -o -name "*.h" -o -name "*.cc" \ - -exec ./cpplint.py "${args[@]}" {} \+ 2>${ERRFILE}2 + \( -name "*.cc" \ + -o \( -name "*.cpp" -a \! -path src/debug/nvwa/debug_new.cpp \) \ + -o \( -name "*.h" -a \! -path src/unittests/doctest.h \) \ + -o \( -name "*.hpp" -a \! -path src/unittests/catch.hpp \) \ + \) -exec ./cpplint.py --verbose=5 "${args[@]}" {} \+ 2>"$ERRFILE" + #|| true -grep ": " ${ERRFILE}2 | grep -v -e "src/debug/" \ - -e "unittests/doctest.h" \ - -e "unittests/catch.hpp" \ - -e "debug/fast_mutex" \ - -e "sdl2gfx/SDL2" \ - >${ERRFILE} -rm ${ERRFILE}2 run_check_warnings |