5 # This script builds coreboot images for all available targets.
7 # (C) 2004 by Stefan Reinauer <stepan@openbios.org>
8 # (C) 2006-2010 by coresystems GmbH <info@coresystems.de>
9 # (C) 2013-2014 Sage Electronic Engineering, LLC
10 # (C) 2014 Patrick Georgi <patrick@georgi-clan.de>
12 # This file is subject to the terms and conditions of the GNU General
13 # Public License. See the file COPYING in the main directory of this
14 # archive for more details.
17 #set -x # Turn echo on....
19 ABUILD_DATE
="Mar 28, 2017"
20 ABUILD_VERSION
="0.10.03"
24 # Where shall we place all the build trees?
25 TARGET
=${COREBOOT_BUILD_DIR:-coreboot-builds}
26 XMLFILE
=$TOP/abuild.xml
29 export KCONFIG_OVERWRITECONFIG
=1
31 # path to payload. Should be more generic
34 # get path to coreboot XGCC if it's not already set
35 if [ -z "$XGCCPATH" ]; then
36 XGCCPATH
="${TOP}/util/crossgcc/xgcc/bin/"
39 # Add XGCC to the path.
40 if [ -d "$XGCCPATH" ] && [[ ":$PATH:" != *":$XGCCPATH:"* ]]; then
41 PATH
="$XGCCPATH:$PATH"
44 # Lines of error context to be printed in FAILURE case
50 # Did any board fail to build?
53 # Exit with a non-zero errorlevel on failure
56 # default: don't save checksums
59 # default: single CPU build
62 # change with -d <directory>
63 configdir
="$TOP/configs"
68 # One might want to adjust these in case of cross compiling
69 for i
in make gmake gnumake nonexistant_make
; do
70 $i --version 2>/dev
/null |
grep "GNU Make" >/dev
/null
&& break
72 if [ "$i" = "nonexistant_make" ]; then
73 echo No GNU Make found.
78 # this can be changed to junit by -J
81 # quiet mode: only print pass, failure, and 'skipped' messages
84 # clang mode enabled by -sb option.
87 # Mark whether abuild was called recursively
94 printf "\n%s: execution interrupted manually.\n" "$0"
95 if [ "$mode" == "junit" ]; then
96 printf "%s: deleting incomplete xml output file.\n" "$0"
103 test "$verbose" == "true" && echo "$*"
108 test "$mode" == "junit" && echo "$*" >> "$XMLFILE"
114 test "$mode" == "junit" && {
121 # Return mainboard descriptors.
122 # By default all mainboards are listed, but when passing a two-level path
123 # below src/mainboard, such as emulation/qemu-i440fx, or emulation/*, it
124 # returns all board descriptors in that hierarchy.
125 function get_mainboards
127 local search_space
=${1-*/*}
128 # shellcheck disable=SC2086
129 grep -h "^[[:space:]]*config\>[[:space:]]*\<BOARD_" \
130 ${ROOT}/src
/mainboard
/${search_space}/Kconfig.name
2>/dev
/null | \
131 sed "s,^.*\<BOARD_\([A-Z0-9_]*\)\>.*$,\1,"
134 # Given a mainboard descriptor, return its directory below src/mainboard
135 function mainboard_directory
139 # shellcheck disable=SC2086
140 grep -l "^[[:space:]]*config\>[[:space:]]*\<BOARD_${MAINBOARD}\>" \
141 ${ROOT}/src
/mainboard
/*/*/Kconfig.name | \
142 sed "s:^$ROOT/src/mainboard/\(.*\)/Kconfig.name$:\1:"
145 # Given a mainboard descriptor, return its vendor (CONFIG_VENDOR_*)
146 function mainboard_vendor
151 # shellcheck disable=SC2086
153 grep -l "^[[:space:]]*config\>[[:space:]]*\<BOARD_${MAINBOARD}\>" \
154 ${ROOT}/src
/mainboard
/*/*/Kconfig.name | \
155 sed "s:^\(${ROOT}/src/mainboard/.*\)/.*/\(Kconfig.name\)$:\1/\2:" )
156 if [ ! -f "$kconfig_file" ]; then
159 grep "^[[:space:]]*config\>[[:space:]]*\<VENDOR_" "$kconfig_file" | \
160 sed "s,^.*\<VENDOR_\([A-Z0-9_]*\)\>.*$,\1,"
163 # Accepts directory names (eg. emulation/qemu-i440fx) and mainboard
164 # descriptors (eg. EMULATION_QEMU_X86_I440F} and returns the latter
166 # If a directory contains multiple boards, returns them all.
167 function normalize_target
169 # TODO: Change 'targets' variable to an array
173 VARIANT_UC
=$
(echo "${variant}" |
tr '[:lower:]' '[:upper:]')
175 targets
=$
(get_mainboards
"$1")
176 if [ -n "$targets" ]; then
177 # shellcheck disable=SC2086
178 targets
="$(grep "${VARIANT_UC}\$
" <<< ${targets})"
183 targets
=$
(echo "$1" |
tr ',' ' ')
184 for i
in $targets; do
185 if [ -n "$(mainboard_directory "$i")" ]; then
188 echo "$i is not a valid target" >&2
194 # shellcheck disable=SC2129
195 function create_config
201 local config_file
="${build_dir}/config.build"
202 board_srcdir
="$(mainboard_directory "${BUILD_NAME}")"
204 mkdir
-p "${build_dir}"
205 mkdir
-p "$TARGET/sharedutils"
207 if [ "$quiet" == "false" ]; then echo " Creating config file for $BUILD_NAME..."; fi
208 echo "CONFIG_VENDOR_$(mainboard_vendor "${BUILD_NAME}")=y" > "${config_file}"
209 echo "CONFIG_BOARD_${BUILD_NAME}=y" >> "${config_file}"
210 grep "select[\t ]*ARCH" "${ROOT}/src/mainboard/${board_srcdir}/Kconfig" | \
211 sed "s,^.*\(ARCH_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> "${config_file}"
212 echo "CONFIG_MAINBOARD_DIR=\"${board_srcdir}\"" >> "${config_file}"
214 update_config
"$BUILD_NAME" "$build_dir" "$config_file"
217 if [ $ret -eq 0 ]; then
218 if [ "$quiet" == "false" ]; then echo " $BUILD_NAME config created."; fi
221 # Does this ever happen?
222 if [ "$quiet" == "false" ]; then printf "%s config creation FAILED!\nLog excerpt:\n" "$BUILD_NAME"; fi
223 tail -n $CONTEXT "$build_dir/config.log" 2> /dev
/null ||
tail -$CONTEXT "$build_dir/config.log"
228 function update_config
236 defconfig_file
=${build_dir}/config.$
(echo "${BUILD_NAME}" |
tr '[:upper:]' '[:lower:]').default
238 # get a working payload for the board if we have one.
239 # the --payload option expects a directory containing
240 # a shell script payload.sh
241 # Usage: payload.sh [BOARD]
242 # the script returns an absolute path to the payload binary.
244 if [ -f "$payloads/payload.sh" ]; then
245 PAYLOAD
=$
(sh
"$payloads/payload.sh" "$BUILD_NAME")
247 if [ $PAYLOAD_OK -gt 0 ]; then
248 echo "problem with payload"
251 if [ "$quiet" == "false" ]; then printf "Using payload %s\n" "$PAYLOAD"; fi
252 elif [ "$payloads" = "none" ]; then
256 if [ "$PAYLOAD" = "none" ]; then
258 echo "CONFIG_PAYLOAD_NONE=y"
259 echo "# CONFIG_PAYLOAD_ELF is not set"
260 } >> "${config_file}"
261 elif [ "$PAYLOAD" != "/dev/null" ]; then
263 echo "# CONFIG_PAYLOAD_NONE is not set"
264 echo "CONFIG_PAYLOAD_ELF=y"
265 echo "CONFIG_PAYLOAD_FILE=\"$PAYLOAD\""
266 } >> "${config_file}"
268 # Disable all other payload config options
270 echo "# CONFIG_PAYLOAD_SEABIOS is not set"
271 echo "# CONFIG_PAYLOAD_BAYOU is not set"
272 echo "# CONFIG_PAYLOAD_FILO is not set"
273 echo "# CONFIG_PAYLOAD_GRUB2 is not set"
274 echo "# CONFIG_PAYLOAD_OPENBIOS is not set"
275 echo "# CONFIG_PAYLOAD_DEPTHCHARGE is not set"
276 echo "# CONFIG_PAYLOAD_LINUXBOOT is not set"
277 echo "# CONFIG_PAYLOAD_UBOOT is not set"
278 echo "# CONFIG_PAYLOAD_TIANOCORE is not set"
279 echo "# CONFIG_PXE is not set"
280 echo "# CONFIG_BUILD_IPXE is not set"
281 echo "# CONFIG_MEMTEST_SECONDARY_PAYLOAD is not set"
282 echo "# CONFIG_COREINFO_SECONDARY_PAYLOAD is not set"
283 echo "# CONFIG_NVRAMCUI_SECONDARY_PAYLOAD is not set"
284 echo "# CONFIG_TINT_SECONDARY_PAYLOAD is not set"
285 } >> "${config_file}"
287 if [ "$quiet" == "false" ]; then echo " $MAINBOARD ($customizing)"; fi
288 # shellcheck disable=SC2059
289 printf "$configoptions" >> "${config_file}"
291 yes "" 2>/dev
/null |
$MAKE oldconfig
"$verboseopt" "DOTCONFIG=${config_file}" "obj=${build_dir}" "objutil=$TARGET/sharedutils" &> "${build_dir}/config.log" ; \
293 if [ $CONFIG_OK -eq 0 ]; then
294 $MAKE savedefconfig
"$verboseopt" DEFCONFIG
="${defconfig_file}" DOTCONFIG="${config_file}" obj="${build_dir}" objutil="$TARGET/sharedutils" &>> "${build_dir}/config.log"
301 # shellcheck disable=SC2129
302 function create_buildenv
308 if [ -z "$config_file" ]; then
309 create_config
"$BUILD_NAME" "$build_dir"
311 local new_config_file
="${build_dir}/config.build"
312 cp "$config_file" "$new_config_file"
313 update_config
"$BUILD_NAME" "$build_dir" "$new_config_file"
317 # Allow simple "make" in the target directory
318 local MAKEFILE
=$TARGET/${BUILD_NAME}/Makefile
319 echo "# autogenerated" > "$MAKEFILE"
320 echo "TOP=$ROOT" >> "$MAKEFILE"
321 echo "BUILD=$TARGET" >> "$MAKEFILE"
322 echo "OBJ=\$(BUILD)/${MAINBOARD}" >> "$MAKEFILE"
323 echo "OBJUTIL=\$(BUILD)/sharedutils" >> "$MAKEFILE"
324 echo "all:" >> "$MAKEFILE"
325 echo " @cp -a config.h config.h.bak" >> "$MAKEFILE"
326 echo " @cd \$(TOP); \$(MAKE) oldconfig DOTCONFIG=\$(OBJ)/config.build objutil=\$(OBJUTIL) obj=\$(OBJ)" >> "$MAKEFILE"
327 echo " @tail -n+6 config.h > config.new; tail -n+6 config.h.bak > config.old" >> "$MAKEFILE"
328 echo " @cmp -s config.new config.old && cp -a config.h.bak config.h || echo \"Config file changed\"" >> "$MAKEFILE"
329 echo " @rm config.h.bak config.new config.old" >> "$MAKEFILE"
330 echo " @cd \$(TOP); \$(MAKE) DOTCONFIG=\$(OBJ)/config.build objutil=\$(OBJUTIL) obj=\$(OBJ)" >> "$MAKEFILE"
335 function check_config
339 local TEST_STRING
="$3"
341 local CONFIG_FILE
="$BUILD_DIR/config.build"
342 local CONFIG_LOG
="$BUILD_DIR/config.log"
344 if ! grep -q "$TEST_STRING" "$CONFIG_FILE"; then
345 echo "config file: $CONFIG_FILE has incorrect $TEST_TYPE"
346 echo "Error: Expected '$TEST_STRING' in config file." >> "$CONFIG_LOG"
353 function compile_target
357 if [ "$quiet" == "false" ]; then echo " Compiling $MAINBOARD image$cpuconfig..."; fi
360 #stime=`perl -e 'print time();' 2>/dev/null || date +%s`
361 eval "$BUILDPREFIX" "$MAKE" "$verboseopt" DOTCONFIG
="${build_dir}/config.build" obj
="${build_dir}" objutil
="$TARGET/sharedutils" BUILD_TIMELESS
=$TIMELESS \
362 &> "${build_dir}/make.log" ; \
364 cp "${ROOT}/.xcompile" "${build_dir}/xcompile.build"
365 cd "${build_dir}" ||
return $?
367 etime
=$
(perl
-e 'print time();' 2>/dev
/null ||
date +%s
)
368 duration
=$
(( etime
- stime
))
369 junit
" <testcase classname='board${testclass/#/.}' name='$BUILD_NAME' time='$duration' >"
371 if [ $MAKE_FAILED -eq 0 ]; then
374 junit
"</system-out>"
375 printf "ok\n" > compile.status
376 printf "%s built successfully. (took %ss)\n" "$BUILD_NAME" "${duration}"
377 echo "$BUILD_NAME" >> "$PASSED_BOARDS"
379 junit
"<failure type='BuildFailed'>"
382 printf "failed\n" > compile.status
383 printf "%s build FAILED after %ss!\nLog excerpt:\n" "$BUILD_NAME" "${duration}"
384 tail -n $CONTEXT make.log
2> /dev
/null ||
tail -$CONTEXT make.log
385 if [ "$clean_work" = "true" ]; then
386 echo "$BUILD_NAME" >> "$FAILED_BOARDS"
388 echo "$BUILD_NAME - Log: ${build_dir}/make.log" >> "$FAILED_BOARDS"
392 cd "$CURR" ||
return $?
393 if [ -n "$checksum_file" ]; then
394 sha256sum
"${build_dir}/coreboot.rom" >> "${checksum_file}_platform"
395 sort "${build_dir}/config.h" |
grep CONFIG_
> "${build_dir}/config.h.sorted"
396 sha256sum
"${build_dir}/config.h.sorted" >> "${checksum_file}_config"
398 if [ "$clean_work" = "true" ]; then
399 rm -rf "${build_dir}"
404 function build_config
413 board_srcdir
=$
(mainboard_directory
"${MAINBOARD}")
415 if [ "$(cat "${build_dir}/compile.status
" 2>/dev/null)" = "ok" ] && \
416 [ "$buildall" = "false" ]; then
417 echo "Skipping $BUILD_NAME; (already successful)"
423 if [ "$chromeos" = true
] && [ "$(grep -c "^
[[:space
:]]*select[[:space
:]]*MAINBOARD_HAS_CHROMEOS\
>" "${ROOT}/src
/mainboard
/${board_srcdir}/Kconfig
")" -eq 0 ]; then
424 echo "${BUILD_NAME} doesn't support Chrome OS, skipping."
428 if [ -f "src/mainboard/${board_srcdir}/abuild.disabled" ]; then
429 echo "${BUILD_NAME} disabled:"
430 cat "src/mainboard/${board_srcdir}/abuild.disabled"
434 if [ "$quiet" == "false" ]; then echo "Building $BUILD_NAME"; fi
435 mkdir
-p "$TARGET/${BUILD_NAME}" "$TARGET/abuild"
436 ABSPATH
="$(cd "$TARGET/abuild
" && pwd)"
437 XMLFILE
="$ABSPATH/${BUILD_NAME}.xml"
440 stime
=$
(perl
-e 'print time();' 2>/dev
/null ||
date +%s
)
441 create_buildenv
"$BUILD_NAME" "$build_dir" "$config_file"
442 local BUILDENV_CREATED
=$?
444 check_config
"$build_dir" "mainboard" "CONFIG_BOARD_${MAINBOARD}=y"
445 local MAINBOARD_OK
=$?
447 check_config
"$build_dir" "vendor" "CONFIG_VENDOR_$(mainboard_vendor "${MAINBOARD}")=y"
450 if [ $BUILDENV_CREATED -ne 0 ] ||
[ $MAINBOARD_OK -ne 0 ] ||
[ $VENDOR_OK -ne 0 ]; then
451 junit
" <testcase classname='board${testclass/#/.}' name='$BUILD_NAME' >"
453 junit
"<failure type='BuildFailed'>"
454 junitfile
"$build_dir/config.log"
456 printf "failed\n" > compile.status
457 printf "%s build configuration FAILED!\nLog excerpt:\n" "$BUILD_NAME"
458 tail -n $CONTEXT "$build_dir/config.log" 2> /dev
/null ||
tail -$CONTEXT "$build_dir/config.log"
461 echo "$BUILD_NAME - Log: ${TOP}/$build_dir/config.log" >> "$FAILED_BOARDS"
465 required_arches
=$
(grep -E "^CONFIG_ARCH_(BOOTBLOCK|R.MSTAGE|VERSTAGE)" "$TARGET/${BUILD_NAME}/config.build" | \
466 sed "s,^CONFIG_ARCH_[^_]*_\([^=]*\)=.*$,\1," |
sort -u |
tr 'A-Z\n\r' 'a-z ')
467 # shellcheck disable=SC2016,SC2059
468 missing_arches
=$
(printf 'include .xcompile\nall: ; @echo $(foreach arch,'"$required_arches"',$(if $(filter $(arch),$(SUBARCH_SUPPORTED)),,$(arch)))' |
$MAKE --no-print-directory -f -)
469 if [ -n "$missing_arches" ]; then
470 printf "skipping %s because we're missing compilers for (%s)\n" "$BUILD_NAME" "$missing_arches"
474 if [ $BUILDENV_CREATED -eq 0 ] && [ $configureonly -eq 0 ]; then
476 if [ "$scanbuild" = "true" ]; then
477 scanbuild_out
=$TARGET/${BUILD_NAME}-scanbuild
478 rm -rf "${scanbuild_out}"
479 BUILDPREFIX
="scan-build ${SCANBUILD_ARGS} -o ${scanbuild_out}tmp"
481 compile_target
"${BUILD_NAME}"
482 if [ "$scanbuild" = "true" ]; then
483 mv "${scanbuild_out}"tmp
/* "${scanbuild_out}"
484 rmdir "${scanbuild_out}tmp"
491 # One target may build several configs
492 function build_target
496 MAINBOARD_LC
=$
(echo "$MAINBOARD" |
tr '[:upper:]' '[:lower:]')
498 # look for config files in the config directory that match the boardname
499 if [ -n "$( find "$configdir" -maxdepth 1 -name "config.
${MAINBOARD_LC}*" -print -quit )" ]; then
500 for config
in "$configdir/config.${MAINBOARD_LC}"*; do
501 BUILD_NAME
="${config##*/}"
502 BUILD_NAME
="${BUILD_NAME##config.}"
503 BUILD_NAME
=$
(echo "${BUILD_NAME}" |
tr '[:lower:]' '[:upper:]')
504 echo "Building config $BUILD_NAME"
505 build_dir
=$TARGET/${BUILD_NAME}
506 build_config
"$MAINBOARD" "$build_dir" "$BUILD_NAME" "$config"
507 remove_target
"$BUILD_NAME"
511 echo "Building board $MAINBOARD (using default config)"
512 build_dir
=$TARGET/${MAINBOARD}
514 build_config
"$MAINBOARD" "$build_dir" "$MAINBOARD"
515 remove_target
"$MAINBOARD"
520 function remove_target
522 if [ "$remove" != "true" ]; then
528 # Save the generated coreboot.rom file of each board.
529 if [ -r "$TARGET/${BUILD_NAME}/coreboot.rom" ]; then
530 cp "$TARGET/${BUILD_NAME}/coreboot.rom" \
531 "${BUILD_NAME}_coreboot.rom"
534 echo "Removing build dir for $BUILD_NAME..."
535 rm -rf "${TARGET:?}/${BUILD_NAME}"
548 [-a|--all] Build previously succeeded ports as well
549 [-A|--any-toolchain] Use any toolchain
550 [-b|--board-variant <name>] Build specific board variant under the
552 [-B|--blobs] Allow using binary files
553 [--checksum <path/basefile>] Store checksums at path/basefile
554 [-c|--cpus <numcpus>] Build on <numcpus> at the same time
555 [-C|--config] Configure-only mode
556 [-d|--dir <dir>] Directory containing config files
557 [-e|--exitcode] Exit with a non-zero errorlevel on failure
558 [-J|--junit] Write JUnit formatted xml log file
559 [-K|--kconfig <name>] Prepend file to generated Kconfig
560 [-l|--loglevel <num>] Set loglevel
561 [-L|--clang] Use clang
562 [-o|--outdir <path>] Store build results in path
563 (defaults to $TARGET)
564 [-p|--payloads <dir>] Use payloads in <dir> to build images
565 [-P|--prefix <name>] File name prefix in CBFS
566 [-q|--quiet] Print fewer messages
567 [-r|--remove] Remove output dir after build
568 [-R|--root <path>] Absolute path to coreboot sources
570 [--scan-build] Use clang's static analyzer
571 [--timeless] Generate timeless builds
572 [-t|--target <vendor/board>] Attempt to build target vendor/board only
573 [-T|--test] Submit image(s) to automated test system
574 [-u|--update] Update existing image
575 [-v|--verbose] Print more messages
576 [-x|--chromeos] Build with CHROMEOS enabled
577 Skip boards without Chrome OS support
578 [-X|--xmlfile <name>] Set JUnit XML log file filename
579 (defaults to $XMLFILE)
580 [-y|--ccache] Use ccache
581 [-z|--clean] Remove build results when finished
583 [-V|--version] Print version number and exit
584 [-h|--help] Print this help and exit
586 [-s|--silent] obsolete
594 coreboot autobuild v$ABUILD_VERSION ($ABUILD_DATE)
596 Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
597 Copyright (C) 2006-2010 by coresystems GmbH <info@coresystems.de>
599 This program is free software; you may redistribute it under the terms
600 of the GNU General Public License. This program has absolutely no
611 test -f util
/sconfig
/sconfig.l
&& ROOT
=$
( pwd )
612 test -f ..
/util
/sconfig
/sconfig.l
&& ROOT
=$
( cd ..
&& pwd )
613 test "$ROOT" = "" && ROOT
=$
( cd ..
/..
&& pwd )
615 # Look if we have getopt. If not, build it.
616 export PATH
=$PATH:util
/abuild
617 getopt
- > /dev
/null
2>/dev
/null || gcc
-o util
/abuild
/getopt util
/abuild
/getopt.c
619 # Save command line for xargs parallelization.
622 # parse parameters.. try to find out whether we're running GNU getopt
623 getoptbrand
="$(getopt -V)"
625 # shellcheck disable=SC2086
626 if [ "${getoptbrand:0:6}" == "getopt" ]; then
627 # Detected GNU getopt that supports long options.
628 args
=$
(getopt
-l version
,verbose
,quiet
,help,all
,target
:,board-variant
:,payloads
:,cpus
:,silent
,junit
,config
,loglevel
:,remove
,prefix
:,update
,scan-build
,ccache
,blobs
,clang
,any-toolchain
,clean
,outdir
:,chromeos
,xmlfile
:,kconfig
:,dir
:,root
:,recursive
,checksum
:,timeless
,exitcode
-o Vvqhat
:b
:p
:c
:sJCl
:rP
:uyBLAzo
:xX
:K
:d
:R
:Ie
-- "$@") ||
exit 1
632 # Detected non-GNU getopt
633 args
=$
(getopt Vvqhat
:b
:p
:c
:sJCl
:rP
:uyBLAzo
:xX
:K
:d
:R
:Ie
"$@")
638 if [ $retval != 0 ]; then
648 # testclass needs to be undefined if not used for variable expansion to work
652 -J|
--junit) shift; mode
=junit
; rm -f "$XMLFILE" ;;
653 -t|
--target) shift; target
="$1"; shift;;
654 -b|
--board-variant) shift; variant
="$1"; shift;;
655 -a|
--all) shift; buildall
=true
;;
656 -d|
--dir) shift; configdir
="$1"; shift;;
657 -e|
--exitcode) shift; exitcode
=1;;
658 -r|
--remove) shift; remove
=true
;;
659 -v|
--verbose) shift; verbose
=true
; verboseopt
='V=1';;
660 -q|
--quiet) shift; quiet
=true
;;
661 -V|
--version) shift; myversion
; exit 0;;
662 -h|
--help) shift; myversion
; myhelp
; exit 0;;
663 -p|
--payloads) shift; payloads
="$1"; shift;;
664 -R|
--root) shift; ROOT
="$1"; MAKE
="$MAKE -C $1"; shift;;
666 export MAKEFLAGS
="-j $1"
668 test "$MAKEFLAGS" == "-j max" && export MAKEFLAGS
="-j" && cpuconfig
=" in parallel"
669 test "$1" == "1" && cpuconfig
=" on 1 cpu"
670 expr "$1" : '-\?[0-9]\+$' > /dev
/null
&& test "0$1" -gt 1 && cpuconfig
=" on $1 cpus in parallel"
676 customizing
="${customizing}, scan-build"
677 SCANBUILD_ARGS
=${SCANBUILD_ARGS:-'-k'}
680 customizing
="${customizing}, ccache"
681 configoptions
="${configoptions}CONFIG_CCACHE=y\n"
683 -C|
--config) shift; configureonly
=1;;
685 customizing
="${customizing}, loglevel $1"
686 configoptions
="${configoptions}CONFIG_DEFAULT_CONSOLE_LOGLEVEL_$1=y\n"
687 configoptions
="${configoptions}CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$1\n"
690 customizing
="${customizing}, update"
691 configoptions
="${configoptions}CONFIG_UPDATE_IMAGE=y\n"
694 customizing
="${customizing}, cbfs prefix $1"
695 configoptions
="${configoptions}CONFIG_CBFS_PREFIX=\"$1\""
698 customizing
="${customizing}, blobs"
699 configoptions
="${configoptions}CONFIG_USE_BLOBS=y\n"
701 -A|
--any-toolchain) shift
702 customizing
="${customizing}, any-toolchain"
703 configoptions
="${configoptions}CONFIG_ANY_TOOLCHAIN=y\n"
706 customizing
="${customizing}, clang"
707 configoptions
="${configoptions}CONFIG_COMPILER_LLVM_CLANG=y\n# CONFIG_COMPILER_GCC is not set\n"
710 customizing
="${customizing}, clean"
719 customizing
="${customizing}, chrome os"
720 configoptions
="${configoptions}CONFIG_CHROMEOS=y\n"
722 -X|
--xmlfile) shift; XMLFILE
=$1; REAL_XMLFILE
=$1; shift;;
723 -I|
--recursive) shift; recursive
=true
;;
725 testclass
="$(basename "$1" | tr '.' '_' )"
726 customizing
="${customizing}, $1 config"
727 configoptions
="$(cat "$1")${configoptions}\n"
729 --checksum) shift; checksum_file
="$1"; shift;;
730 --timeless) shift; TIMELESS
=1;;
732 -*) printf "Invalid option '%s'\n\n" "$1"; myhelp
; exit 1;;
737 printf "Invalid option '%s'\n\n" "$1"; myhelp
; exit 1;
740 if [ -z "$TARGET" ] ||
[ "$TARGET" = "/" ]; then
741 echo "Please specify a valid, non-root build directory."
745 customizing
=$
(echo "$customizing" | cut
-c3-)
746 if [ "$customizing" = "" ]; then
747 customizing
="default configuration"
750 FAILED_BOARDS
="${TARGET}/failed_boards"
751 PASSED_BOARDS
="${TARGET}/passing_boards"
753 if [ "$recursive" = "false" ]; then
754 rm -f "$FAILED_BOARDS" "$PASSED_BOARDS"
758 if [ "$cpus" != "1" ]; then
759 # Limit to 32 parallel builds for now.
760 # Thrashing all caches because we run
761 # 160 abuilds in parallel is no fun.
762 if [ "$cpus" = "max" ]; then
765 # Test if xargs supports the non-standard -P flag
766 # FIXME: disabled until we managed to eliminate all the make(1) quirks
767 echo |
xargs -P ${cpus:-0} -n 1 echo 2>/dev
/null
>/dev
/null
&& USE_XARGS
=1
770 if [ "$USE_XARGS" = "0" ]; then
771 test "$MAKEFLAGS" == "" && test "$cpus" != "" && export MAKEFLAGS
="-j $cpus"
774 local targets
=${*-$(get_mainboards)}
775 for MAINBOARD
in $targets; do
776 build_target
"${MAINBOARD}"
786 local cpus_per_target
788 local targets
=${*-$(get_mainboards)}
791 printf "%s" "$configoptions" > "$TMPCFG"
792 $MAKE -j "$cpus" DOTCONFIG
="$TMPCFG" obj
="$TARGET/temp" objutil
="$TARGET/sharedutils" allnoconfig
793 printf "%s" "$configoptions" >> "$TMPCFG"
794 yes "" 2>/dev
/null |
$MAKE -j "$cpus" DOTCONFIG
="$TMPCFG" obj
="$TARGET/temp" objutil
="$TARGET/sharedutils" oldconfig
2>/dev
/null |
head > /dev
/null
796 if [ "$scanbuild" = "true" ]; then
797 scanbuild_out
=$TARGET/sharedutils-scanbuild
798 rm -rf "${scanbuild_out}"
799 BUILDPREFIX
="scan-build -o ${scanbuild_out}tmp"
801 mkdir
-p "$TARGET/abuild"
802 ABSPATH
="$(cd "$TARGET/abuild
" && pwd)"
803 local XMLFILE
="$ABSPATH/__util.xml"
805 stime
=$
(perl
-e 'print time();' 2>/dev
/null ||
date +%s
)
806 $BUILDPREFIX "$MAKE" -j "$cpus" DOTCONFIG
="$TMPCFG" obj
="$TARGET/temp" objutil
="$TARGET/sharedutils" tools
> "$TARGET/sharedutils/make.log" 2>&1
808 etime
=$
(perl
-e 'print time();' 2>/dev
/null ||
date +%s
)
809 local duration
=$
(( etime
- stime
))
811 junit
" <testcase classname='util' name='all' time='$duration' >"
812 if [ $ret -eq 0 ]; then
814 junitfile
"$TARGET/sharedutils/make.log"
815 junit
"</system-out>"
818 junit
"<failure type='BuildFailed'>"
819 junitfile
"$TARGET/sharedutils/make.log"
822 echo "Shared Utilities - Log: $TARGET/sharedutils/make.log" >> "$FAILED_BOARDS"
826 if [ "$scanbuild" = "true" ]; then
827 mv "${scanbuild_out}tmp/"* "${scanbuild_out}"
828 rmdir "${scanbuild_out}tmp"
830 rm -rf "$TARGET/temp" "$TMPCFG"
831 num_targets
=$
(wc -w <<<"$targets")
832 cpus_per_target
=$
(((${cpus:-1} + num_targets
- 1) / num_targets
))
833 echo "$targets" |
xargs -P ${cpus:-0} -n 1 "$0" "${cmdline[@]}" -I -c "$cpus_per_target" -t
837 junit
'<?xml version="1.0" encoding="utf-8"?>'
840 if [ "$target" != "" ]; then
841 # build a single board
842 MAINBOARD
=$
(normalize_target
"${target}")
843 if [ -z "${MAINBOARD}" ]; then
844 printf "No such target: %s" "${target}"
845 if [ -n "${variant}" ]; then
846 printf ", variant: %s" "${variant}"
851 build_srcdir
="$(mainboard_directory "${MAINBOARD}")"
852 if [ "$(echo "${MAINBOARD}" | wc -w)" -gt 1 ]; then
853 build_targets
"${MAINBOARD}"
854 elif [ ! -r "$ROOT/src/mainboard/${build_srcdir}" ]; then
855 echo "No such target: ${MAINBOARD}"
858 build_target
"${MAINBOARD}"
859 test "$mode" != "text" && \
860 test -f "$TARGET/abuild/${MAINBOARD}.xml" && \
861 cat "$TARGET/abuild/${MAINBOARD}.xml" >> "$REAL_XMLFILE"
862 XMLFILE
=$REAL_XMLFILE
866 rm -f "$REAL_XMLFILE"
867 XMLFILE
="$REAL_XMLFILE"
868 junit
'<?xml version="1.0" encoding="utf-8"?>'
870 if [ "$mode" != "text" ]; then
871 for xmlfile
in $TARGET/abuild
/*_
*.xml
; do
872 cat "$xmlfile" >> "$REAL_XMLFILE"
875 XMLFILE
=$REAL_XMLFILE
879 if [ "$recursive" = "false" ]; then
881 # Print the list of failed configurations
882 if [ -f "$FAILED_BOARDS" ]; then
883 printf "%s configuration(s) failed:\n" "$( wc -l < "$FAILED_BOARDS" )"
886 if [ "$exitcode" != "0" ]; then
890 printf "All %s tested configurations passed.\n" "$( wc -l < "$PASSED_BOARDS" )"