🛠️🐜 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.

101 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. MAKECMD="$MAKE"
  40. unset MAKE # prevent warnings about jobserver mode.
  41. set -x
  42. set -e
  43. cd `dirname "$0"`
  44. cd ..
  45. rm -rf checker-buildbot analysis
  46. if [ ! -z "$FINALDIR" ]; then
  47. rm -rf "$FINALDIR"
  48. fi
  49. mkdir checker-buildbot
  50. cd checker-buildbot
  51. # We turn off deprecated declarations, because we don't care about these warnings during static analysis.
  52. # The -Wno-liblto is new since our checker-279 upgrade, I think; checker otherwise warns "libLTO.dylib relative to clang installed dir not found"
  53. # You might want to do this for CMake-backed builds instead...
  54. PATH="$CHECKERDIR/bin:$PATH" scan-build -o analysis cmake -Wno-dev -DPHYSFS_BUILD_SHARED=False -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_EXE_LINKER_FLAGS="-Wno-liblto" ..
  55. # ...or run configure without the scan-build wrapper...
  56. #CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0 -Wno-deprecated-declarations" LDFLAGS="-Wno-liblto" ../configure --enable-assertions=enabled
  57. rm -rf analysis
  58. PATH="$CHECKERDIR/bin:$PATH" scan-build -o analysis $MAKECMD
  59. if [ `ls -A analysis |wc -l` == 0 ] ; then
  60. mkdir analysis/zarro
  61. echo '<html><head><title>Zarro boogs</title></head><body>Static analysis: no issues to report.</body></html>' >analysis/zarro/index.html
  62. fi
  63. mv analysis/* ../analysis
  64. rmdir analysis # Make sure this is empty.
  65. cd ..
  66. chmod -R a+r analysis
  67. chmod -R go-w analysis
  68. find analysis -type d -exec chmod a+x {} \;
  69. if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
  70. if [ ! -z "$FINALDIR" ]; then
  71. mv analysis "$FINALDIR"
  72. else
  73. FINALDIR=analysis
  74. fi
  75. rm -rf checker-buildbot
  76. echo "Done. Final output is in '$FINALDIR' ..."
  77. # end of checker-buildbot.sh ...