|
1 #!/bin/sh |
|
2 |
|
3 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 # All rights reserved. |
|
5 # This component and the accompanying materials are made available |
|
6 # under the terms of the License "Eclipse Public License v1.0" |
|
7 # which accompanies this distribution, and is available |
|
8 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 # |
|
10 # Initial Contributors: |
|
11 # Nokia Corporation - initial contribution. |
|
12 # |
|
13 # Contributors: |
|
14 # |
|
15 # Description: |
|
16 # Build automation for Symbian OS with Raptor |
|
17 # Author: Timothy N Murphy |
|
18 # |
|
19 # |
|
20 |
|
21 # Default settings. You may override these by specifying a setup script |
|
22 # as the first commandline argument |
|
23 # |
|
24 H=$HOME |
|
25 export H |
|
26 export EPOCROOT="$H/baselineos" |
|
27 export LOGBASEDIR=~/public_html/buildlogs |
|
28 export BUILDROOT="$H/baselineos" |
|
29 export SOURCEROOT="$H/baselineos/fsupdate" |
|
30 export SYSDEF="$H/baselineos/system_definition_fsupdate.xml" |
|
31 export PREEXPORTSYSDEF="$SBS_HOME/test/envelope/preexport.xml" |
|
32 export PLATFORMS="-c armv5" |
|
33 export PARALLEL=46 |
|
34 export SYNCSBSSOURCE="" |
|
35 export UNSPLITDIRS="$SBS_HOME/unsplitdirs.py" |
|
36 |
|
37 # Do we want to attempt to build a ROM? |
|
38 export DOROMBUILD="" |
|
39 export ROMFILLIN_EPOCROOT=$BUILDROOT/rom_fillin |
|
40 # We need to specify the OBY file (must be generated on windows) |
|
41 export ROMOBYFILE="$BUILDROOT/h4hrp_001.techview.oby" |
|
42 |
|
43 # Do you have server that runs evalid automatically? |
|
44 export SENDTOEVALIDSERVER="" |
|
45 # The following should be mounted: |
|
46 export EVALIDSERVERMOUNT="/mnt/evalidserver" |
|
47 export USERBUILDID="" |
|
48 |
|
49 |
|
50 # Allow overrides to this default config |
|
51 if [ ! -z $1 ]; then |
|
52 if [ -f "$1" ]; then |
|
53 . $1 |
|
54 else |
|
55 echo "You must supply a build type as the first parameter - this should be a setup script" |
|
56 exit 1 |
|
57 fi |
|
58 fi |
|
59 |
|
60 |
|
61 genstats() { |
|
62 if [ "$1.stats" -ot "$1.log" ]; then |
|
63 python "$SBS_HOME/bin/buildstats.py" "$1.log" > "$1.stats" && |
|
64 #python "$SBS_HOME/bin/failedstats.py" -m "$1.log" > "$1.failed"; |
|
65 ( |
|
66 cd $EPOCROOT/epoc32 && find "release" > "$1.release_files" && find "build" > "$1.build_files" && find include > "$1.include_files" |
|
67 ) |
|
68 fi; |
|
69 } |
|
70 |
|
71 cd $BUILDROOT |
|
72 |
|
73 |
|
74 # Don't edit the rest: |
|
75 ################################################### |
|
76 export KEY=`date +%d_%m_%y` |
|
77 export DAILYDIR="$LOGBASEDIR/$KEY" |
|
78 |
|
79 export BUILDNAME="`basename \"$SYSDEF\" | sed 's#\.[^.][^.]*$##'`" |
|
80 if [ ! -z "$USERBUILDID" ]; then |
|
81 BUILDNAME="$USERBUILDID-$BUILDNAME" |
|
82 fi |
|
83 export LOGNAME="${BUILDNAME}_${KEY}" |
|
84 |
|
85 for BUILDNUM in {1..50}; do |
|
86 if [ ! -d "$DAILYDIR/$BUILDNUM" ]; then |
|
87 break |
|
88 fi |
|
89 if [ -z "`echo $DAILYDIR/$BUILDNUM/*_BUILDNUM.log*`" ]; then |
|
90 break |
|
91 fi |
|
92 done |
|
93 |
|
94 OUTDIR="$DAILYDIR/$BUILDNUM" |
|
95 export TESTLOG="$OUTDIR/test.log" |
|
96 |
|
97 # make the day's directory |
|
98 mkdir -p "$OUTDIR" |
|
99 |
|
100 echo "testrun: $TESTLOG, build $BUILDNUM of the day:" |
|
101 echo '<testrun>' > "$TESTLOG" |
|
102 |
|
103 echo "Parallel: $PARALLEL" |
|
104 ( |
|
105 echo "<test type='performance' name='speedtest' >" |
|
106 echo " <parameters parallel='$PARALLEL' start='`date`' />" |
|
107 echo " <logfile>$DAILYDIR/$BUILDNUM/${LOGNAME}_$BUILDNUM.log</logfile>" |
|
108 MAKEFILE=$EPOCROOT/epoc32/build/Makefile |
|
109 echo "" |
|
110 |
|
111 TIMELOG="$OUTDIR/${LOGNAME}_$BUILDNUM.time" |
|
112 |
|
113 echo " <build number='$BUILDNUM' of='$KEY' output='$OUTDIR'><![CDATA[" |
|
114 if [ ! -d "$OUTDIR" ]; then |
|
115 mkdir -p "$OUTDIR" || exit 1 |
|
116 fi |
|
117 set -x |
|
118 |
|
119 ( |
|
120 if [ ! -z "$SYNCSBSSOURCE" ]; then |
|
121 echo "Checking out Raptor source to $SBS_HOME" |
|
122 p4 -u timothymurphy sync $SBS_HOME/... |
|
123 else |
|
124 echo "NOT Checking out Raptor source" |
|
125 fi |
|
126 chmod a+x $SBS_HOME/bin/* # ensure permissions were set |
|
127 ) |
|
128 |
|
129 |
|
130 # Make sure that our "stop signal" is clear |
|
131 SIGNALTOSTOPFILE="$OUTDIR/${LOGNAME}_$BUILDNUM.stop" |
|
132 rm -f "$SIGNALTOSTOPFILE" |
|
133 |
|
134 |
|
135 echo "EPOCROOT is $EPOCROOT" |
|
136 export PATH=$EPOCROOT/epoc32/tools:$PATH |
|
137 |
|
138 ( |
|
139 echo "Annihilating epoc32 tree(s)" |
|
140 # wipe the epoc32 directory first |
|
141 chmod -R u+rw "$EPOCROOT/epoc32" && |
|
142 rm -rf "$EPOCROOT/epoc32" && |
|
143 echo "epoc32 tree withered" |
|
144 ) |
|
145 ( |
|
146 # unzip the pre-prepared epoc32 trees |
|
147 cd $EPOCROOT && |
|
148 ( |
|
149 set -x |
|
150 unzip -o $BUILDROOT/epoc32.zip | grep "epoc32/" | sed 's#.* \(epoc32/.*\)#\1#' | xargs -n 1 --replace bash -c "if [ -f '{}' ]; then touch '{}'; fi" && |
|
151 unzip -o $BUILDROOT/variant.zip | grep "epoc32/" | sed 's#.* \(epoc32/.*\)#\1#' | xargs -n 1 --replace bash -c "if [ -f '{}' ]; then touch '{}'; fi" && |
|
152 set +x |
|
153 ) > "$OUTDIR/unzip" && |
|
154 chmod -R u+rw "$EPOCROOT/epoc32" && |
|
155 echo "unzipped skeleton epoc32 tree" |
|
156 ) |
|
157 |
|
158 |
|
159 # (re)Initialise the cluster if required. |
|
160 ( |
|
161 if [ ! -z "$PARALLEL" ]; then |
|
162 echo "Setting up cluster" |
|
163 echo "Parallel: $PARALLEL" |
|
164 set -x |
|
165 echo -e "halt\n" | pvm >/dev/null |
|
166 echo -e "quit\n" | pvm $BUILDROOT/pvmhosts.$PARALLEL >/dev/null |
|
167 set +x |
|
168 else |
|
169 echo "Parallel: 0 - no cluster setup" |
|
170 set -x |
|
171 echo -e "halt\n" | pvm >/dev/null |
|
172 set +x |
|
173 fi |
|
174 ) |
|
175 |
|
176 |
|
177 set +x |
|
178 echo "Prepping makefiles" |
|
179 ( |
|
180 echo "<times>\n" |
|
181 export TIMEFORMAT="<time stage='prepmake'>%3R</time>\n" |
|
182 time $SBS_HOME/bin/sbs -d -k -s "$SYSDEF" -a "$SOURCEROOT" $PLATFORMS -n > $OUTDIR/${LOGNAME}_$BUILDNUM.meta 2>&1 |
|
183 #time cp performance_Makefile $MAKEFILE |
|
184 ) > "$TIMELOG" 2>&1 |
|
185 echo "Running Make" |
|
186 ( |
|
187 # The build process |
|
188 export TIMEFORMAT="<time stage='make' parallel='$PARALLEL'>%3R</time>\n" |
|
189 |
|
190 time /opt/symbian/make-pvm-381/pvmgmake -j$PARALLEL -k -f $MAKEFILE > "$OUTDIR/${LOGNAME}_$BUILDNUM.log" 2>&1 |
|
191 touch "$SIGNALTOSTOPFILE" |
|
192 echo "</times>\n" |
|
193 ) >> "$TIMELOG" 2>&1 & |
|
194 ( |
|
195 # Concurrent process to continuously update statistics |
|
196 echo "" |
|
197 |
|
198 while [ 1 -eq 1 ]; do |
|
199 sleep 20 |
|
200 echo -n "." |
|
201 |
|
202 if [ -e "$SIGNALTOSTOPFILE" ]; then |
|
203 rm -f "$SIGNALTOSTOPFILE" |
|
204 break |
|
205 fi |
|
206 done |
|
207 echo "" |
|
208 ) |
|
209 #set +x |
|
210 #genstats "$OUTDIR/${LOGNAME}_$BUILDNUM" |
|
211 ( |
|
212 echo "UNSPLITTING DIRECTORIES" |
|
213 set -x |
|
214 cd $EPOCROOT/epoc32 && |
|
215 python $UNSPLITDIRS -l . && |
|
216 set +x |
|
217 |
|
218 ) && ( |
|
219 if [ ! -z "$DOROMBUILD" ]; then |
|
220 echo "Building ROM" |
|
221 set -x |
|
222 cd $EPOCROOT && |
|
223 unzip -o $BUILDROOT/data.zip >/dev/null && |
|
224 python $BUILDROOT/oby_tolinux.py < "$ROMOBYFILE" >PROCESSED_H4HRP_001.TECHVIEW.OBY |
|
225 $EPOCROOT/epoc32/tools/rombuild -type-safe-link PROCESSED_H4HRP_001.TECHVIEW.OBY |
|
226 cp |
|
227 set +x |
|
228 else |
|
229 echo "NOT Building ROM" |
|
230 fi |
|
231 ) |
|
232 |
|
233 ( |
|
234 if [ ! -z "$SENDTOEVALIDSERVER" ]; then |
|
235 echo "Sending epoc32/release and epoc32/data to the evalidserver" |
|
236 set -x |
|
237 ZIPFILE="$DAILYDIR/$BUILDNUM/${LOGNAME}_$BUILDNUM.zip" |
|
238 cd $EPOCROOT && |
|
239 find epoc32/release epoc32/data | zip "$ZIPFILE" -@ >/dev/null 2>&1 && |
|
240 cp "$ZIPFILE" /mnt/evalidserver |
|
241 set +x |
|
242 else |
|
243 echo "NOT sending epoc32/release and epoc32/data to the evalidserver" |
|
244 fi |
|
245 ) |
|
246 |
|
247 # Zip the logs - note that test.log should not be zipped since the output from the zip goes into it |
|
248 ( |
|
249 echo "Zipping logs..." |
|
250 set -x |
|
251 cd $OUTDIR && |
|
252 zip ${LOGNAME}_${BUILDNUM}_logs.zip *.time *.meta *.log *.preexport -x test.log |
|
253 set +x |
|
254 ) |
|
255 |
|
256 |
|
257 echo " ]]></build>" |
|
258 echo "</test>" |
|
259 ) >> "$TESTLOG" 2>&1 |
|
260 |
|
261 BUILDNUM=$[ $BUILDNUM + 1 ] |
|
262 # use a new output directory |
|
263 echo -e "<testrun_stat endtime='`date`'\n />" >> "$TESTLOG" |
|
264 echo "</testrun>" >> "$TESTLOG" |