From 41081e1b40ded7aec916cb43fd3d4f068db2a9d2 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 5 Nov 2015 09:49:06 +0100 Subject: [PATCH] build: add a nice cppcheck option --- build.sh | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 97a16d125a..f176702457 100755 --- a/build.sh +++ b/build.sh @@ -23,11 +23,13 @@ useClang=0 # 0 => no, 1 => yes, 2 => force yes useCross=2 CoverityBuild=0 +cppcheck=0 for ARG in "$@"; do case "$ARG" in --clean ) cleanBuild=1 ;; - --clang ) useClang=1; ;; + --clang ) useClang=1 ;; + --cppcheck ) cppcheck=1 ;; --dev|--devel ) flags+=(-DCMAKE_BUILD_TYPE=Devel) ;; --dbg|--debug ) flags+=(-DCMAKE_BUILD_TYPE=Debug) ;; --strip ) flags+=(-DCMAKE_BUILD_STRIP=TRUE) ;; @@ -69,8 +71,11 @@ for ARG in "$@"; do echo "--gtk3 : replace GTK2 by GTK3" echo "--no-cross-multilib: Build a native PCSX2" echo "--clang : Build with Clang/llvm" + echo + echo "** Quality & Assurance (Please install the external tool) **" echo "--asan : Enable Address sanitizer" - echo "--coverity : Do a build for coverity (require the tool)" + echo "--cppcheck : Do a cppcheck analysis. Results can be found in build directory" + echo "--coverity : Do a build for coverity" exit 1 esac @@ -123,7 +128,28 @@ else ncpu=$(grep -w -c processor /proc/cpuinfo) fi -if [[ "$CoverityBuild" -eq 1 ]]; then +if [[ "$cppcheck" -eq 1 ]] && [[ -x `which cppcheck` ]]; then + summary=cpp_check_summary.log + rm -f $summary + touch $summary + + define="-U_WINDOWS -U_M_AMD64 -U_MSC_VER -UWIN32" + #define="-D__linux__ -U_WINDOWS -U_M_AMD64 -U_MSC_VER -UWIN32" + check="--enable=warning,style,missingInclude" + for d in pcsx2 common plugins/GSdx plugins/spu2\-x plugins/onepad + do + flat_d=`echo $d | sed -e 's@/@_@'` + log=cpp_check__${flat_d}.log + rm -f $log + + cppcheck $check -j $ncpu --platform=unix32 $define $root/$d |& tee $log + # Create a small summary (warning it might miss some issues) + fgrep -e "(warning)" -e "(error)" -e "(style)" -e "(performance)" -e "(portability)" $log >> $summary + done + exit 0 +fi + +if [[ "$CoverityBuild" -eq 1 ]] && [[ -x `which cov-build` ]]; then cov-build --dir $coverity_dir make -j"$ncpu" 2>&1 | tee -a $log # Warning: $coverity_dir must be the root directory (cd $build; tar caf $coverity_result $coverity_dir)