🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.9 KiB

  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),
  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. if [ -z "$MAKE" ]; then
  20. OSTYPE=`uname -s`
  21. if [ "$OSTYPE" == "Linux" ]; then
  22. NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
  23. let NCPU=$NCPU+1
  24. elif [ "$OSTYPE" = "Darwin" ]; then
  25. NCPU=`sysctl -n hw.ncpu`
  26. elif [ "$OSTYPE" = "SunOS" ]; then
  27. NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
  28. else
  29. NCPU=1
  30. fi
  31. if [ -z "$NCPU" ]; then
  32. NCPU=1
  33. elif [ "$NCPU" = "0" ]; then
  34. NCPU=1
  35. fi
  36. MAKE="make -j$NCPU"
  37. fi
  38. echo "\$MAKE is '$MAKE'"
  39. # Unset $MAKE so submakes don't use it.
  40. MAKECOMMAND="$MAKE"
  41. unset MAKE
  42. set -x
  43. set -e
  44. cd `dirname "$0"`
  45. cd ..
  46. rm -rf checker-buildbot analysis
  47. if [ ! -z "$FINALDIR" ]; then
  48. rm -rf "$FINALDIR"
  49. fi
  50. mkdir checker-buildbot
  51. cd checker-buildbot
  52. # We turn off deprecated declarations, because we don't care about these warnings during static analysis.
  53. # The -Wno-liblto is new since our checker-279 upgrade, I think; checker otherwise warns "libLTO.dylib relative to clang installed dir not found"
  54. # You might want to do this for CMake-backed builds instead...
  55. PATH="$CHECKERDIR/bin:$PATH" scan-build -o analysis cmake -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_SHARED_LINKER_FLAGS="-Wno-liblto" ..
  56. # ...or run configure without the scan-build wrapper...
  57. #CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0 -Wno-deprecated-declarations" LDFLAGS="-Wno-liblto" ../configure --enable-assertions=enabled
  58. rm -rf analysis
  59. PATH="$CHECKERDIR/bin:$PATH" scan-build -o analysis $MAKECOMMAND
  60. if [ `ls -A analysis |wc -l` == 0 ] ; then
  61. mkdir analysis/zarro
  62. echo '<html><head><title>Zarro boogs</title></head><body>Static analysis: no issues to report.</body></html>' >analysis/zarro/index.html
  63. fi
  64. mv analysis/* ../analysis
  65. rmdir analysis # Make sure this is empty.
  66. cd ..
  67. chmod -R a+r analysis
  68. chmod -R go-w analysis
  69. find analysis -type d -exec chmod a+x {} \;
  70. if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
  71. if [ ! -z "$FINALDIR" ]; then
  72. mv analysis "$FINALDIR"
  73. else
  74. FINALDIR=analysis
  75. fi
  76. rm -rf checker-buildbot
  77. echo "Done. Final output is in '$FINALDIR' ..."
  78. # end of checker-buildbot.sh ...