#!/bin/sh # Copyright (c) 2011-2014 Ulrich Spoerlein <[email protected]> # Copyright (c) 2014-2015 Li-Wen Hsu <[email protected]> # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. WORKDIR=`pwd -P` SCAN_BUILD=/usr/local/bin/scan-build-devel SRCDIR=${WORKDIR}/src export OBJ=${WORKDIR}/obj export MAKEOBJDIRPREFIX=${OBJ} DEST=${WORKDIR}/clangScanBuildReports SRCCONF=${WORKDIR}/freebsd-ci/scan-build/src.conf XCC=/usr/local/llvm-devel/bin/clang XCXX=/usr/local/llvm-devel/bin/clang++ XCPP=/usr/local/llvm-devel/bin/clang-cpp X_COMPILER_TYPE=clang MYFLAGS="__MAKE_CONF=/dev/null -m $SRCDIR/share/mk SRCCONF=${SRCCONF} -DMODULES_WITH_WORLD XCC=${XCC} XCXX=${XCXX} XCPP=${XCPP}" DATE=`date "+%Y-%m-%d"` ARCH=`uname -p` JFLAG=-j4 do_scan() { /usr/bin/time -l \ env CCC_ANALYZER_CHECKER_DEADCODE=0 \ ${SCAN_BUILD} \ --use-cc ${XCC} \ --use-c++ ${XCXX} \ -k -o $DEST $@ } echo "-=-> scan started at `date "+%Y-%m-%d %H:%M:%S"`" cd $SRCDIR || exit 1 rm -fr "$DEST" mkdir -p "$DEST" rm -f Makefile.scanbuild ( cat <<EOF all: \${MAKE} -f Makefile ${JFLAG} ${MYFLAGS} NO_CLEAN=yes NO_KERNELCLEAN=yes bmake \${MAKE} -f Makefile ${JFLAG} ${MYFLAGS} NO_CLEAN=yes NO_KERNELCLEAN=yes kernel-toolchain \${MAKE} -f Makefile ${JFLAG} ${MYFLAGS} NO_CLEAN=yes NO_KERNELCLEAN=yes KERNCONF=GENERIC buildkernel # \${MAKE} -f Makefile ${JFLAG} ${MYFLAGS} NO_CLEAN=yes NO_KERNELCLEAN=yes KERNCONF=LINT buildkernel EOF ) > Makefile.scanbuild do_scan make -f Makefile.scanbuild echo "-=-> scan finished at `date "+%Y-%m-%d %H:%M:%S"`"