coverity-build.sh 1011 Bytes
Newer Older
Ben Straub committed
1 2
#!/bin/bash

3
set -e
4

5 6 7
# Environment check
[ -z "$COVERITY_TOKEN" ] && echo "Need to set a coverity token" && exit 1

8 9 10
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
BUILD_DIR=$(pwd)

11
case $(uname -m) in
Ben Straub committed
12 13 14
	i?86)				BITS=32 ;;
	amd64|x86_64)	BITS=64 ;;
esac
15
SCAN_TOOL=https://scan.coverity.com/download/cxx/linux${BITS}
16
TOOL_BASE=$(pwd)/_coverity-scan
Ben Straub committed
17 18

# Install coverity tools
19
if [ ! -d "$TOOL_BASE" ]; then
Ben Straub committed
20
	echo "Downloading coverity..."
21 22
	mkdir -p "$TOOL_BASE"
	pushd "$TOOL_BASE"
Ben Straub committed
23 24 25
	wget -O coverity_tool.tgz $SCAN_TOOL \
		--post-data "project=libgit2&token=$COVERITY_TOKEN"
	tar xzf coverity_tool.tgz
26 27 28
	popd
	TOOL_DIR=$(find "$TOOL_BASE" -type d -name 'cov-analysis*')
	ln -s "$TOOL_DIR" "$TOOL_BASE"/cov-analysis
Ben Straub committed
29 30
fi

31
cp "${SOURCE_DIR}/script/user_nodefs.h" "$TOOL_BASE"/cov-analysis/config/user_nodefs.h
32

Ben Straub committed
33 34 35
COV_BUILD="$TOOL_BASE/cov-analysis/bin/cov-build"

# Configure and build
36 37
cmake ${SOURCE_DIR}

Ben Straub committed
38 39 40 41
COVERITY_UNSUPPORTED=1 \
	$COV_BUILD --dir cov-int \
	cmake --build .