codechecker-buildbot.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. # This is a script used by some Buildbot build workers to push the project
  3. # through Clang's static analyzer and prepare the output to be uploaded
  4. # back to the buildmaster. You might find it useful too.
  5. # Install Clang (you already have it on macOS, apt-get install clang
  6. # on Ubuntu, etc), install CMake, and pip3 install codechecker.
  7. FINALDIR="$1"
  8. set -x
  9. set -e
  10. cd `dirname "$0"`
  11. cd ..
  12. rm -rf codechecker-buildbot
  13. if [ ! -z "$FINALDIR" ]; then
  14. rm -rf "$FINALDIR"
  15. fi
  16. mkdir codechecker-buildbot
  17. cd codechecker-buildbot
  18. # We turn off deprecated declarations, because we don't care about these warnings during static analysis.
  19. cmake -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DSDL_ASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
  20. # CMake on macOS adds "-arch arm64" or whatever is appropriate, but this confuses CodeChecker, so strip it out.
  21. perl -w -pi -e 's/\-arch\s+.*?\s+//g;' compile_commands.json
  22. rm -rf ../analysis
  23. CodeChecker analyze compile_commands.json -o ./reports
  24. # "parse" returns 2 if there was a static analysis issue to report, but this
  25. # does not signify an error in the parsing (that would be error code 1). Turn
  26. # off the abort-on-error flag.
  27. set +e
  28. CodeChecker parse ./reports -e html -o ../analysis
  29. set -e
  30. cd ..
  31. chmod -R a+r analysis
  32. chmod -R go-w analysis
  33. find analysis -type d -exec chmod a+x {} \;
  34. if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
  35. if [ ! -z "$FINALDIR" ]; then
  36. mv analysis "$FINALDIR"
  37. else
  38. FINALDIR=analysis
  39. fi
  40. rm -rf codechecker-buildbot
  41. echo "Done. Final output is in '$FINALDIR' ..."
  42. # end of codechecker-buildbot.sh ...