extras/buildbot-checker.sh
author Ryan C. Gordon <icculus@icculus.org>
Sun, 17 May 2020 00:58:55 -0400
branchstable-3.0
changeset 1688 62804a972e79
parent 1425 176efd35457c
permissions -rwxr-xr-x
Move buildbot script changes to stable-3.0 branch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1411
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
#!/bin/bash
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
1688
62804a972e79 Move buildbot script changes to stable-3.0 branch.
Ryan C. Gordon <icculus@icculus.org>
parents: 1425
diff changeset
     3
# This is a script used by some Buildbot workers to push the project
1411
c69e2a678c5a Added script to 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
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
#  back to the buildmaster. You might find it useful too.
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
# Install Clang (you already have it on Mac OS X, apt-get install clang
1688
62804a972e79 Move buildbot script changes to stable-3.0 branch.
Ryan C. Gordon <icculus@icculus.org>
parents: 1425
diff changeset
     8
#  on Ubuntu, etc), Make sure "scan-build" is in your $PATH.
1411
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
FINALDIR="$1"
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
set -x
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
set -e
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
cd `dirname "$0"`
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
cd ..
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
rm -rf checker-buildbot analysis
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
if [ ! -z "$FINALDIR" ]; then
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
    rm -rf "$FINALDIR"
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
fi
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
mkdir checker-buildbot
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
cd checker-buildbot
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
# We turn off deprecated declarations, because we don't care about these warnings during static analysis.
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    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"
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
# You might want to do this for CMake-backed builds instead...
1688
62804a972e79 Move buildbot script changes to stable-3.0 branch.
Ryan C. Gordon <icculus@icculus.org>
parents: 1425
diff changeset
    30
scan-build -o analysis cmake -G Ninja -Wno-dev -DPHYSFS_BUILD_SHARED=False -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_EXE_LINKER_FLAGS="-Wno-liblto" ..
1411
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
rm -rf analysis
1688
62804a972e79 Move buildbot script changes to stable-3.0 branch.
Ryan C. Gordon <icculus@icculus.org>
parents: 1425
diff changeset
    33
scan-build -o analysis cmake --build . --config Debug
1411
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
if [ `ls -A analysis |wc -l` == 0 ] ; then
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
    mkdir analysis/zarro
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
    echo '<html><head><title>Zarro boogs</title></head><body>Static analysis: no issues to report.</body></html>' >analysis/zarro/index.html
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
fi
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
mv analysis/* ../analysis
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
rmdir analysis   # Make sure this is empty.
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
cd ..
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
chmod -R a+r analysis
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
chmod -R go-w analysis
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
find analysis -type d -exec chmod a+x {} \;
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
if [ ! -z "$FINALDIR" ]; then
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
    mv analysis "$FINALDIR"
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
else
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
    FINALDIR=analysis
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
fi
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
rm -rf checker-buildbot
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
echo "Done. Final output is in '$FINALDIR' ..."
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
# end of checker-buildbot.sh ...
c69e2a678c5a Added script to run Clang static analysis.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59