sonar-scanner.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. export CPPCHECK_INCLUDES="-Iinclude -Impi/include"
  3. export SOURCES_TO_ANALYZE="include src mpi/src tools tests examples mpi/tests mpi/examples"
  4. export SONAR_SOURCES=$(echo $SOURCES_TO_ANALYZE | tr ' ' ',')
  5. export SOURCES_TO_EXCLUDE="-itools/dev"
  6. if test -z "$SONAR_LOGIN_FILE"
  7. then
  8. echo "Error. Environment variable SONAR_LOGIN_FILE missing"
  9. exit 1
  10. fi
  11. SONAR_PROJECT=storm:starpu_trunk
  12. SONAR_LOGIN=$(grep ${SONAR_PROJECT} ${SONAR_LOGIN_FILE} | awk '{print $2}')
  13. if test -z "$SONAR_LOGIN"
  14. then
  15. echo "Error. Project ${SONAR_PROJECT} not available in file ${SONAR_LOGIN_FILE}"
  16. exit 1
  17. fi
  18. if test -f build/config.log
  19. then
  20. CONFIG_LOG=build/config.log
  21. elif test -f config.log
  22. then
  23. CONFIG_LOG=config.log
  24. else
  25. echo Error no config.log file found
  26. exit 1
  27. fi
  28. export DEFINITIONS_LOG=$(grep "^#define" ${CONFIG_LOG} | sed -e "s#\#define #-D#g" | sed -e "s# #=#g" | xargs)
  29. export DEFINITIONS_SRC=$(grep "^#undef" src/common/config.h.in| sed -e "s#\#undef #-D#g" | sed -e "s#\$#=1#g" | xargs)
  30. export DEFINITIONS_LOCAL=$(grep -rs "#ifdef" src/ mpi/src |awk -F':' '{print $2}' | awk '{print "-D"$2"=1"}' |sort|uniq)
  31. export DEFINITIONS="${DEFINITIONS_LOG} ${DEFINITIONS_SRC} ${DEFINITIONS_LOCAL}"
  32. cppcheck --max-configs=1000 --language=c++ --platform=unix64 --force -v --enable=all --inline-suppr --xml --xml-version=2 ${DEFINITIONS} ${CPPCHECK_INCLUDES} ${SOURCES_TO_EXCLUDE} ${SOURCES_TO_ANALYZE} 2> cppcheck.xml
  33. #--suppressions-list=tools/cppcheck/suppressions.txt
  34. sonar-scanner -Dsonar.login=${SONAR_LOGIN} -Dsonar.projectKey=${SONAR_PROJECT} -Dsonar.projectName=StarPU_trunk -Dsonar.projectVersion=HEAD -Dsonar.sources=${SONAR_SOURCES} -Dsonar.cxx.cppcheck.reportPath=cppcheck.xml