build-scripts/checker-buildbot.sh
author Ryan C. Gordon <icculus@icculus.org>
Wed, 19 Mar 2014 16:02:25 -0400
changeset 8640 89bab8249c74
parent 8639 21093d07b958
child 8644 f218b4e65498
permissions -rwxr-xr-x
Don't overwrite SDL_dynapi.h in checker-buildbot.sh.
     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 # To use: get CMake from http://cmake.org/ or "apt-get install cmake" or whatever.
     8 # And download checker at http://clang-analyzer.llvm.org/ and unpack it in
     9 #  /usr/local ... update CHECKERDIR as appropriate.
    10 
    11 FINALDIR="$1"
    12 
    13 CHECKERDIR="/usr/local/checker-276"
    14 if [ ! -d "$CHECKERDIR" ]; then
    15     echo "$CHECKERDIR not found. Trying /usr/share/clang ..." 1>&2
    16     CHECKERDIR="/usr/share/clang/scan-build"
    17 fi
    18 
    19 if [ ! -d "$CHECKERDIR" ]; then
    20     echo "$CHECKERDIR not found. Giving up." 1>&2
    21     exit 1
    22 fi
    23 
    24 if [ -z "$MAKE" ]; then
    25     OSTYPE=`uname -s`
    26     if [ "$OSTYPE" == "Linux" ]; then
    27         NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
    28         let NCPU=$NCPU+1
    29     elif [ "$OSTYPE" = "Darwin" ]; then
    30         NCPU=`sysctl -n hw.ncpu`
    31     elif [ "$OSTYPE" = "SunOS" ]; then
    32         NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
    33     else
    34         NCPU=1
    35     fi
    36 
    37     if [ -z "$NCPU" ]; then
    38         NCPU=1
    39     elif [ "$NCPU" = "0" ]; then
    40         NCPU=1
    41     fi
    42 
    43     MAKE="make -j$NCPU"
    44 fi
    45 
    46 echo "\$MAKE is '$MAKE'"
    47 
    48 set -x
    49 set -e
    50 
    51 cd `dirname "$0"`
    52 cd ..
    53 
    54 rm -rf checker-buildbot analysis
    55 if [ ! -z "$FINALDIR" ]; then
    56     rm -rf "$FINALDIR"
    57 fi
    58 
    59 mkdir checker-buildbot
    60 cd checker-buildbot
    61 #cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="$CHECKERDIR/libexec/ccc-analyzer" -DSDL_STATIC=OFF ..
    62 #CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0" ../configure
    63 CFLAGS="-O0" PATH="$CHECKERDIR:$PATH" scan-build -o analysis ../configure
    64 rm -rf analysis
    65 PATH="$CHECKERDIR:$PATH" scan-build -o analysis $MAKE
    66 mv analysis/* ../analysis
    67 rmdir analysis   # Make sure this is empty.
    68 cd ..
    69 chmod -R a+r analysis
    70 chmod -R go-w analysis
    71 find analysis -type d -exec chmod a+x {} \;
    72 if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
    73 
    74 if [ ! -z "$FINALDIR" ]; then
    75     mv analysis "$FINALDIR"
    76 else
    77     FINALDIR=analysis
    78 fi
    79 
    80 rm -rf checker-buildbot
    81 
    82 echo "Done. Final output is in '$FINALDIR' ..."
    83 
    84 # end of checker-buildbot.sh ...
    85