checker-buildbot.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # This is a script used by some Buildbot buildslaves 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 Mac OS X, apt-get install clang
  6. # on Ubuntu, etc), and make sure scan-build is in your $PATH.
  7. FINALDIR="$1"
  8. set -x
  9. set -e
  10. cd `dirname "$0"`
  11. cd ..
  12. rm -rf checker-buildbot analysis
  13. if [ ! -z "$FINALDIR" ]; then
  14. rm -rf "$FINALDIR"
  15. fi
  16. mkdir checker-buildbot
  17. cd checker-buildbot
  18. # We turn off deprecated declarations, because we don't care about these warnings during static analysis.
  19. # The -Wno-liblto is new since our checker-279 upgrade, I think; checker otherwise warns "libLTO.dylib relative to clang installed dir not found"
  20. # You might want to do this for CMake-backed builds instead...
  21. scan-build -o analysis cmake -G Ninja -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DSDL_ASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_SHARED_LINKER_FLAGS="-Wno-liblto" ..
  22. # ...or run configure without the scan-build wrapper...
  23. #CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0 -Wno-deprecated-declarations" LDFLAGS="-Wno-liblto" ../configure --enable-assertions=enabled
  24. rm -rf analysis
  25. scan-build -o analysis ninja
  26. if [ `ls -A analysis |wc -l` == 0 ] ; then
  27. mkdir analysis/zarro
  28. echo '<html><head><title>Zarro boogs</title></head><body>Static analysis: no issues to report.</body></html>' >analysis/zarro/index.html
  29. fi
  30. mv analysis/* ../analysis
  31. rmdir analysis # Make sure this is empty.
  32. cd ..
  33. chmod -R a+r analysis
  34. chmod -R go-w analysis
  35. find analysis -type d -exec chmod a+x {} \;
  36. if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
  37. if [ ! -z "$FINALDIR" ]; then
  38. mv analysis "$FINALDIR"
  39. else
  40. FINALDIR=analysis
  41. fi
  42. rm -rf checker-buildbot
  43. echo "Done. Final output is in '$FINALDIR' ..."
  44. # end of checker-buildbot.sh ...