checker-buildbot.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. # To use: get CMake from http://cmake.org/ or "apt-get install cmake" or whatever.
  6. # And download checker at http://clang-analyzer.llvm.org/ and unpack it in
  7. # /usr/local ... update CHECKERDIR as appropriate.
  8. # this currently expects a mercurial working copy that it can modify a little.
  9. CHECKERDIR="/usr/local/checker-276"
  10. FINALDIR="$1"
  11. if [ ! -d "$CHECKERDIR" ]; then
  12. echo "$CHECKERDIR not found." 1>&2
  13. exit 1
  14. fi
  15. if [ -z "$MAKE" ]; then
  16. OSTYPE=`uname -s`
  17. if [ "$OSTYPE" == "Linux" ]; then
  18. NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
  19. let NCPU=$NCPU+1
  20. elif [ "$OSTYPE" = "Darwin" ]; then
  21. NCPU=`sysctl -n hw.ncpu`
  22. elif [ "$OSTYPE" = "SunOS" ]; then
  23. NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
  24. else
  25. NCPU=1
  26. fi
  27. if [ -z "$NCPU" ]; then
  28. NCPU=1
  29. elif [ "$NCPU" = "0" ]; then
  30. NCPU=1
  31. fi
  32. MAKE="make -j$NCPU"
  33. fi
  34. echo "\$MAKE is '$MAKE'"
  35. set -x
  36. set -e
  37. cd `dirname "$0"`
  38. cd ..
  39. # Turn off the dynamic API. Makes the analysis output clearer.
  40. echo '#pragma once' >src/dynapi/SDL_dynapi.h
  41. echo '#define SDL_DYNAMIC_API 0' >>src/dynapi/SDL_dynapi.h
  42. rm -rf checker-buildbot analysis
  43. if [ ! -z "$FINALDIR" ]; then
  44. rm -rf "$FINALDIR"
  45. fi
  46. mkdir checker-buildbot
  47. cd checker-buildbot
  48. #cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="$CHECKERDIR/libexec/ccc-analyzer" -DSDL_STATIC=OFF ..
  49. CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0" ../configure --disable-static
  50. PATH="$CHECKERDIR:$PATH" scan-build -o analysis $MAKE
  51. mv analysis/* ../analysis
  52. rmdir analysis # Make sure this is empty.
  53. cd ..
  54. chmod -R a+r analysis
  55. chmod -R go-w analysis
  56. find analysis -type d -exec chmod a+x {} \;
  57. if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
  58. if [ ! -z "$FINALDIR" ]; then
  59. mv analysis "$FINALDIR"
  60. else
  61. FINALDIR=analysis
  62. fi
  63. rm -rf checker-buildbot
  64. hg revert src/dynapi/SDL_dynapi.h
  65. echo "Done. Final output is in '$FINALDIR' ..."
  66. # end of checker-buildbot.sh ...