summaryrefslogtreecommitdiffstats
path: root/build-aux/ci/ci-helper.sh
blob: ddecded22d1932bbc3a3bacd0b25da04112fd148 (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
#!/bin/bash -e

function do_print_labels(){

    if [[ -n "${1}" ]]; then
        label_len=${#1}
        span=$(((54 - $label_len) / 2))

        echo
        echo "= ======================================================== ="
        printf "%s %${span}s %s %${span}s %s\n" "=" "" "$1" "" "="
        echo "= ======================================================== ="
    else
        echo "= ========================= Done ========================= ="
        echo
    fi
}

function do_show_info(){

    local compiler=gcc

    echo -n "Processors: "; grep -c ^processor /proc/cpuinfo
    grep ^MemTotal /proc/meminfo
    id; uname -a
    printenv
    echo '-----------------------------------------'
    cat /etc/*-release
    echo '-----------------------------------------'

    if [[ ! -z $CC ]]; then
        compiler=$CC
    fi
    echo 'Compiler version'
    $compiler --version
    echo '-----------------------------------------'
    $compiler -dM -E -x c /dev/null
    echo '-----------------------------------------'
}

function do_check_warnings(){

    cat compilation.log | grep "warning:" | awk '{total+=1}END{print "Total number of warnings: "total}'
}

# -----------  -----------
if [[ $1 == "INFO" ]]; then
    do_print_labels 'Build environment '
    do_show_info
    do_print_labels

elif [[ $1 == "GIT_INFO" ]]; then
    do_print_labels 'Commit'
    git log --pretty=format:"%h %cd %s" -1; echo
    do_print_labels

elif [[ $1 == "WARNINGS" ]]; then
    do_print_labels 'Warning Report '
    do_check_warnings
    do_print_labels
fi