build-scripts/checker-buildbot.sh
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 10046 4b62fb588d22
permissions -rwxr-xr-x
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8635
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
#!/bin/bash
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
# This is a script used by some Buildbot buildslaves to push the project
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
#  through Clang's static analyzer and prepare the output to be uploaded
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
#  back to the buildmaster. You might find it useful too.
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
8644
f218b4e65498 Minor comment cleanups in checker-buildbot.sh
Ryan C. Gordon <icculus@icculus.org>
parents: 8640
diff changeset
     7
# Install Clang (you already have it on Mac OS X, apt-get install clang
f218b4e65498 Minor comment cleanups in checker-buildbot.sh
Ryan C. Gordon <icculus@icculus.org>
parents: 8640
diff changeset
     8
#  on Ubuntu, etc),
f218b4e65498 Minor comment cleanups in checker-buildbot.sh
Ryan C. Gordon <icculus@icculus.org>
parents: 8640
diff changeset
     9
# or download checker at http://clang-analyzer.llvm.org/ and unpack it in
8635
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
#  /usr/local ... update CHECKERDIR as appropriate.
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
FINALDIR="$1"
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
8639
21093d07b958 Make checker-buildbot.sh work just about anywhere Clang is installed.
Ryan C. Gordon <icculus@icculus.org>
parents: 8638
diff changeset
    14
CHECKERDIR="/usr/local/checker-276"
8635
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
if [ ! -d "$CHECKERDIR" ]; then
8639
21093d07b958 Make checker-buildbot.sh work just about anywhere Clang is installed.
Ryan C. Gordon <icculus@icculus.org>
parents: 8638
diff changeset
    16
    echo "$CHECKERDIR not found. Trying /usr/share/clang ..." 1>&2
21093d07b958 Make checker-buildbot.sh work just about anywhere Clang is installed.
Ryan C. Gordon <icculus@icculus.org>
parents: 8638
diff changeset
    17
    CHECKERDIR="/usr/share/clang/scan-build"
21093d07b958 Make checker-buildbot.sh work just about anywhere Clang is installed.
Ryan C. Gordon <icculus@icculus.org>
parents: 8638
diff changeset
    18
fi
21093d07b958 Make checker-buildbot.sh work just about anywhere Clang is installed.
Ryan C. Gordon <icculus@icculus.org>
parents: 8638
diff changeset
    19
21093d07b958 Make checker-buildbot.sh work just about anywhere Clang is installed.
Ryan C. Gordon <icculus@icculus.org>
parents: 8638
diff changeset
    20
if [ ! -d "$CHECKERDIR" ]; then
21093d07b958 Make checker-buildbot.sh work just about anywhere Clang is installed.
Ryan C. Gordon <icculus@icculus.org>
parents: 8638
diff changeset
    21
    echo "$CHECKERDIR not found. Giving up." 1>&2
8635
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
    exit 1
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
fi
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
if [ -z "$MAKE" ]; then
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
    OSTYPE=`uname -s`
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
    if [ "$OSTYPE" == "Linux" ]; then
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
        NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
        let NCPU=$NCPU+1
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
    elif [ "$OSTYPE" = "Darwin" ]; then
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
        NCPU=`sysctl -n hw.ncpu`
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
    elif [ "$OSTYPE" = "SunOS" ]; then
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
        NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
    else
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
        NCPU=1
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
    fi
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
    if [ -z "$NCPU" ]; then
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
        NCPU=1
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
    elif [ "$NCPU" = "0" ]; then
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
        NCPU=1
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
    fi
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
    MAKE="make -j$NCPU"
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
fi
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
echo "\$MAKE is '$MAKE'"
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
set -x
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
set -e
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
cd `dirname "$0"`
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
cd ..
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
rm -rf checker-buildbot analysis
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
if [ ! -z "$FINALDIR" ]; then
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
    rm -rf "$FINALDIR"
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
fi
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
mkdir checker-buildbot
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
cd checker-buildbot
8644
f218b4e65498 Minor comment cleanups in checker-buildbot.sh
Ryan C. Gordon <icculus@icculus.org>
parents: 8640
diff changeset
    62
f218b4e65498 Minor comment cleanups in checker-buildbot.sh
Ryan C. Gordon <icculus@icculus.org>
parents: 8640
diff changeset
    63
# You might want to do this for CMake-backed builds instead...
10046
4b62fb588d22 Fixed buildbot's static analysis script to enable assertions.
Ryan C. Gordon <icculus@icculus.org>
parents: 9100
diff changeset
    64
PATH="$CHECKERDIR:$PATH" scan-build -o analysis cmake -DCMAKE_BUILD_TYPE=Debug -DASSERTIONS=enabled ..
8644
f218b4e65498 Minor comment cleanups in checker-buildbot.sh
Ryan C. Gordon <icculus@icculus.org>
parents: 8640
diff changeset
    65
f218b4e65498 Minor comment cleanups in checker-buildbot.sh
Ryan C. Gordon <icculus@icculus.org>
parents: 8640
diff changeset
    66
# ...or run configure without the scan-build wrapper...
10046
4b62fb588d22 Fixed buildbot's static analysis script to enable assertions.
Ryan C. Gordon <icculus@icculus.org>
parents: 9100
diff changeset
    67
#CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0" ../configure --enable-assertions=enabled
8644
f218b4e65498 Minor comment cleanups in checker-buildbot.sh
Ryan C. Gordon <icculus@icculus.org>
parents: 8640
diff changeset
    68
9100
441e6cee6d14 Fixed the cmake-guided static analysis and use it by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 8644
diff changeset
    69
# ...but this works for our buildbots just fine (EXCEPT ON LATEST MAC OS X).
10046
4b62fb588d22 Fixed buildbot's static analysis script to enable assertions.
Ryan C. Gordon <icculus@icculus.org>
parents: 9100
diff changeset
    70
#CFLAGS="-O0" PATH="$CHECKERDIR:$PATH" scan-build -o analysis ../configure --enable-assertions=enabled
8644
f218b4e65498 Minor comment cleanups in checker-buildbot.sh
Ryan C. Gordon <icculus@icculus.org>
parents: 8640
diff changeset
    71
8639
21093d07b958 Make checker-buildbot.sh work just about anywhere Clang is installed.
Ryan C. Gordon <icculus@icculus.org>
parents: 8638
diff changeset
    72
rm -rf analysis
8635
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
PATH="$CHECKERDIR:$PATH" scan-build -o analysis $MAKE
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
mv analysis/* ../analysis
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
rmdir analysis   # Make sure this is empty.
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
cd ..
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
chmod -R a+r analysis
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
chmod -R go-w analysis
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
find analysis -type d -exec chmod a+x {} \;
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
if [ ! -z "$FINALDIR" ]; then
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
    mv analysis "$FINALDIR"
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
else
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
    FINALDIR=analysis
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
fi
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
rm -rf checker-buildbot
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
echo "Done. Final output is in '$FINALDIR' ..."
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
# end of checker-buildbot.sh ...
f1076ec9e707 Added a script to let buildslaves run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93