codechecker-buildbot.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 -DASSERTIONS=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. CodeChecker parse ./reports -e html -o ../analysis
  25. cd ..
  26. chmod -R a+r analysis
  27. chmod -R go-w analysis
  28. find analysis -type d -exec chmod a+x {} \;
  29. if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
  30. if [ ! -z "$FINALDIR" ]; then
  31. mv analysis "$FINALDIR"
  32. else
  33. FINALDIR=analysis
  34. fi
  35. rm -rf codechecker-buildbot
  36. echo "Done. Final output is in '$FINALDIR' ..."
  37. # end of codechecker-buildbot.sh ...