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