Simple Directmedia Layer
at main 1.7 kB view raw
1#!/bin/bash 2 3# This is a script used by some Buildbot build workers 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# Install Clang (you already have it on macOS, apt-get install clang 8# on Ubuntu, etc), install CMake, and pip3 install codechecker. 9 10FINALDIR="$1" 11 12set -x 13set -e 14 15cd `dirname "$0"` 16cd .. 17 18rm -rf codechecker-buildbot 19if [ ! -z "$FINALDIR" ]; then 20 rm -rf "$FINALDIR" 21fi 22 23mkdir codechecker-buildbot 24cd codechecker-buildbot 25 26# We turn off deprecated declarations, because we don't care about these warnings during static analysis. 27cmake -Wno-dev -DSDL_STATIC=OFF -DCMAKE_BUILD_TYPE=Debug -DSDL_ASSERTIONS=enabled -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. 28 29# CMake on macOS adds "-arch arm64" or whatever is appropriate, but this confuses CodeChecker, so strip it out. 30perl -w -pi -e 's/\-arch\s+.*?\s+//g;' compile_commands.json 31 32rm -rf ../analysis 33CodeChecker analyze compile_commands.json -o ./reports 34 35# "parse" returns 2 if there was a static analysis issue to report, but this 36# does not signify an error in the parsing (that would be error code 1). Turn 37# off the abort-on-error flag. 38set +e 39CodeChecker parse ./reports -e html -o ../analysis 40set -e 41 42cd .. 43chmod -R a+r analysis 44chmod -R go-w analysis 45find analysis -type d -exec chmod a+x {} \; 46if [ -x /usr/bin/xattr ]; then find analysis -exec /usr/bin/xattr -d com.apple.quarantine {} \; 2>/dev/null ; fi 47 48if [ ! -z "$FINALDIR" ]; then 49 mv analysis "$FINALDIR" 50else 51 FINALDIR=analysis 52fi 53 54rm -rf codechecker-buildbot 55 56echo "Done. Final output is in '$FINALDIR' ..." 57 58# end of codechecker-buildbot.sh ... 59