summaryrefslogtreecommitdiff
path: root/build/gitlab-ci
blob: 110df391087ff7d9edaf15bcb0c82d2953de6373 (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
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
# This script is used for testing the build, primarily for use
# with travis, but may be used by hand as well.

set -e
set -x

# Test autoconf build
autoconf_build()
{
    autoreconf -ivf

    mkdir autoconf-build
    cd autoconf-build
    echo "Running ../configure --prefix=$(pwd)/../autoconf-install) ${opts}"
    ../configure --prefix=$(pwd)/../autoconf-install ${opts}
    make
    make install
    make check
    make distcheck
}

# Test cmake build
cmake_build()
{
    PATH="$(pwd)/tools/bin:$PATH"
    if [ "$(uname -s)" = "Darwin" ]; then
        PATH="$(pwd)/tools/CMake.app/Contents/bin:$PATH"
    fi
    mkdir cmake-build
    cd cmake-build
    opts="-Dfatal-warnings=ON"
    echo "Running cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} .."
    cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} ..
    $COVERITY_BUILD cmake --build .
    cmake --build . --target install
    ctest -V
}

# Static-analysis with coverity
coverity_build()
{
    curl -o /tmp/cov-analysis-linux64.tgz \
        https://scan.coverity.com/download/linux64 \
        --form project=$COVERITY_SCAN_PROJECT_NAME \
        --form token=$COVERITY_SCAN_TOKEN
    tar xfz /tmp/cov-analysis-linux64.tgz
    COVERITY_BUILD="$(pwd)/cov-analysis-linux64-*/bin/cov-build --dir cov-int" cmake_build "$@"
    tar cfz cov-int.tar.gz cov-int
    curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME \
        --form token=$COVERITY_SCAN_TOKEN \
        --form email=$GITLAB_USER_EMAIL \
        --form file=@cov-int.tar.gz \
        --form version="`git describe --tags`" \
        --form description="`git describe --tags` / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
}


build=$1
shift

case $build in
    autoconf)
        echo "Testing Autoconf build"
        autoconf_build "$@"
        ;;
    cmake)
        echo "Testing CMake build"
        cmake_build "$@"
        ;;
    coverity)
        echo "Static analysis with Coverity"
        coverity_build "$@"
        ;;
    *)
        echo "Invalid argument: \"$arg\"" >&2
        exit 1
        ;;
esac

exit 0