| 1 | #!/bin/bash |
|---|
| 2 | # |
|---|
| 3 | # coreboot autobuild |
|---|
| 4 | # |
|---|
| 5 | # This script builds coreboot images for all available targets. |
|---|
| 6 | # |
|---|
| 7 | # (C) 2004 by Stefan Reinauer <stepan@openbios.org> |
|---|
| 8 | # (C) 2006-2009 by coresystems GmbH <info@coresystems.de> |
|---|
| 9 | # |
|---|
| 10 | # This file is subject to the terms and conditions of the GNU General |
|---|
| 11 | # Public License. See the file COPYING in the main directory of this |
|---|
| 12 | # archive for more details. |
|---|
| 13 | # |
|---|
| 14 | |
|---|
| 15 | #set -x # Turn echo on.... |
|---|
| 16 | |
|---|
| 17 | ABUILD_DATE="April 10th, 2009" |
|---|
| 18 | ABUILD_VERSION="0.8.1" |
|---|
| 19 | |
|---|
| 20 | # Where shall we place all the build trees? |
|---|
| 21 | TARGET=$( pwd )/coreboot-builds |
|---|
| 22 | XMLFILE=$( pwd )/abuild.xml |
|---|
| 23 | |
|---|
| 24 | # path to payload. Should be more generic |
|---|
| 25 | PAYLOAD=/dev/null |
|---|
| 26 | |
|---|
| 27 | # Lines of error context to be printed in FAILURE case |
|---|
| 28 | CONTEXT=5 |
|---|
| 29 | |
|---|
| 30 | TESTSUBMISSION="http://qa.coreboot.org/deployment/send.php" |
|---|
| 31 | |
|---|
| 32 | # Number of CPUs to compile on per default |
|---|
| 33 | cpus=1 |
|---|
| 34 | |
|---|
| 35 | # Configure-only mode |
|---|
| 36 | configureonly=0 |
|---|
| 37 | |
|---|
| 38 | # One might want to adjust these in case of cross compiling |
|---|
| 39 | for i in make gmake gnumake nonexistant_make; do |
|---|
| 40 | $i --version 2>/dev/null |grep "GNU Make" >/dev/null && break |
|---|
| 41 | done |
|---|
| 42 | if [ "$i" = "nonexistant_make" ]; then |
|---|
| 43 | echo No GNU Make found. |
|---|
| 44 | exit 1 |
|---|
| 45 | fi |
|---|
| 46 | MAKE=$i |
|---|
| 47 | PYTHON=python |
|---|
| 48 | |
|---|
| 49 | # this can be changed to xml by -x |
|---|
| 50 | mode=text |
|---|
| 51 | |
|---|
| 52 | # silent mode.. no compiler calls, only warnings in the log files. |
|---|
| 53 | # this is disabled per default but can be enabled with -s |
|---|
| 54 | silent= |
|---|
| 55 | |
|---|
| 56 | # clang mode enabled by -sb option. |
|---|
| 57 | scanbuild=false |
|---|
| 58 | |
|---|
| 59 | # stackprotect mode enabled by -ns option. |
|---|
| 60 | stackprotect=false |
|---|
| 61 | |
|---|
| 62 | # loglevel changed with -l / --loglevel option |
|---|
| 63 | loglevel=default |
|---|
| 64 | |
|---|
| 65 | ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ |
|---|
| 66 | -e s/i86pc/i386/ \ |
|---|
| 67 | -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \ |
|---|
| 68 | -e "s/Power Macintosh/ppc/"` |
|---|
| 69 | |
|---|
| 70 | trap interrupt INT |
|---|
| 71 | |
|---|
| 72 | function interrupt |
|---|
| 73 | { |
|---|
| 74 | printf "\n$0: execution interrupted manually.\n" |
|---|
| 75 | if [ "$mode" == "xml" ]; then |
|---|
| 76 | printf "$0: deleting incomplete xml output file.\n" |
|---|
| 77 | fi |
|---|
| 78 | exit 1 |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | function debug |
|---|
| 82 | { |
|---|
| 83 | test "$verbose" == "true" && printf "$*\n" |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | function xml |
|---|
| 87 | { |
|---|
| 88 | test "$mode" == "xml" && printf "$*\n" >> $XMLFILE |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | function xmlfile |
|---|
| 92 | { |
|---|
| 93 | test "$mode" == "xml" && { |
|---|
| 94 | printf '<![CDATA[\n' |
|---|
| 95 | cat $1 |
|---|
| 96 | printf ']]>\n' |
|---|
| 97 | } >> $XMLFILE |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | function vendors |
|---|
| 103 | { |
|---|
| 104 | # make this a function so we can easily select |
|---|
| 105 | # without breaking readability |
|---|
| 106 | ls -1 "$LBROOT/src/mainboard" | grep -v CVS |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | function mainboards |
|---|
| 110 | { |
|---|
| 111 | # make this a function so we can easily select |
|---|
| 112 | # without breaking readability |
|---|
| 113 | |
|---|
| 114 | VENDOR=$1 |
|---|
| 115 | |
|---|
| 116 | ls -1 $LBROOT/src/mainboard/$VENDOR | grep -v CVS |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | function architecture |
|---|
| 120 | { |
|---|
| 121 | VENDOR=$1 |
|---|
| 122 | MAINBOARD=$2 |
|---|
| 123 | ARCH=`cat $LBROOT/src/mainboard/$VENDOR/$MAINBOARD/Config.lb | \ |
|---|
| 124 | grep ^arch | cut -f 2 -d\ ` |
|---|
| 125 | echo $ARCH | sed s/ppc/powerpc/ |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | function create_config |
|---|
| 129 | { |
|---|
| 130 | VENDOR=$1 |
|---|
| 131 | MAINBOARD=$2 |
|---|
| 132 | CONFIG=$3 |
|---|
| 133 | TARCH=$( architecture $VENDOR $MAINBOARD ) |
|---|
| 134 | TARGCONFIG=$LBROOT/targets/$VENDOR/$MAINBOARD/Config-abuild.lb |
|---|
| 135 | |
|---|
| 136 | if [ "$CONFIG" != "" ]; then |
|---|
| 137 | TARGCONFIG=$LBROOT/targets/$VENDOR/$MAINBOARD/$CONFIG |
|---|
| 138 | fi |
|---|
| 139 | |
|---|
| 140 | # get a working payload for the board if we have one. |
|---|
| 141 | # the --payload option expects a directory containing |
|---|
| 142 | # a shell script payload.sh |
|---|
| 143 | # Usage: payload.sh [VENDOR] [DEVICE] |
|---|
| 144 | # the script returns an absolute path to the payload binary. |
|---|
| 145 | |
|---|
| 146 | if [ -f $payloads/payload.sh ]; then |
|---|
| 147 | PAYLOAD=`sh $payloads/payload.sh $VENDOR $MAINBOARD` |
|---|
| 148 | printf "Using payload $PAYLOAD\n" |
|---|
| 149 | fi |
|---|
| 150 | |
|---|
| 151 | mkdir -p $TARGET |
|---|
| 152 | |
|---|
| 153 | if [ -f $TARGCONFIG ]; then |
|---|
| 154 | cp $TARGCONFIG $TARGET/Config-${VENDOR}_${MAINBOARD}.lb |
|---|
| 155 | printf "Using existing test target $TARGCONFIG" |
|---|
| 156 | xml " <config>$TARGCONFIG</config>" |
|---|
| 157 | else |
|---|
| 158 | |
|---|
| 159 | printf " Creating config file..." |
|---|
| 160 | xml " <config>autogenerated</config>" |
|---|
| 161 | ( cat << EOF |
|---|
| 162 | # This will make a target directory of ./VENDOR_MAINBOARD |
|---|
| 163 | |
|---|
| 164 | target VENDOR_MAINBOARD |
|---|
| 165 | mainboard VENDOR/MAINBOARD |
|---|
| 166 | |
|---|
| 167 | option CC="CROSSCC" |
|---|
| 168 | option CONFIG_CROSS_COMPILE="CROSS_PREFIX" |
|---|
| 169 | option HOSTCC="CROSS_HOSTCC" |
|---|
| 170 | |
|---|
| 171 | __COMPRESSION__ |
|---|
| 172 | __LOGLEVEL__ |
|---|
| 173 | |
|---|
| 174 | EOF |
|---|
| 175 | if [ "$TARCH" == i386 ] ; then |
|---|
| 176 | cat <<EOF |
|---|
| 177 | romimage "normal" |
|---|
| 178 | option CONFIG_USE_FALLBACK_IMAGE=0 |
|---|
| 179 | if CONFIG_CBFS |
|---|
| 180 | else |
|---|
| 181 | option CONFIG_ROM_IMAGE_SIZE=0x17000 |
|---|
| 182 | end |
|---|
| 183 | option COREBOOT_EXTRA_VERSION=".0-normal" |
|---|
| 184 | payload __PAYLOAD__ |
|---|
| 185 | end |
|---|
| 186 | |
|---|
| 187 | romimage "fallback" |
|---|
| 188 | option CONFIG_USE_FALLBACK_IMAGE=1 |
|---|
| 189 | if CONFIG_CBFS |
|---|
| 190 | else |
|---|
| 191 | option CONFIG_ROM_IMAGE_SIZE=0x17000 |
|---|
| 192 | end |
|---|
| 193 | option COREBOOT_EXTRA_VERSION=".0-fallback" |
|---|
| 194 | payload __PAYLOAD__ |
|---|
| 195 | end |
|---|
| 196 | buildrom ./coreboot.rom CONFIG_ROM_SIZE "normal" "fallback" |
|---|
| 197 | EOF |
|---|
| 198 | else |
|---|
| 199 | cat <<EOF |
|---|
| 200 | romimage "only" |
|---|
| 201 | option COREBOOT_EXTRA_VERSION=".0" |
|---|
| 202 | payload __PAYLOAD__ |
|---|
| 203 | end |
|---|
| 204 | buildrom ./coreboot.rom CONFIG_ROM_SIZE "only" |
|---|
| 205 | EOF |
|---|
| 206 | fi |
|---|
| 207 | ) > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb |
|---|
| 208 | fi |
|---|
| 209 | |
|---|
| 210 | if [ "$loglevel" != "default" ]; then |
|---|
| 211 | LOGLEVEL1="option CONFIG_MAXIMUM_CONSOLE_LOGLEVEL=$loglevel" |
|---|
| 212 | LOGLEVEL2="option CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$loglevel" |
|---|
| 213 | else |
|---|
| 214 | LOGLEVEL1="# no loglevel override" |
|---|
| 215 | LOGLEVEL2="" |
|---|
| 216 | fi |
|---|
| 217 | |
|---|
| 218 | COMPRESSION="# no compression" |
|---|
| 219 | if which lzma >/dev/null 2>/dev/null; then |
|---|
| 220 | if [ "$PAYLOAD" != /dev/null ]; then |
|---|
| 221 | COMPRESSION="option CONFIG_COMPRESSED_PAYLOAD_LZMA=1" |
|---|
| 222 | fi |
|---|
| 223 | fi |
|---|
| 224 | |
|---|
| 225 | cp $TARGET/Config-${VENDOR}_${MAINBOARD}.lb $TARGET/Config-${VENDOR}_${MAINBOARD}.lb.pre |
|---|
| 226 | sed -e s:VENDOR:$VENDOR:g \ |
|---|
| 227 | -e s:MAINBOARD:$MAINBOARD:g \ |
|---|
| 228 | -e s:payload\ __PAYLOAD__:payload\ $PAYLOAD:g \ |
|---|
| 229 | -e s:CROSSCC:"$CC":g \ |
|---|
| 230 | -e s:CROSS_PREFIX:"$CROSS_COMPILE":g \ |
|---|
| 231 | -e s:CROSS_HOSTCC:"$HOSTCC":g \ |
|---|
| 232 | -e s:__COMPRESSION__:"$COMPRESSION":g \ |
|---|
| 233 | -e s:__LOGLEVEL__:"$LOGLEVEL1"\ |
|---|
| 234 | "$LOGLEVEL2":g \ |
|---|
| 235 | $TARGET/Config-${VENDOR}_${MAINBOARD}.lb.pre > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb |
|---|
| 236 | printf " ok\n" |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | function create_builddir |
|---|
| 240 | { |
|---|
| 241 | VENDOR=$1 |
|---|
| 242 | MAINBOARD=$2 |
|---|
| 243 | |
|---|
| 244 | printf " Creating builddir..." |
|---|
| 245 | |
|---|
| 246 | target_dir=$TARGET |
|---|
| 247 | config_dir=$LBROOT/util/newconfig |
|---|
| 248 | yapps2_py=$config_dir/yapps2.py |
|---|
| 249 | config_g=$config_dir/config.g |
|---|
| 250 | config_lb=Config-${VENDOR}_${MAINBOARD}.lb |
|---|
| 251 | |
|---|
| 252 | cd $target_dir |
|---|
| 253 | |
|---|
| 254 | build_dir=${VENDOR}_${MAINBOARD} |
|---|
| 255 | config_py=$build_dir/config.py |
|---|
| 256 | |
|---|
| 257 | if [ ! -d $build_dir ] ; then |
|---|
| 258 | mkdir -p $build_dir |
|---|
| 259 | fi |
|---|
| 260 | if [ ! -f $config_py ]; then |
|---|
| 261 | $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log |
|---|
| 262 | fi |
|---|
| 263 | |
|---|
| 264 | # make sure config.py is up-to-date |
|---|
| 265 | |
|---|
| 266 | export PYTHONPATH=$config_dir |
|---|
| 267 | $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log |
|---|
| 268 | if [ $? -eq 0 ]; then |
|---|
| 269 | printf "ok\n" |
|---|
| 270 | xml " <builddir>ok</builddir>" |
|---|
| 271 | xml " <log>" |
|---|
| 272 | xmlfile $build_dir/config.log |
|---|
| 273 | xml " </log>" |
|---|
| 274 | xml "" |
|---|
| 275 | return 0 |
|---|
| 276 | else |
|---|
| 277 | printf "FAILED! Log excerpt:\n" |
|---|
| 278 | xml " <builddir>failed</builddir>" |
|---|
| 279 | xml " <log>" |
|---|
| 280 | xmlfile $build_dir/config.log |
|---|
| 281 | xml " </log>" |
|---|
| 282 | xml "" |
|---|
| 283 | tail -n $CONTEXT $build_dir/config.log 2> /dev/null || tail -$CONTEXT $build_dir/config.log |
|---|
| 284 | return 1 |
|---|
| 285 | fi |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | function create_buildenv |
|---|
| 289 | { |
|---|
| 290 | VENDOR=$1 |
|---|
| 291 | MAINBOARD=$2 |
|---|
| 292 | CONFIG=$3 |
|---|
| 293 | create_config $VENDOR $MAINBOARD $CONFIG |
|---|
| 294 | create_builddir $VENDOR $MAINBOARD |
|---|
| 295 | } |
|---|
| 296 | |
|---|
| 297 | function compile_target |
|---|
| 298 | { |
|---|
| 299 | VENDOR=$1 |
|---|
| 300 | MAINBOARD=$2 |
|---|
| 301 | |
|---|
| 302 | printf " Compiling image " |
|---|
| 303 | test "$cpus" == "" && printf "in parallel .. " |
|---|
| 304 | test "$cpus" == "1" && printf "on 1 cpu .. " |
|---|
| 305 | test 0$cpus -gt 1 && printf "on %d cpus in parallel .. " $cpus |
|---|
| 306 | |
|---|
| 307 | CURR=$( pwd ) |
|---|
| 308 | cd $TARGET/${VENDOR}_${MAINBOARD} |
|---|
| 309 | stime=`perl -e 'print time();'` |
|---|
| 310 | eval $MAKE $silent -j $cpus &> make.log |
|---|
| 311 | ret=$? |
|---|
| 312 | etime=`perl -e 'print time();'` |
|---|
| 313 | duration=$(( $etime - $stime )) |
|---|
| 314 | if [ $ret -eq 0 ]; then |
|---|
| 315 | xml " <compile>ok</compile>" |
|---|
| 316 | xml " <compiletime>${duration}s</compiletime>" |
|---|
| 317 | xml " <log>" |
|---|
| 318 | xmlfile make.log |
|---|
| 319 | xml " </log>" |
|---|
| 320 | printf "ok\n" > compile.status |
|---|
| 321 | printf "ok. (took ${duration}s)\n" |
|---|
| 322 | cd $CURR |
|---|
| 323 | return 0 |
|---|
| 324 | else |
|---|
| 325 | xml " <compile>failed</compile>" |
|---|
| 326 | xml " <compiletime>${duration}s</compiletime>" |
|---|
| 327 | xml " <log>" |
|---|
| 328 | xmlfile make.log |
|---|
| 329 | xml " </log>" |
|---|
| 330 | |
|---|
| 331 | printf "FAILED after ${duration}s! Log excerpt:\n" |
|---|
| 332 | tail -n $CONTEXT make.log 2> /dev/null || tail -$CONTEXT make.log |
|---|
| 333 | cd $CURR |
|---|
| 334 | return 1 |
|---|
| 335 | fi |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | function built_successfully |
|---|
| 339 | { |
|---|
| 340 | CURR=`pwd` |
|---|
| 341 | status="fail" |
|---|
| 342 | if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then |
|---|
| 343 | cd $TARGET/${VENDOR}_${MAINBOARD} |
|---|
| 344 | if [ -r compile.status ] ; then |
|---|
| 345 | status=`cat compile.status` |
|---|
| 346 | fi |
|---|
| 347 | cd $CURR |
|---|
| 348 | fi |
|---|
| 349 | [ "$buildall" != "true" -a "$status" == "ok" ] |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | function build_broken |
|---|
| 353 | { |
|---|
| 354 | CURR=`pwd` |
|---|
| 355 | status="yes" |
|---|
| 356 | [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no" |
|---|
| 357 | [ "$buildbroken" == "true" -o "$status" == "yes" ] |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | function build_target |
|---|
| 361 | { |
|---|
| 362 | VENDOR=$1 |
|---|
| 363 | MAINBOARD=$2 |
|---|
| 364 | CONFIG=$3 |
|---|
| 365 | TARCH=$( architecture $VENDOR $MAINBOARD ) |
|---|
| 366 | |
|---|
| 367 | # Allow architecture override in an abuild.info file. |
|---|
| 368 | # This is used for the Motorola Sandpoint, which is not a real target |
|---|
| 369 | # but a skeleton target for the Sandpoint X3. |
|---|
| 370 | [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info" ] && \ |
|---|
| 371 | source $LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info |
|---|
| 372 | |
|---|
| 373 | # default setting |
|---|
| 374 | |
|---|
| 375 | CC="${CROSS_COMPILE}gcc" |
|---|
| 376 | CROSS_COMPILE="" |
|---|
| 377 | found_crosscompiler=false |
|---|
| 378 | if which $TARCH-elf-gcc 2>/dev/null >/dev/null; then |
|---|
| 379 | # i386-elf target needs --divide, for i386-linux, that's the default |
|---|
| 380 | if [ "$TARCH" = "i386" ]; then |
|---|
| 381 | CC="$CC -Wa,--divide" |
|---|
| 382 | fi |
|---|
| 383 | CROSS_COMPILE="$TARCH-elf-" |
|---|
| 384 | CC=gcc |
|---|
| 385 | echo using $CROSS_COMPILE$CC |
|---|
| 386 | found_crosscompiler=true |
|---|
| 387 | fi |
|---|
| 388 | |
|---|
| 389 | HOSTCC='gcc' |
|---|
| 390 | |
|---|
| 391 | printf "Processing mainboard/$VENDOR/$MAINBOARD" |
|---|
| 392 | |
|---|
| 393 | xml "<mainboard>" |
|---|
| 394 | xml "" |
|---|
| 395 | xml " <vendor>$VENDOR</vendor>" |
|---|
| 396 | xml " <device>$MAINBOARD</device>" |
|---|
| 397 | xml "" |
|---|
| 398 | xml " <architecture>$TARCH</architecture>" |
|---|
| 399 | xml "" |
|---|
| 400 | |
|---|
| 401 | if [ "$ARCH" = "$TARCH" -o $found_crosscompiler = true ]; then |
|---|
| 402 | printf " ($TARCH: ok)\n" |
|---|
| 403 | else |
|---|
| 404 | found_crosscompiler=false |
|---|
| 405 | if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then |
|---|
| 406 | CC="gcc -m32" |
|---|
| 407 | found_crosscompiler=true |
|---|
| 408 | fi |
|---|
| 409 | if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then |
|---|
| 410 | CC="gcc -m32" |
|---|
| 411 | found_crosscompiler=true |
|---|
| 412 | fi |
|---|
| 413 | if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then |
|---|
| 414 | for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \ |
|---|
| 415 | powerpc-7450-linux-gnu- powerpc-elf-; do |
|---|
| 416 | if ${prefix}gcc --version > /dev/null 2> /dev/null ; then |
|---|
| 417 | found_crosscompiler=true |
|---|
| 418 | CROSS_COMPILE=$prefix |
|---|
| 419 | fi |
|---|
| 420 | done |
|---|
| 421 | fi |
|---|
| 422 | |
|---|
| 423 | |
|---|
| 424 | # TBD: look for suitable cross compiler suite |
|---|
| 425 | # cross-$TARCH-gcc and cross-$TARCH-ld |
|---|
| 426 | |
|---|
| 427 | # Check result: |
|---|
| 428 | if [ $found_crosscompiler == "false" ]; then |
|---|
| 429 | printf " ($TARCH: skipped, we're $ARCH)\n\n" |
|---|
| 430 | xml " <status>notbuilt</status>" |
|---|
| 431 | xml "" |
|---|
| 432 | xml "</mainboard>" |
|---|
| 433 | |
|---|
| 434 | return 0 |
|---|
| 435 | else |
|---|
| 436 | printf " ($TARCH: ok, we're $ARCH with a ${CROSS_COMPILE} cross compiler)\n" |
|---|
| 437 | xml " <compiler>" |
|---|
| 438 | xml " <path>`which ${CROSS_COMPILE}gcc`</path>" |
|---|
| 439 | xml " <version>`${CROSS_COMPILE}gcc --version | head -1`</version>" |
|---|
| 440 | xml " </compiler>" |
|---|
| 441 | xml "" |
|---|
| 442 | fi |
|---|
| 443 | fi |
|---|
| 444 | |
|---|
| 445 | CC=${CROSS_COMPILE}$CC |
|---|
| 446 | |
|---|
| 447 | if [ "$stackprotect" = "true" ]; then |
|---|
| 448 | CC="$CC -fno-stack-protector" |
|---|
| 449 | fi |
|---|
| 450 | |
|---|
| 451 | if [ "$scanbuild" = "true" ]; then |
|---|
| 452 | ccwrap=`mktemp` |
|---|
| 453 | mkdir -p $TARGET/${VENDOR}_${MAINBOARD} |
|---|
| 454 | mkdir -p $TARGET/scan-build-results-tmp |
|---|
| 455 | mv $ccwrap $TARGET/${VENDOR}_${MAINBOARD} |
|---|
| 456 | ccwrap=$TARGET/${VENDOR}_${MAINBOARD}/`basename $ccwrap` |
|---|
| 457 | echo '#!/bin/sh' > $ccwrap |
|---|
| 458 | echo $CC' "$@"' >> $ccwrap |
|---|
| 459 | chmod +x $ccwrap |
|---|
| 460 | origMAKE=$MAKE |
|---|
| 461 | MAKE="scan-build --use-cc=$ccwrap -o $TARGET/scan-build-results-tmp -analyze-headers $MAKE GCC=$ccwrap" |
|---|
| 462 | CC="\$(CC)" |
|---|
| 463 | HOSTCC="CCC_CC=$HOSTCC \$(CC)" |
|---|
| 464 | fi |
|---|
| 465 | |
|---|
| 466 | built_successfully $VENDOR $MAINBOARD && \ |
|---|
| 467 | { |
|---|
| 468 | printf " ( mainboard/$VENDOR/$MAINBOARD previously ok )\n\n" |
|---|
| 469 | xml " <status>previouslyok</status>" |
|---|
| 470 | xml "" |
|---|
| 471 | xml "</mainboard>" |
|---|
| 472 | return 0 |
|---|
| 473 | } |
|---|
| 474 | |
|---|
| 475 | build_broken $VENDOR $MAINBOARD || \ |
|---|
| 476 | { |
|---|
| 477 | printf " ( broken mainboard/$VENDOR/$MAINBOARD skipped )\n\n" |
|---|
| 478 | xml " <status>knownbroken</status>" |
|---|
| 479 | xml "" |
|---|
| 480 | xml "</mainboard>" |
|---|
| 481 | return 0 |
|---|
| 482 | } |
|---|
| 483 | |
|---|
| 484 | create_buildenv $VENDOR $MAINBOARD $CONFIG |
|---|
| 485 | if [ $? -eq 0 -a $configureonly -eq 0 ]; then |
|---|
| 486 | compile_target $VENDOR $MAINBOARD && |
|---|
| 487 | xml " <status>ok</status>" || |
|---|
| 488 | xml "<status>broken</status>" |
|---|
| 489 | if [ "$scanbuild" = "true" ]; then |
|---|
| 490 | mv `dirname $TARGET/scan-build-results-tmp/*/index.html` $TARGET/${VENDOR}_${MAINBOARD}-scanbuild |
|---|
| 491 | MAKE=$origMAKE |
|---|
| 492 | fi |
|---|
| 493 | fi |
|---|
| 494 | |
|---|
| 495 | xml "" |
|---|
| 496 | xml "</mainboard>" |
|---|
| 497 | |
|---|
| 498 | printf "\n" |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | function test_target |
|---|
| 502 | { |
|---|
| 503 | VENDOR=$1 |
|---|
| 504 | MAINBOARD=$2 |
|---|
| 505 | |
|---|
| 506 | if [ "$hwtest" != "true" ]; then |
|---|
| 507 | return 0 |
|---|
| 508 | fi |
|---|
| 509 | |
|---|
| 510 | # image does not exist. we silently skip the patch. |
|---|
| 511 | if [ ! -r "$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" ]; then |
|---|
| 512 | return 0 |
|---|
| 513 | fi |
|---|
| 514 | |
|---|
| 515 | which curl &> /dev/null |
|---|
| 516 | if [ $? != 0 ]; then |
|---|
| 517 | printf "curl is not installed but required for test submission. skipping test.\n\n" |
|---|
| 518 | return 0 |
|---|
| 519 | fi |
|---|
| 520 | |
|---|
| 521 | CURR=`pwd` |
|---|
| 522 | if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/tested" ]; then |
|---|
| 523 | printf "Testing image for board $VENDOR $MAINBOARD skipped (previously submitted).\n\n" |
|---|
| 524 | return 0 |
|---|
| 525 | fi |
|---|
| 526 | # touch $TARGET/${VENDOR}_${MAINBOARD}/tested |
|---|
| 527 | |
|---|
| 528 | printf "Submitting image for board $VENDOR $MAINBOARD to test system...\n" |
|---|
| 529 | |
|---|
| 530 | curl -f -F "romfile=@$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" \ |
|---|
| 531 | -F "mode=abuild" -F "mainboard=${VENDOR}_${MAINBOARD}" -F "submit=Upload" \ |
|---|
| 532 | "http://qa.coreboot.org/deployment/send.php" |
|---|
| 533 | |
|---|
| 534 | printf "\n" |
|---|
| 535 | return 0 |
|---|
| 536 | } |
|---|
| 537 | |
|---|
| 538 | function remove_target |
|---|
| 539 | { |
|---|
| 540 | if [ "$remove" != "true" ]; then |
|---|
| 541 | return 0 |
|---|
| 542 | fi |
|---|
| 543 | |
|---|
| 544 | VENDOR=$1 |
|---|
| 545 | MAINBOARD=$2 |
|---|
| 546 | |
|---|
| 547 | # Save the generated coreboot.rom file of each board. |
|---|
| 548 | if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" ]; then |
|---|
| 549 | cp $TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom \ |
|---|
| 550 | ${VENDOR}_${MAINBOARD}_coreboot.rom |
|---|
| 551 | fi |
|---|
| 552 | |
|---|
| 553 | printf "Removing build dir for board $VENDOR $MAINBOARD...\n" |
|---|
| 554 | rm -rf $TARGET/${VENDOR}_${MAINBOARD} |
|---|
| 555 | |
|---|
| 556 | return 0 |
|---|
| 557 | } |
|---|
| 558 | |
|---|
| 559 | function myhelp |
|---|
| 560 | { |
|---|
| 561 | printf "Usage: $0 [-v] [-a] [-b] [-r] [-t <vendor/board>] [-p <dir>] [lbroot]\n" |
|---|
| 562 | printf " $0 [-V|--version]\n" |
|---|
| 563 | printf " $0 [-h|--help]\n\n" |
|---|
| 564 | |
|---|
| 565 | printf "Options:\n" |
|---|
| 566 | printf " [-v|--verbose] print more messages\n" |
|---|
| 567 | printf " [-a|--all] build previously succeeded ports as well\n" |
|---|
| 568 | printf " [-b|--broken] attempt to build ports that are known broken\n" |
|---|
| 569 | printf " [-r|--remove] remove output dir after build\n" |
|---|
| 570 | printf " [-t|--target <vendor/board>] attempt to build target vendor/board only\n" |
|---|
| 571 | printf " [-p|--payloads <dir>] use payloads in <dir> to build images\n" |
|---|
| 572 | printf " [-V|--version] print version number and exit\n" |
|---|
| 573 | printf " [-h|--help] print this help and exit\n" |
|---|
| 574 | printf " [-x|--xml] write xml log file \n" |
|---|
| 575 | printf " (defaults to $XMLFILE)\n" |
|---|
| 576 | printf " [-T|--test] submit image(s) to automated test system\n" |
|---|
| 577 | printf " [-c|--cpus <numcpus>] build on <numcpus> at the same time\n" |
|---|
| 578 | printf " [-s|--silent] omit compiler calls in logs\n" |
|---|
| 579 | printf " [-ns|--nostackprotect] use gcc -fno-stack-protector option\n" |
|---|
| 580 | printf " [-sb|--scan-build] use clang's static analyzer\n" |
|---|
| 581 | printf " [-C|--config] configure-only mode\n" |
|---|
| 582 | printf " [-l|--loglevel <num>] set loglevel\n" |
|---|
| 583 | printf " [lbroot] absolute path to coreboot sources\n" |
|---|
| 584 | printf " (defaults to $LBROOT)\n\n" |
|---|
| 585 | } |
|---|
| 586 | |
|---|
| 587 | function myversion |
|---|
| 588 | { |
|---|
| 589 | cat << EOF |
|---|
| 590 | |
|---|
| 591 | coreboot autobuild v$ABUILD_VERSION ($ABUILD_DATE) |
|---|
| 592 | |
|---|
| 593 | Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org> |
|---|
| 594 | Copyright (C) 2006-2008 by coresystems GmbH <info@coresystems.de> |
|---|
| 595 | |
|---|
| 596 | This program is free software; you may redistribute it under the terms |
|---|
| 597 | of the GNU General Public License. This program has absolutely no |
|---|
| 598 | warranty. |
|---|
| 599 | |
|---|
| 600 | EOF |
|---|
| 601 | } |
|---|
| 602 | |
|---|
| 603 | # default options |
|---|
| 604 | target="" |
|---|
| 605 | buildall=false |
|---|
| 606 | verbose=false |
|---|
| 607 | |
|---|
| 608 | test -f util/newconfig/config.g && LBROOT=$( pwd ) |
|---|
| 609 | test -f ../util/newconfig/config.g && LBROOT=$( cd ..; pwd ) |
|---|
| 610 | test "$LBROOT" = "" && LBROOT=$( cd ../..; pwd ) |
|---|
| 611 | |
|---|
| 612 | # parse parameters.. try to find out whether we're running GNU getopt |
|---|
| 613 | getoptbrand="`getopt -V`" |
|---|
| 614 | if [ "${getoptbrand:0:6}" == "getopt" ]; then |
|---|
| 615 | # Detected GNU getopt that supports long options. |
|---|
| 616 | args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config,loglevel Vvhat:bp:Tc:sxCl: -- "$@"` |
|---|
| 617 | eval set "$args" |
|---|
| 618 | else |
|---|
| 619 | # Detected non-GNU getopt |
|---|
| 620 | args=`getopt Vvhat:bp:Tc:sxCl: $*` |
|---|
| 621 | set -- $args |
|---|
| 622 | fi |
|---|
| 623 | |
|---|
| 624 | if [ $? != 0 ]; then |
|---|
| 625 | myhelp |
|---|
| 626 | exit 1 |
|---|
| 627 | fi |
|---|
| 628 | |
|---|
| 629 | while true ; do |
|---|
| 630 | case "$1" in |
|---|
| 631 | -x|--xml) shift; mode=xml; rm -f $XMLFILE ;; |
|---|
| 632 | -t|--target) shift; target="$1"; shift;; |
|---|
| 633 | -a|--all) shift; buildall=true;; |
|---|
| 634 | -b|--broken) shift; buildbroken=true;; |
|---|
| 635 | -r|--remove) shift; remove=true; shift;; |
|---|
| 636 | -v|--verbose) shift; verbose=true;; |
|---|
| 637 | -V|--version) shift; myversion; exit 0;; |
|---|
| 638 | -h|--help) shift; myversion; myhelp; exit 0;; |
|---|
| 639 | -p|--payloads) shift; payloads="$1"; shift;; |
|---|
| 640 | -T|--test) shift; hwtest=true;; |
|---|
| 641 | -c|--cpus) shift; cpus="$1"; test "$cpus" == "max" && cpus=""; shift;; |
|---|
| 642 | -s|--silent) shift; silent="-s";; |
|---|
| 643 | -ns|--nostackprotect) shift; stackprotect=true;; |
|---|
| 644 | -sb|--scan-build) shift; scanbuild=true;; |
|---|
| 645 | -C|--config) shift; configureonly=1;; |
|---|
| 646 | -l|--loglevel) shift; loglevel="$1"; shift;; |
|---|
| 647 | --) shift; break;; |
|---|
| 648 | -*) printf "Invalid option\n\n"; myhelp; exit 1;; |
|---|
| 649 | *) break;; |
|---|
| 650 | esac |
|---|
| 651 | done |
|---|
| 652 | |
|---|
| 653 | # /path/to/freebios2/ |
|---|
| 654 | test -z "$1" || LBROOT=$1 |
|---|
| 655 | |
|---|
| 656 | debug "LBROOT=$LBROOT" |
|---|
| 657 | |
|---|
| 658 | xml '<?xml version="1.0" encoding="utf-8"?>' |
|---|
| 659 | xml '<abuild>' |
|---|
| 660 | |
|---|
| 661 | if [ "$target" != "" ]; then |
|---|
| 662 | # build a single board |
|---|
| 663 | VENDOR=`printf $target|cut -f1 -d/` |
|---|
| 664 | MAINBOARD=`printf $target|cut -f2 -d/` |
|---|
| 665 | CONFIG=`printf $target|cut -f3 -d/` |
|---|
| 666 | build_target $VENDOR $MAINBOARD $CONFIG |
|---|
| 667 | test_target $VENDOR $MAINBOARD |
|---|
| 668 | else |
|---|
| 669 | # build all boards per default |
|---|
| 670 | for VENDOR in $( vendors ); do |
|---|
| 671 | for MAINBOARD in $( mainboards $VENDOR ); do |
|---|
| 672 | build_target $VENDOR $MAINBOARD |
|---|
| 673 | test_target $VENDOR $MAINBOARD |
|---|
| 674 | remove_target $VENDOR $MAINBOARD |
|---|
| 675 | done |
|---|
| 676 | done |
|---|
| 677 | fi |
|---|
| 678 | xml '</abuild>' |
|---|
| 679 | |
|---|