osbuild.sh 6.6 KB

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