Added a script to let buildslaves run Clang static analysis.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 19 Mar 2014 00:58:32 -0400
changeset 8635f1076ec9e707
parent 8634 a60eaa04d3fb
child 8636 c10618240799
Added a script to let buildslaves run Clang static analysis.
build-scripts/checker-buildbot.sh
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build-scripts/checker-buildbot.sh	Wed Mar 19 00:58:32 2014 -0400
     1.3 @@ -0,0 +1,85 @@
     1.4 +#!/bin/bash
     1.5 +
     1.6 +# This is a script used by some Buildbot buildslaves to push the project
     1.7 +#  through Clang's static analyzer and prepare the output to be uploaded
     1.8 +#  back to the buildmaster. You might find it useful too.
     1.9 +
    1.10 +# To use: get CMake from http://cmake.org/ or "apt-get install cmake" or whatever.
    1.11 +# And download checker at http://clang-analyzer.llvm.org/ and unpack it in
    1.12 +#  /usr/local ... update CHECKERDIR as appropriate.
    1.13 +
    1.14 +# this currently expects a mercurial working copy that it can modify a little.
    1.15 +
    1.16 +CHECKERDIR="/usr/local/checker-276"
    1.17 +
    1.18 +FINALDIR="$1"
    1.19 +
    1.20 +if [ ! -d "$CHECKERDIR" ]; then
    1.21 +    echo "$CHECKERDIR not found." 1>&2
    1.22 +    exit 1
    1.23 +fi
    1.24 +
    1.25 +if [ -z "$MAKE" ]; then
    1.26 +    OSTYPE=`uname -s`
    1.27 +    if [ "$OSTYPE" == "Linux" ]; then
    1.28 +        NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
    1.29 +        let NCPU=$NCPU+1
    1.30 +    elif [ "$OSTYPE" = "Darwin" ]; then
    1.31 +        NCPU=`sysctl -n hw.ncpu`
    1.32 +    elif [ "$OSTYPE" = "SunOS" ]; then
    1.33 +        NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
    1.34 +    else
    1.35 +        NCPU=1
    1.36 +    fi
    1.37 +
    1.38 +    if [ -z "$NCPU" ]; then
    1.39 +        NCPU=1
    1.40 +    elif [ "$NCPU" = "0" ]; then
    1.41 +        NCPU=1
    1.42 +    fi
    1.43 +
    1.44 +    MAKE="make -j$NCPU"
    1.45 +fi
    1.46 +
    1.47 +echo "\$MAKE is '$MAKE'"
    1.48 +
    1.49 +set -x
    1.50 +set -e
    1.51 +
    1.52 +cd `dirname "$0"`
    1.53 +cd ..
    1.54 +
    1.55 +# Turn off the dynamic API. Makes the analysis output clearer.
    1.56 +echo '#pragma once' >src/dynapi/SDL_dynapi.h
    1.57 +echo '#define SDL_DYNAMIC_API 0' >>src/dynapi/SDL_dynapi.h
    1.58 +
    1.59 +rm -rf checker-buildbot analysis
    1.60 +if [ ! -z "$FINALDIR" ]; then
    1.61 +    rm -rf "$FINALDIR"
    1.62 +fi
    1.63 +
    1.64 +mkdir checker-buildbot
    1.65 +cd checker-buildbot
    1.66 +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="$CHECKERDIR/libexec/ccc-analyzer" ..
    1.67 +PATH="$CHECKERDIR:$PATH" scan-build -o analysis $MAKE
    1.68 +mv analysis/* ../analysis
    1.69 +rmdir analysis   # Make sure this is empty.
    1.70 +cd ..
    1.71 +chmod -R a+r analysis
    1.72 +chmod -R go-w analysis
    1.73 +find analysis -type d -exec chmod a+x {} \;
    1.74 +if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
    1.75 +
    1.76 +if [ ! -z "$FINALDIR" ]; then
    1.77 +    mv analysis "$FINALDIR"
    1.78 +else
    1.79 +    FINALDIR=analysis
    1.80 +fi
    1.81 +
    1.82 +rm -rf checker-buildbot
    1.83 +hg revert src/dynapi/SDL_dynapi.h
    1.84 +
    1.85 +echo "Done. Final output is in '$FINALDIR' ..."
    1.86 +
    1.87 +# end of checker-buildbot.sh ...
    1.88 +