summaryrefslogtreecommitdiff
path: root/tb/tb_phases.sh
blob: aeb41810d235dea8f5ce07797b52f2438a39be37 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/usr/bin/env bash
# -*- tab-width : 4; indent-tabs-mode : nil -*-
#
#    Copyright (C) 2011-2013 Norbert Thiebaud
#    License: GPLv3
#

canonical_pre_autogen()
{
    if [ "${R}" = "0" ] ; then
        if [ ! -f autogen.lastrun -o "${tb_KEEP_AUTOGEN}" != "YES" ] ; then
            copy_autogen_config
        fi
    fi
}

pre_autogen()
{
    canonical_pre_autogen
}

canonical_do_autogen()
{
    if [ "${R}" = "0" ] ; then
        if ! ${TB_NICE} ${TB_GIT_DIR?}/autogen.sh > "tb_${P?}_autogen.log" 2>&1 ; then
            tb_REPORT_LOG=tb_${P?}_autogen.log
            tb_REPORT_MSGS="autogen/configure failed - error is:"
            [ $V ] && echo "autogen failed"
            [ $V ] && cat tb_${P?}_autogen.log
            R=1
        fi
    fi
}

do_autogen()
{
    canonical_do_autogen
}

canoncial_post_autogen()
{
    return
}

canonical_pre_clean()
{
    if [ "${R}" = "0" ] ; then
        true # log files to clean, if any
    fi
}

pre_clean()
{
    canonical_pre_clean
}

canonical_do_clean()
{
    if [ "${R}" = "0" ] ; then
        if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr clean > "tb_${P?}_clean.log" 2>&1 ; then
            tb_REPORT_LOG="tb_${P?}_clean.log"
            tb_REPORT_MSGS="cleaning up failed - error is:"
            R=1
        fi
    fi
}

do_clean()
{
    canonical_do_clean
}

canonical_post_clean()
{
    return
}

canonical_do_make()
{
local current_timestamp=
local optdir=""
local extra_buildid=""

    tb_OPT_DIR=""
    if [ "${TB_TYPE?}" = "tb" ] ; then
        current_timestamp=$(sed -e "s/ /_/" "${TB_METADATA_DIR?}/${P?}_current-git-timestamp.log")
        extra_buildid="TinderBox: ${TB_NAME?}, Branch:${TB_BRANCH?}, Time: $current_timestamp"
    fi
    if [ "${R}" = "0" ] ; then
        export EXTRA_BUILDID="$extra_buildid"
        if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr > "tb_${P?}_build.log" 2>&1 ; then
            tb_REPORT_LOG="tb_${P?}_build.log"
            tb_REPORT_MSGS="build failed - error is:"
            [ $V ] && echo "make failed :"
            [ $V ] && cat tb_${P?}_build.log
            R=1
        else
            # if we want to populate bibisect we need to 'install'
            if [ "${TB_TYPE?}" = "tb" -a ${TB_BIBISECT} != "0" ] ; then
                if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr install-tb >>"tb_${P?}_build.log" 2>&1 ; then
                    tb_REPORT_LOG="tb_${P}_build.log"
                    tb_REPORT_MSGS="build failed - error is:"
                    R=1
                else
                    tb_OPT_DIR="$(find_dev_install_location)"
                fi
            fi
        fi
    fi
}

do_make()
{
    canonical_do_make
}

canonical_post_make()
{
    if [ "${TB_TYPE?}" = "tb" ] ; then
        if [ "${R}" != "0" ] ; then
            if [ -f "${tb_REPORT_LOG?}" ] ; then
                if [ -f "${tb_CONFIG_DIR?}/profiles/${P?}false_negatives" ] ; then
                    grep -F "$(cat "${tb_CONFIG_DIR?}/profiles/${P?}/false_negatives")" "${tb_REPORT_LOG?}" && R="2"
                    if [ "${R?}" == "2" ] ; then
                        log_msgs "False negative detected"
                    fi
                fi
            fi
        fi
    fi
}

post_make()
{
    canonical_post_make
}

canonical_pre_test()
{
    return
}

canonical_do_test()
{
    if [ "${R}" = "0" ] ; then
        if [ "${TB_DO_TESTS}" = "1" ] ; then
            if ! ${TB_NICE} ${TB_WATCHDOG} ${MAKE?} -sr check > "tb_${P?}_tests.log" 2>&1 ; then
                tb_REPORT_LOG="tb_${P?}_tests.log"
                tb_REPORT_MSGS="check failed - error is:"
                R=1
            fi
        fi
    fi
}

do_test()
{
    canonical_do_test
}

canonical_post_test()
{
    return
}

canonical_pre_push()
{
    return
}

canonical_do_push()
{
    [ $V ] && echo "Push: phase starting"

    if [ "${R}" != "0" ] ; then
        return 0;
    fi

    if [ "${TB_TYPE?}" = "tb" ] ; then
        # Push nightly build if needed
        if [ "$TB_PUSH_NIGHTLIES" = "1" ] ; then
            push_nightly
        fi
        # Push bibisect to remote bibisect if needed
        if [ "$TB_BIBISECT" = "1" ] ; then
            push_bibisect
        fi
    fi
    return 0;
}

do_push()
{
    canonical_do_push
}

canonical_post_push()
{
    return
}

tb_call()
{
    [ $V ] && declare -F "$1" > /dev/null && echo "call $1"
    declare -F "$1" > /dev/null && $1
}

phase()
{
    local f=${1}
    for x in {pre_,do_,post_}${f} ; do
        tb_call ${x}
    done
}


do_build()
{
    local phases="$@"
    local p
    [ $V ] && echo "do_build (${TB_TYPE?}) phase_list=${phases?}"

    for p in ${phases?} ; do
        [ $V ] && echo "phase $p"
        phase $p
    done

}