summaryrefslogtreecommitdiffstats
path: root/tdemarkdown/md4c/scripts/coverity.sh
blob: bcf7f140b3169834f8651884727b02f048f709dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
#
# This scripts attempts to build the project via cov-build utility, and prepare
# a package for uploading to the coverity scan service.
#
# (See http://scan.coverity.com for more info.)

set -e

# Check presence of coverity static analyzer.
if ! which cov-build; then
    echo "Utility cov-build not found in PATH."
    exit 1
fi

# Choose a build system (ninja or GNU make).
if which ninja; then
    BUILD_TOOL=ninja
    GENERATOR=Ninja
elif which make; then
    BUILD_TOOL=make
    GENERATOR="MSYS Makefiles"
else
    echo "No suitable build system found."
    exit 1
fi

# Choose a zip tool.
if which 7za; then
    MKZIP="7za a -r -mx9"
elif which 7z; then
    MKZIP="7z a -r -mx9"
elif which zip; then
    MKZIP="zip -r"
else
    echo "No suitable zip utility found"
    exit 1
fi

# Change dir to project root.
cd `dirname "$0"`/..

CWD=`pwd`
ROOT_DIR="$CWD"
BUILD_DIR="$CWD/coverity"
OUTPUT="$CWD/cov-int.zip"

# Sanity checks.
if [ ! -x "$ROOT_DIR/scripts/coverity.sh" ]; then
    echo "There is some path mismatch."
    exit 1
fi
if [ -e "$BUILD_DIR" ]; then
    echo "Path $BUILD_DIR already exists. Delete it and retry."
    exit 1
fi
if [ -e "$OUTPUT" ]; then
    echo "Path $OUTPUT already exists. Delete it and retry."
    exit 1
fi

# Build the project with the Coverity analyzes enabled.
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
cmake -G "$GENERATOR" "$ROOT_DIR"
cov-build --dir cov-int "$BUILD_TOOL"
$MKZIP "$OUTPUT" "cov-int"
cd "$ROOT_DIR"
rm -rf "$BUILD_DIR"