aboutsummaryrefslogtreecommitdiff
path: root/make-ssc.sh
blob: 724467da3ab4c20cd5d8555bca50d1678cf73821 (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
#!/bin/bash
set -e

ROOT_DIR=$(readlink -f $(dirname $0))
export parent_workspace="/home/buildslave/workspace/odp-api-ssc-new"
export reference_git="${parent_workspace}/reference-git"
export git_repo="${git_repo:-git://git.linaro.org/lng/odp.git}"
export git_branch="${git_branch:-master}"

usage() {
    echo -e "$0 makes use of the following environment variables,"
    echo -e "\tgit_repo:\twhich ODP git repo to use"
    echo -e "\tgit_branch:\twhich branch to checkout and test"
    echo -e "\ttests:\t\twhich test to run (clang/sparse/smatch), default: clang"
}

if [ "x$1" = "x-h" ]; then
    usage
    exit 0
fi

if [ -z "${WORKSPACE}" ]; then
    # Local build
    export tests=${tests:-clang}
    export parent_workspace=${ROOT_DIR}
    export reference_git="${parent_workspace}/reference-git"
    export WORKSPACE="${parent_workspace}/workspace"
    export BUILD_NUMBER=1
    mkdir -p ${WORKSPACE}
    cd ${WORKSPACE}
fi

trap cleanup_exit INT TERM EXIT

cleanup_exit()
{
    rm -rf ${WORKSPACE}/*
    rm -rf ${WORKSPACE}/.git*
}

test -d ${reference_git} || git clone --depth 1 -b $git_branch $git_repo ${reference_git}
cp -a ${reference_git}/* ${reference_git}/.git* .

cd ${WORKSPACE}
./bootstrap
./configure

case "${tests}" in
    clang)
        scan-build make 2>&1 | tee make-clang.log
        CLANG_BUILD_DIR=$(cat make-clang.log | egrep "scan-build: Run .* to examine bug reports." | awk -F' ' '{print $4}' | sed -e "s|'||")
        test -d ${CLANG_BUILD_DIR} || cp -r ${CLANG_BUILD_DIR} ${WORKSPACE}/scan-build
        rm -rf ${WORKSPACE}/scan-build/scan-build-20*

        make clean
        make CC=clang CFLAGS=-Wno-error
        ;;
    sparse)
        make clean
        make CC=cgcc -Wattributes -Wno-error -Wdefault-bitfield-sign -Wparen-string -Wshadow -Wbitwise -Wcast-to-as -Wdo-while -Wnon-pointer-null -Wptr-subtraction-blows
        ;;
    smatch)
        make clean
        make CC=cgcc CHECK="smatch --no-data --full-path"
        ;;
esac

## vim: set sw=4 sts=4 et foldmethod=syntax : ##