build-scripts/checker-buildbot.sh
author Sam Lantinga <slouken@libsdl.org>
Fri, 02 Dec 2016 21:01:13 -0800
changeset 10673 4f02752f8d85
parent 10652 c3fbfa229d71
child 11170 b5fe34e8401f
permissions -rwxr-xr-x
Added SDL_HINT_MOUSE_NORMAL_SPEED_SCALE and SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE to scale the speed of the mouse.
This currently doesn't affect absolute motion, which would need to be implemented on each windowing system so the cursor matches the reported mouse coordinates.
icculus@8635
     1
#!/bin/bash
icculus@8635
     2
icculus@8635
     3
# This is a script used by some Buildbot buildslaves to push the project
icculus@8635
     4
#  through Clang's static analyzer and prepare the output to be uploaded
icculus@8635
     5
#  back to the buildmaster. You might find it useful too.
icculus@8635
     6
icculus@8644
     7
# Install Clang (you already have it on Mac OS X, apt-get install clang
icculus@8644
     8
#  on Ubuntu, etc),
icculus@8644
     9
# or download checker at http://clang-analyzer.llvm.org/ and unpack it in
icculus@8635
    10
#  /usr/local ... update CHECKERDIR as appropriate.
icculus@8635
    11
icculus@8635
    12
FINALDIR="$1"
icculus@8635
    13
icculus@10649
    14
CHECKERDIR="/usr/local/checker-279"
icculus@8635
    15
if [ ! -d "$CHECKERDIR" ]; then
icculus@8639
    16
    echo "$CHECKERDIR not found. Trying /usr/share/clang ..." 1>&2
icculus@8639
    17
    CHECKERDIR="/usr/share/clang/scan-build"
icculus@8639
    18
fi
icculus@8639
    19
icculus@8639
    20
if [ ! -d "$CHECKERDIR" ]; then
icculus@8639
    21
    echo "$CHECKERDIR not found. Giving up." 1>&2
icculus@8635
    22
    exit 1
icculus@8635
    23
fi
icculus@8635
    24
icculus@8635
    25
if [ -z "$MAKE" ]; then
icculus@8635
    26
    OSTYPE=`uname -s`
icculus@8635
    27
    if [ "$OSTYPE" == "Linux" ]; then
icculus@8635
    28
        NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
icculus@8635
    29
        let NCPU=$NCPU+1
icculus@8635
    30
    elif [ "$OSTYPE" = "Darwin" ]; then
icculus@8635
    31
        NCPU=`sysctl -n hw.ncpu`
icculus@8635
    32
    elif [ "$OSTYPE" = "SunOS" ]; then
icculus@8635
    33
        NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
icculus@8635
    34
    else
icculus@8635
    35
        NCPU=1
icculus@8635
    36
    fi
icculus@8635
    37
icculus@8635
    38
    if [ -z "$NCPU" ]; then
icculus@8635
    39
        NCPU=1
icculus@8635
    40
    elif [ "$NCPU" = "0" ]; then
icculus@8635
    41
        NCPU=1
icculus@8635
    42
    fi
icculus@8635
    43
icculus@8635
    44
    MAKE="make -j$NCPU"
icculus@8635
    45
fi
icculus@8635
    46
icculus@8635
    47
echo "\$MAKE is '$MAKE'"
icculus@8635
    48
icculus@10652
    49
# Unset $MAKE so submakes don't use it.
icculus@10652
    50
MAKECOMMAND="$MAKE"
icculus@10652
    51
unset MAKE
icculus@10652
    52
icculus@8635
    53
set -x
icculus@8635
    54
set -e
icculus@8635
    55
icculus@8635
    56
cd `dirname "$0"`
icculus@8635
    57
cd ..
icculus@8635
    58
icculus@8635
    59
rm -rf checker-buildbot analysis
icculus@8635
    60
if [ ! -z "$FINALDIR" ]; then
icculus@8635
    61
    rm -rf "$FINALDIR"
icculus@8635
    62
fi
icculus@8635
    63
icculus@8635
    64
mkdir checker-buildbot
icculus@8635
    65
cd checker-buildbot
icculus@8644
    66
icculus@10652
    67
# We turn off deprecated declarations, because we don't care about these warnings during static analysis.
icculus@10652
    68
# The -Wno-liblto is new since our checker-279 upgrade, I think; checker otherwise warns "libLTO.dylib relative to clang installed dir not found"
icculus@10652
    69
icculus@8644
    70
# You might want to do this for CMake-backed builds instead...
icculus@10652
    71
PATH="$CHECKERDIR/bin:$PATH" scan-build -o analysis cmake -Wno-dev -DCMAKE_BUILD_TYPE=Debug -DASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_SHARED_LINKER_FLAGS="-Wno-liblto" ..
icculus@8644
    72
icculus@8644
    73
# ...or run configure without the scan-build wrapper...
icculus@10652
    74
#CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0 -Wno-deprecated-declarations" LDFLAGS="-Wno-liblto" ../configure --enable-assertions=enabled
icculus@8644
    75
icculus@8639
    76
rm -rf analysis
icculus@10652
    77
PATH="$CHECKERDIR/bin:$PATH" scan-build -o analysis $MAKECOMMAND
icculus@10649
    78
icculus@10649
    79
if [ `ls -A analysis |wc -l` == 0 ] ; then
icculus@10649
    80
    mkdir analysis/zarro
icculus@10649
    81
    echo '<html><head><title>Zarro boogs</title></head><body>Static analysis: no issues to report.</body></html>' >analysis/zarro/index.html
icculus@10649
    82
fi
icculus@10649
    83
icculus@8635
    84
mv analysis/* ../analysis
icculus@8635
    85
rmdir analysis   # Make sure this is empty.
icculus@8635
    86
cd ..
icculus@8635
    87
chmod -R a+r analysis
icculus@8635
    88
chmod -R go-w analysis
icculus@8635
    89
find analysis -type d -exec chmod a+x {} \;
icculus@8635
    90
if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
icculus@8635
    91
icculus@8635
    92
if [ ! -z "$FINALDIR" ]; then
icculus@8635
    93
    mv analysis "$FINALDIR"
icculus@8635
    94
else
icculus@8635
    95
    FINALDIR=analysis
icculus@8635
    96
fi
icculus@8635
    97
icculus@8635
    98
rm -rf checker-buildbot
icculus@8635
    99
icculus@8635
   100
echo "Done. Final output is in '$FINALDIR' ..."
icculus@8635
   101
icculus@8635
   102
# end of checker-buildbot.sh ...
icculus@8635
   103