diff --git a/build.sh b/build.sh index f9b65ee4dd..2470d38960 100755 --- a/build.sh +++ b/build.sh @@ -24,10 +24,12 @@ useClang=0 useCross=2 CoverityBuild=0 cppcheck=0 +clangTidy=0 for ARG in "$@"; do case "$ARG" in --clean ) cleanBuild=1 ;; + --clang-tidy ) flags+=(-DCMAKE_EXPORT_COMPILE_COMMANDS=ON); clangTidy=1 ;; --clang ) useClang=1 ;; --cppcheck ) cppcheck=1 ;; --dev|--devel ) flags+=(-DCMAKE_BUILD_TYPE=Devel) ;; @@ -74,6 +76,7 @@ for ARG in "$@"; do echo echo "** Quality & Assurance (Please install the external tool) **" echo "--asan : Enable Address sanitizer" + echo "--clang-tidy : Do a clang-tidy analysis. Results can be found in build directory" echo "--cppcheck : Do a cppcheck analysis. Results can be found in build directory" echo "--coverity : Do a build for coverity" @@ -128,6 +131,9 @@ else ncpu=$(grep -w -c processor /proc/cpuinfo) fi +############################################################ +# CPP check build +############################################################ if [[ "$cppcheck" -eq 1 ]] && [[ -x `which cppcheck` ]]; then summary=cpp_check_summary.log rm -f $summary @@ -149,13 +155,45 @@ if [[ "$cppcheck" -eq 1 ]] && [[ -x `which cppcheck` ]]; then exit 0 fi +############################################################ +# Clang tidy build +############################################################ +if [[ "$clangTidy" -eq 1 ]] && [[ -x `which clang-tidy` ]]; then + compile_json=compile_commands.json + cpp_list=cpp_file.txt + summary=clang_tidy_summary.txt + rm -f $summary + touch $summary + + grep '"file"' $compile_json | sed -e 's/"//g' | sed -e 's/^\s*file\s*:\s*//' > $cpp_list + + for cpp in `cat $cpp_list` + do + # Check all, likely severals millions of log... + #clang-tidy -p $compile_json $cpp -checks='*' -header-filter='.*' + + # Don't check header, don't check google/llvm coding conventions + echo "$count/$total" + clang-tidy -p $compile_json $cpp -checks='*,-llvm-*,-google-*' >> $summary + done + + exit 0 +fi + +############################################################ +# Coverity build +############################################################ 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) -else - make -j"$ncpu" 2>&1 | tee -a $log - make install 2>&1 | tee -a $log + exit 0 fi +############################################################ +# Real build +############################################################ +make -j"$ncpu" 2>&1 | tee -a $log +make install 2>&1 | tee -a $log + exit 0