[mcs] When setting struct empty layout consider compiler generated fields. Fixes...
[mono.git] / mcs / tools / tinderbox / tinderbox.sh
1 #!/bin/bash
2
3 # TOPDIR: set this to the directory containing
4 # your 'mono' and 'mcs' directories. Do NOT use '~' here.
5 TOPDIR=$HOME/mono
6
7 # BACKUP: initially this directory should contain a working install of mono.
8 # this directory should minimally contain the 'bin' and 'lib' dirs.
9 # after each successful build, the results are placed in here.
10 BACKUP=$TOPDIR/install.bak
11
12 # INSTALL: this is used as the install directory for
13 # the various stages of the build.
14 INSTALL=$TOPDIR/install
15
16 # SENDMAIL: uncomment this line if you want to send notifications.
17 # be careful to check the recipients below before running this script!
18 SENDMAIL=$TOPDIR/mcs/tools/tinderbox/smtp
19
20 # EMAIL_*: notification addresses. please change these before running!
21 EMAIL_FATAL="piersh@friskit.com"
22 EMAIL_MESSAGE="mono-patches@lists.ximian.com"
23 #EMAIL_MESSAGE="piersh@friskit.com"
24 #EMAIL_MESSAGE="mono-hackers-list@ximian.com"
25 EMAIL_FROM="piersh@friskit.com"
26 EMAIL_CC="-c mono-hackers-list@lists.ximian.com"
27 EMAIL_HOST="zeus.sfhq.friskit.com"
28
29 LOGBASE=$TOPDIR/.build.log
30 LOG=$LOGBASE.txt
31 LOGPREV=$LOGBASE.prev
32 LOGFATAL=$LOGBASE.fatal
33 LOGDATE=$TOPDIR/.build.date
34 LOGLOG=$TOPDIR/.build.log.log
35 BUILDMSG=$TOPDIR/.build.msg
36 export LOGDATE
37
38 DELAY_SUCCESS=5m                        # wait after a successful build
39 DELAY_CHECK_BROKEN=5m           # wait while verifying the build is broken
40 DELAY_STILL_BROKEN=3m           # wait while waiting for fix
41 DELAY_BROKEN=5m                         # wait after notification sent
42
43 FILTER_LOG="sed -e 's/^in <0x[0-9a-z]*>//' -e 's/:[0-9]*): WARNING \*\*:/): WARNING **/' -e 's/^\[[0-9][0-9]*:[0-9][0-9]*\] - .*//' -e 's/^[0-9][0-9]* - Member cache//' -e 's/^[0-9][0-9]* - Misc counter//' -e 's/: [0-9]* Trace\/breakpoint/ : Trace\/breakpoint/' -e 's/Needed to allocate blacklisted block at 0x[0-9a-f]*//'"
44
45 function fatal ()
46 {
47         $SENDMAIL -h $EMAIL_HOST -f $EMAIL_FROM -t $EMAIL_FATAL -a $LOGFATAL -s "[MONOBUILD] FATAL ERROR (`uname -s -m`)"
48         echo FATAL: `date` >> $LOGLOG
49         echo FATAL ERROR
50         exit 1
51 }
52
53 function build_mono ()
54 {
55         # try to build
56
57         echo building...
58
59         cd $TOPDIR
60
61         rm -f $LOGFATAL
62         touch $LOGFATAL
63
64         [ -f $LOG ] && mv $LOG $LOGPREV
65         touch $LOG
66
67         # restore tools from backup
68         rm -fr $INSTALL
69         cp -a $BACKUP $INSTALL
70
71         # update from CVS
72         cvs -z3 update -APd mcs mono 2>&1 | tee -a $LOG
73         [ $PIPESTATUS == "0" ] || return 1
74
75         # clean mcs
76         cd $TOPDIR/mcs
77         make -f makefile.gnu clean 2>&1 | tee -a $LOG
78         [ $PIPESTATUS == "0" ] || return 1
79
80         # build JAY
81         cd $TOPDIR/mcs/jay
82         make -f makefile.gnu 2>&1 | tee -a $LOG
83         [ $PIPESTATUS == "0" ] || return 1
84
85         # build MCS compiler
86         cd $TOPDIR/mcs/mcs
87         make -f makefile.gnu 2>&1 | tee -a $LOG
88         [ $PIPESTATUS == "0" ] || return 1
89
90         # build CORLIB with old tools
91         cd $TOPDIR/mcs/class/corlib
92         make -f makefile.gnu 2>&1 | tee -a $LOG
93         [ $PIPESTATUS == "0" ] || return 1
94
95         # copy new MCS and CORLIB to build tools
96         cp -f $TOPDIR/mcs/class/lib/corlib.dll $INSTALL/lib/
97         cp -f $TOPDIR/mcs/mcs/mcs.exe $INSTALL/bin/
98
99
100
101         cd $TOPDIR/mono
102
103         # configure mono build
104         rm -f config.cache
105         ./autogen.sh --prefix=$INSTALL 2>&1 | tee -a $LOG
106         [ $PIPESTATUS == "0" ] || return 1
107
108         # clean mono
109         make clean 2>&1 | tee -a $LOG
110         [ $PIPESTATUS == "0" ] || return 1
111
112         # build mono
113         make 2>&1 | tee -a $LOG
114         [ $PIPESTATUS == "0" ] || return 1
115
116         # install runtime
117         cd $TOPDIR/mono/mono
118         make install 2>&1 | tee -a $LOG
119         [ $PIPESTATUS == "0" ] || return 1
120
121
122
123         # clean/make runtime libraries/tools
124         cd $TOPDIR/mcs
125         make -f makefile.gnu clean 2>&1 | tee -a $LOG
126         [ $PIPESTATUS == "0" ] || return 1
127
128         make -f makefile.gnu 2>&1 | tee -a $LOG
129         [ $PIPESTATUS == "0" ] || return 1
130
131
132
133         # retrieve runtime libraries
134         cd $TOPDIR/mono/runtime
135         rm -f *.dll *.exe
136
137         # install everything
138         cd $TOPDIR/mono
139         make install 2>&1 | tee -a $LOG
140         [ $PIPESTATUS == "0" ] || return 1
141
142
143         # test mcs self-build
144         cd $TOPDIR/mcs/mcs
145         make -f makefile.gnu clean 2>&1 | tee -a $LOG
146         [ $PIPESTATUS == "0" ] || return 1
147         make -f makefile.gnu 2>&1 | tee -a $LOG
148         [ $PIPESTATUS == "0" ] || return 1
149
150
151         # test corlib self-build
152         cd $TOPDIR/mcs/class/corlib
153         make -f makefile.gnu clean 2>&1 | tee -a $LOG
154         [ $PIPESTATUS == "0" ] || return 1
155         make -f makefile.gnu 2>&1 | tee -a $LOG
156         [ $PIPESTATUS == "0" ] || return 1
157
158
159         # it worked, backup build tools
160         rm -fr $BACKUP
161         cp -a $INSTALL $BACKUP
162
163         return 0
164 }
165
166 function compare_logs ()
167 {
168         touch $LOG $LOGPREV
169         echo Comparing build logs
170         eval $FILTER_LOG $LOG > $LOG.tmp
171         eval $FILTER_LOG $LOGPREV > $LOGPREV.tmp
172         diff -b --brief $LOG.tmp $LOGPREV.tmp
173 }
174
175 function build_fixed ()
176 {
177         echo "Build fixed:       `date`" > $BUILDMSG
178         echo "Previous breakage: `cat .build.date.last_fail`" >> $BUILDMSG
179         echo "Previous build:    `cat .build.date.last_success`" >> $BUILDMSG
180         echo >> $BUILDMSG
181
182         $SENDMAIL -h $EMAIL_HOST -f $EMAIL_FROM -t $EMAIL_MESSAGE $EMAIL_CC -s "[MONOBUILD] fixed (`uname -s -m`)" -m $BUILDMSG
183         rm -f $BUILDMSG
184 }
185
186 function build_failed ()
187 {
188         echo "Build broken:   `date`" > $BUILDMSG
189         echo "Broken since:   `cat .build.date.last_fail`" >> $BUILDMSG
190         echo "Previous build: `cat .build.date.last_success`" >> $BUILDMSG
191         echo >> $BUILDMSG
192
193         sed -e 's/$/\r/' < $LOG > errors.txt
194         tail -25 errors.txt >> $BUILDMSG
195         rm -f errors.txt.gz
196         gzip errors.txt
197
198         $SENDMAIL -h $EMAIL_HOST -f $EMAIL_FROM -t $EMAIL_MESSAGE $EMAIL_CC -a errors.txt.gz -s "[MONOBUILD] broken (`uname -s -m`)" -m $BUILDMSG
199         rm -f $BUILDMSG errors.txt.gz
200 }
201
202 function stabilize ()
203 {
204         cd $TOPDIR
205         while ! compare_logs ; do
206
207                 date > $LOGDATE.last_fail
208                 echo "|||||||||||||||||||||||||"
209                 echo "|||||| LOGS DIFFER ||||||"
210                 echo "|||||||||||||||||||||||||"
211                 echo CHECK: `date` >> $LOGLOG
212
213                 echo sleeping for $DELAY_CHECK_BROKEN
214                 sleep $DELAY_CHECK_BROKEN
215
216                 if build_mono ; then
217                         return 0
218                 fi
219
220                 cd $TOPDIR
221
222         done
223         return 1
224 }
225
226 [ -f $LOGPREV ] && mv $LOGPREV $LOG
227
228 while [ 1 ] ; do
229
230         cd $TOPDIR
231         
232         if build_mono ; then
233
234                 cd $TOPDIR
235
236                 echo "|||||||||||||||||||||||||"
237                 echo "|||| BUILD SUCCEEDED ||||"
238                 echo "|||||||||||||||||||||||||"
239                 echo SUCCESS: `date` >> $LOGLOG
240                 date > $LOGDATE.last_success
241                 echo sleeping for $DELAY_SUCCESS
242                 sleep $DELAY_SUCCESS
243
244         else
245
246                 if ! stabilize ; then
247
248                         build_failed
249
250                         echo "||||||||||||||||||||||"
251                         echo "|||| BUILD BROKEN ||||"
252                         echo "||||||||||||||||||||||"
253                         echo BROKEN: `date` >> $LOGLOG
254                         date > $LOGDATE.last_fail
255                         echo sleeping for $DELAY_BROKEN
256                         sleep $DELAY_BROKEN
257
258                         until build_mono ; do
259
260                                 cd $TOPDIR
261                                 echo "||||||||||||||||||||||||||||"
262                                 echo "|||| BUILD STILL BROKEN ||||"
263                                 echo "||||||||||||||||||||||||||||"
264                                 echo STILL BROKEN: `date` >> $LOGLOG
265                                 date > $LOGDATE.last_fail
266                                 echo sleeping for $DELAY_STILL_BROKEN
267                                 sleep $DELAY_STILL_BROKEN
268
269                         done
270
271                         cd $TOPDIR
272                         build_fixed
273                         echo "|||||||||||||||||||||"
274                         echo "|||| BUILD FIXED ||||"
275                         echo "|||||||||||||||||||||"
276                         echo FIXED: `date` >> $LOGLOG
277                         date > $LOGDATE.last_success
278                         echo sleeping for $DELAY_SUCCESS
279                         sleep $DELAY_SUCCESS
280
281                 fi
282
283         fi
284
285 done
286