buildbot-checker.sh 2.4 KB

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