2004-10-19 09:00:47 +02:00
#!/bin/bash
#
2008-01-18 16:08:58 +01:00
# coreboot autobuild
2004-10-19 09:00:47 +02:00
#
2008-01-18 16:08:58 +01:00
# This script builds coreboot images for all available targets.
2004-10-19 09:00:47 +02:00
#
# (C) 2004 by Stefan Reinauer <stepan@openbios.org>
2010-01-30 11:44:28 +01:00
# (C) 2006-2010 by coresystems GmbH <info@coresystems.de>
2014-12-08 09:57:52 +01:00
# (C) 2013-2014 Sage Electronic Engineering, LLC
2014-05-21 22:48:35 +02:00
# (C) 2014 Patrick Georgi <patrick@georgi-clan.de>
2004-10-19 09:00:47 +02:00
#
# This file is subject to the terms and conditions of the GNU General
# Public License. See the file COPYING in the main directory of this
# archive for more details.
2010-04-27 08:56:47 +02:00
#
2004-10-19 09:00:47 +02:00
2004-11-05 09:50:54 +01:00
#set -x # Turn echo on....
2004-10-21 23:41:57 +02:00
2014-05-21 22:48:35 +02:00
ABUILD_DATE="May 21, 2014"
ABUILD_VERSION="0.9.3"
2006-10-25 21:02:34 +02:00
2011-11-05 13:21:14 +01:00
TOP=$PWD
2004-10-21 23:41:57 +02:00
# Where shall we place all the build trees?
2013-12-19 20:43:29 +01:00
TARGET=${COREBOOT_BUILD_DIR:-coreboot-builds}
2011-11-05 13:21:14 +01:00
XMLFILE=$TOP/abuild.xml
REAL_XMLFILE=$XMLFILE
2004-10-19 09:00:47 +02:00
2013-12-19 20:13:23 +01:00
export KCONFIG_OVERWRITECONFIG=1
2004-10-21 23:41:57 +02:00
# path to payload. Should be more generic
2004-11-04 12:04:33 +01:00
PAYLOAD=/dev/null
2004-10-21 23:41:57 +02:00
2013-05-31 21:33:30 +02:00
# path to coreboot XGCC
XGCCPATH="`pwd`/util/crossgcc/xgcc/bin/"
# Add XGCC to the path.
if [ -d "$XGCCPATH" ] && [[ ":$PATH:" != *":$XGCCPATH:"* ]]; then
PATH="$XGCCPATH:$PATH"
fi
2004-10-21 23:41:57 +02:00
# Lines of error context to be printed in FAILURE case
2010-03-30 16:02:19 +02:00
CONTEXT=6
2004-10-21 23:41:57 +02:00
2008-01-18 16:08:58 +01:00
TESTSUBMISSION="http://qa.coreboot.org/deployment/send.php"
2006-10-25 21:02:34 +02:00
2009-03-11 16:00:50 +01:00
# Configure-only mode
configureonly=0
2011-06-01 21:29:48 +02:00
# Did any board fail to build?
failed=0
2013-12-05 19:53:04 +01:00
# default: single CPU build
cpus=1
2004-10-21 23:41:57 +02:00
# One might want to adjust these in case of cross compiling
2009-05-26 16:03:51 +02:00
for i in make gmake gnumake nonexistant_make; do
$i --version 2>/dev/null |grep "GNU Make" >/dev/null && break
done
if [ "$i" = "nonexistant_make" ]; then
echo No GNU Make found.
exit 1
fi
MAKE=$i
2004-10-19 09:00:47 +02:00
2013-12-05 19:36:31 +01:00
# this can be changed to junit by -J
2006-05-27 02:22:02 +02:00
mode=text
2008-05-27 20:29:26 +02:00
# silent mode.. no compiler calls, only warnings in the log files.
# this is disabled per default but can be enabled with -s
silent=
2014-12-08 09:57:52 +01:00
# quiet mode: only print pass, failure, and 'skipped' messages
quiet=false
2009-03-11 16:43:02 +01:00
# clang mode enabled by -sb option.
scanbuild=false
2004-10-19 09:00:47 +02:00
ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
2009-03-11 16:00:50 +01:00
-e s/i86pc/i386/ \
2004-10-19 09:00:47 +02:00
-e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
-e "s/Power Macintosh/ppc/"`
2006-10-25 21:02:34 +02:00
trap interrupt INT
function interrupt
{
printf "\n$0: execution interrupted manually.\n"
2013-12-05 19:36:31 +01:00
if [ "$mode" == "junit" ]; then
2006-10-25 21:02:34 +02:00
printf "$0: deleting incomplete xml output file.\n"
fi
exit 1
}
2004-11-05 12:57:00 +01:00
function debug
{
2006-10-25 21:02:34 +02:00
test "$verbose" == "true" && printf "$*\n"
2004-11-05 12:57:00 +01:00
}
2004-11-05 20:55:06 +01:00
2011-06-03 21:56:13 +02:00
function junit
{
test "$mode" == "junit" && printf "$*\n" >> $XMLFILE
return 0
}
function junitfile
{
test "$mode" == "junit" && {
printf '<![CDATA[\n'
cat $1
printf ']]>\n'
} >> $XMLFILE
}
2006-05-27 02:22:02 +02:00
2004-10-19 09:00:47 +02:00
function vendors
{
# make this a function so we can easily select
# without breaking readability
2014-05-17 21:50:06 +02:00
ls -1 $ROOT/src/mainboard/*/Kconfig 2>/dev/null | sed "s:^$ROOT/src/mainboard/\(.*\)/Kconfig$:\1:"
2004-10-19 09:00:47 +02:00
}
function mainboards
{
# make this a function so we can easily select
# without breaking readability
2010-04-27 08:56:47 +02:00
2004-10-19 09:00:47 +02:00
VENDOR=$1
2010-04-27 08:56:47 +02:00
2014-05-17 21:50:06 +02:00
ls -1 $ROOT/src/mainboard/$VENDOR/*/Kconfig 2>/dev/null | sed "s:^$ROOT/src/mainboard/$VENDOR/\(.*\)/Kconfig$:\1:"
2004-10-19 09:00:47 +02:00
}
2010-01-30 11:44:28 +01:00
function create_config
{
VENDOR=$1
MAINBOARD=$2
CONFIG=$3
build_dir=$TARGET/${VENDOR}_${MAINBOARD}
# get a working payload for the board if we have one.
2010-04-27 08:56:47 +02:00
# the --payload option expects a directory containing
2010-01-30 11:44:28 +01:00
# a shell script payload.sh
# Usage: payload.sh [VENDOR] [DEVICE]
# the script returns an absolute path to the payload binary.
if [ -f $payloads/payload.sh ]; then
PAYLOAD=`sh $payloads/payload.sh $VENDOR $MAINBOARD`
2012-09-24 20:52:42 +02:00
if [ $? -gt 0 ]; then
echo "problem with payload"
exit 1
fi
2014-12-10 23:49:23 +01:00
if [ "$quiet" == "false" ]; then printf "Using payload $PAYLOAD\n"; fi
2012-10-07 15:05:42 +02:00
elif [ "$payloads" = "none" ]; then
PAYLOAD=none
2010-01-30 11:44:28 +01:00
fi
mkdir -p ${build_dir}
2010-04-17 00:48:57 +02:00
mkdir -p $TARGET/sharedutils
2010-01-30 11:44:28 +01:00
if [ "$CONFIG" != "" ]; then
printf " Using existing configuration $CONFIG ... "
2011-02-01 11:42:52 +01:00
cp src/mainboard/$VENDOR/$MAINBOARD/$CONFIG ${build_dir}/config.build
2010-01-30 11:44:28 +01:00
else
2014-12-08 09:57:52 +01:00
if [ "$quiet" == "false" ]; then printf " Creating config file for $VENDOR/$MAINBOARD... \n"; fi
2010-09-02 20:36:29 +02:00
grep "if[\t ]*VENDOR" src/mainboard/$VENDOR/$MAINBOARD/../Kconfig | \
2010-12-08 20:58:30 +01:00
sed "s,^.*\(VENDOR_.*\)[^A-Z0-9_]*,CONFIG_\1=y," > ${build_dir}/config.build
2010-09-02 20:36:29 +02:00
grep "if[\t ]*BOARD" src/mainboard/$VENDOR/$MAINBOARD/Kconfig | \
2010-12-08 20:58:30 +01:00
sed "s,^.*\(BOARD_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> ${build_dir}/config.build
2010-01-30 11:44:28 +01:00
grep "select[\t ]*ARCH" src/mainboard/$VENDOR/$MAINBOARD/Kconfig | \
2010-12-08 20:58:30 +01:00
sed "s,^.*\(ARCH_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> ${build_dir}/config.build
echo "CONFIG_MAINBOARD_DIR=\"$VENDOR/$MAINBOARD\"" >> ${build_dir}/config.build
2012-10-07 15:05:42 +02:00
if [ "$PAYLOAD" = "none" ]; then
echo "CONFIG_PAYLOAD_NONE=y" >> ${build_dir}/config.build
elif [ "$PAYLOAD" != "/dev/null" ]; then
2010-12-08 20:58:30 +01:00
echo "# CONFIG_PAYLOAD_NONE is not set" >> ${build_dir}/config.build
2010-12-30 18:39:50 +01:00
echo "# CONFIG_PAYLOAD_SEABIOS is not set" >> ${build_dir}/config.build
2010-12-08 20:58:30 +01:00
echo "CONFIG_PAYLOAD_ELF=y" >> ${build_dir}/config.build
2010-12-19 22:20:14 +01:00
echo "CONFIG_PAYLOAD_FILE=\"$PAYLOAD\"" >> ${build_dir}/config.build
2010-01-30 11:44:28 +01:00
fi
2014-12-08 09:57:52 +01:00
if [ "$quiet" == "false" ]; then printf " $VENDOR/$MAINBOARD ($customizing)\n"; fi
2012-05-01 15:14:46 +02:00
printf "$configoptions" >> ${build_dir}/config.build
2010-01-30 11:44:28 +01:00
fi
2014-04-12 21:57:13 +02:00
yes "" 2>/dev/null | $MAKE oldconfig $silent DOTCONFIG=${build_dir}/config.build obj=${build_dir} objutil=$TARGET/sharedutils &> ${build_dir}/config.log
2010-01-30 11:44:28 +01:00
ret=$?
if [ $ret -eq 0 ]; then
2014-12-08 09:57:52 +01:00
if [ "$quiet" == "false" ]; then printf " $VENDOR/$MAINBOARD config created.\n"; fi
2010-01-30 11:44:28 +01:00
return 0
else
2010-03-30 16:02:19 +02:00
# Does this ever happen?
2014-12-08 09:57:52 +01:00
if [ "$quiet" == "false" ]; then printf "$VENDOR/$MAINBOARD config creation FAILED!\nLog excerpt:\n"; fi
2010-01-30 11:44:28 +01:00
tail -n $CONTEXT $build_dir/config.log 2> /dev/null || tail -$CONTEXT $build_dir/config.log
return 1
fi
}
2004-10-19 09:00:47 +02:00
function create_buildenv
{
VENDOR=$1
MAINBOARD=$2
2009-04-23 01:39:19 +02:00
CONFIG=$3
2010-03-30 17:49:14 +02:00
2010-02-07 22:43:48 +01:00
create_config $VENDOR $MAINBOARD $CONFIG
2010-03-30 17:49:14 +02:00
ret=$?
2010-03-25 15:18:57 +01:00
# Allow simple "make" in the target directory
MAKEFILE=$TARGET/${VENDOR}_${MAINBOARD}/Makefile
2010-12-11 23:07:07 +01:00
echo "# autogenerated" > $MAKEFILE
2010-03-25 15:18:57 +01:00
echo "TOP=$ROOT" >> $MAKEFILE
2010-12-11 23:07:07 +01:00
echo "BUILD=$TARGET" >> $MAKEFILE
echo "OBJ=\$(BUILD)/${VENDOR}_${MAINBOARD}" >> $MAKEFILE
echo "OBJUTIL=\$(BUILD)/sharedutils" >> $MAKEFILE
2010-03-30 16:02:19 +02:00
echo "all:" >> $MAKEFILE
2010-12-11 23:07:07 +01:00
echo " @cp -a config.h config.h.bak" >> $MAKEFILE
echo " @cd \$(TOP); \$(MAKE) oldconfig DOTCONFIG=\$(OBJ)/config.build objutil=\$(OBJUTIL) obj=\$(OBJ)" >> $MAKEFILE
echo " @tail -n+6 config.h > config.new; tail -n+6 config.h.bak > config.old" >> $MAKEFILE
echo " @cmp -s config.new config.old && cp -a config.h.bak config.h || echo \"Config file changed\"" >> $MAKEFILE
echo " @rm config.h.bak config.new config.old" >> $MAKEFILE
echo " @cd \$(TOP); \$(MAKE) DOTCONFIG=\$(OBJ)/config.build objutil=\$(OBJUTIL) obj=\$(OBJ)" >> $MAKEFILE
2010-03-30 17:49:14 +02:00
return $ret
2004-10-19 09:00:47 +02:00
}
function compile_target
2010-04-27 08:56:47 +02:00
{
2004-10-19 09:00:47 +02:00
VENDOR=$1
MAINBOARD=$2
2014-12-08 09:57:52 +01:00
if [ "$quiet" == "false" ]; then printf " Compiling $VENDOR/$MAINBOARD image$cpuconfig...\n"; fi
2008-05-27 20:29:26 +02:00
2004-10-19 09:00:47 +02:00
CURR=$( pwd )
2010-03-30 16:02:19 +02:00
#stime=`perl -e 'print time();' 2>/dev/null || date +%s`
2010-02-07 22:43:48 +01:00
build_dir=$TARGET/${VENDOR}_${MAINBOARD}
2014-05-17 18:26:38 +02:00
eval $BUILDPREFIX $MAKE $silent DOTCONFIG=${build_dir}/config.build obj=${build_dir} objutil=$TARGET/sharedutils \
2010-02-07 22:43:48 +01:00
&> ${build_dir}/make.log
ret=$?
2011-11-05 12:47:13 +01:00
cp .xcompile ${build_dir}/xcompile.build
2010-02-07 22:43:48 +01:00
cd $TARGET/${VENDOR}_${MAINBOARD}
2010-03-30 16:02:19 +02:00
2010-02-10 19:08:22 +01:00
etime=`perl -e 'print time();' 2>/dev/null || date +%s`
2005-12-04 21:35:56 +01:00
duration=$(( $etime - $stime ))
2015-07-31 16:30:04 +02:00
junit " <testcase classname='board${testclass/#/.}' name='$VENDOR/$MAINBOARD' time='$duration' >"
2010-03-30 16:02:19 +02:00
2005-12-04 21:42:37 +01:00
if [ $ret -eq 0 ]; then
2011-06-03 21:56:13 +02:00
junit "<system-out>"
junitfile make.log
junit "</system-out>"
2006-10-25 21:02:34 +02:00
printf "ok\n" > compile.status
2014-12-08 09:57:52 +01:00
printf "$VENDOR/$MAINBOARD built successfully. (took ${duration}s)\n"
2004-10-19 09:00:47 +02:00
else
2014-05-21 22:47:05 +02:00
ret=1
2011-06-03 21:56:13 +02:00
junit "<failure type='BuildFailed'>"
junitfile make.log
junit "</failure>"
2015-04-22 18:24:01 +02:00
printf "failed\n" > compile.status
2014-12-08 09:57:52 +01:00
printf "$VENDOR/$MAINBOARD build FAILED after ${duration}s!\nLog excerpt:\n"
2009-05-26 16:03:51 +02:00
tail -n $CONTEXT make.log 2> /dev/null || tail -$CONTEXT make.log
2011-06-01 21:29:48 +02:00
failed=1
2004-10-19 09:00:47 +02:00
fi
2014-05-21 22:47:05 +02:00
cd $CURR
if [ $clean_work = "true" ]; then
rm -rf $TARGET/${VENDOR}_${MAINBOARD}
fi
return $ret
2004-10-19 09:00:47 +02:00
}
function build_target
{
VENDOR=$1
MAINBOARD=$2
2009-04-23 01:39:19 +02:00
CONFIG=$3
2004-11-05 01:25:19 +01:00
2014-05-21 23:00:32 +02:00
if [ "`cat $TARGET/${VENDOR}_${MAINBOARD}/compile.status 2>/dev/null`" = "ok" -a \
2012-11-22 14:19:43 +01:00
"$buildall" = "false" ]; then
printf "Skipping $VENDOR/$MAINBOARD; (already successful)\n"
return
fi
2009-03-11 16:00:50 +01:00
HOSTCC='gcc'
2004-11-05 11:48:04 +01:00
2015-07-31 16:26:19 +02:00
if [ $chromeos = true -a `grep -c "^[[:space:]]*select[[:space:]]*MAINBOARD_HAS_CHROMEOS\>" src/mainboard/${VENDOR}/${MAINBOARD}/Kconfig` -eq 0 ]; then
echo "${VENDOR}/${MAINBOARD} doesn't support Chrome OS, skipping."
return
fi
2015-07-14 20:20:13 +02:00
if [ -f src/mainboard/${VENDOR}/${MAINBOARD}/abuild.disabled ]; then
echo "${VENDOR}/${MAINBOARD} disabled:"
cat src/mainboard/${VENDOR}/${MAINBOARD}/abuild.disabled
return
fi
2014-12-08 09:57:52 +01:00
if [ "$quiet" == "false" ]; then printf "Building $VENDOR/$MAINBOARD\n"; fi
2014-05-21 23:00:32 +02:00
mkdir -p $TARGET/${VENDOR}_${MAINBOARD} $TARGET/abuild
ABSPATH=`cd $TARGET/abuild; pwd`
XMLFILE=$ABSPATH/${VENDOR}_${MAINBOARD}.xml
2006-05-27 02:22:02 +02:00
2009-03-11 16:43:02 +01:00
2010-03-30 16:02:19 +02:00
stime=`perl -e 'print time();' 2>/dev/null || date +%s`
2009-04-23 01:39:19 +02:00
create_buildenv $VENDOR $MAINBOARD $CONFIG
2014-10-18 11:57:11 +02:00
2015-04-08 11:36:45 +02:00
required_arches=`egrep "^CONFIG_ARCH_(BOOTBLOCK|R.MSTAGE|VERSTAGE)" $TARGET/${VENDOR}_${MAINBOARD}/config.build | \
2014-10-31 16:48:00 +01:00
sed "s,^CONFIG_ARCH_[^_]*_\([^=]*\)=.*$,\1," |sort -u |tr 'A-Z\n\r' 'a-z '`
2014-12-29 15:06:16 +01:00
missing_arches=`printf 'include .xcompile\nall: ; @echo $(foreach arch,'"$required_arches"',$(if $(filter $(arch),$(SUBARCH_SUPPORTED)),,$(arch)))' | make --no-print-directory -f -`
2014-10-18 11:57:11 +02:00
if [ -n "$missing_arches" ]; then
printf "skipping $VENDOR/$MAINBOARD because we're missing compilers for ($missing_arches)\n"
return
fi
2009-03-11 16:00:50 +01:00
if [ $? -eq 0 -a $configureonly -eq 0 ]; then
2014-05-17 18:26:38 +02:00
BUILDPREFIX=
2010-04-19 22:39:22 +02:00
if [ "$scanbuild" = "true" ]; then
2014-05-17 18:26:38 +02:00
scanbuild_out=$TARGET/${VENDOR}_${MAINBOARD}-scanbuild
rm -rf ${scanbuild_out}
BUILDPREFIX="scan-build -o ${scanbuild_out}tmp"
2010-04-19 22:39:22 +02:00
fi
2013-12-05 19:36:31 +01:00
compile_target $VENDOR $MAINBOARD
2009-03-11 16:43:02 +01:00
if [ "$scanbuild" = "true" ]; then
2014-05-17 18:26:38 +02:00
mv ${scanbuild_out}tmp/* ${scanbuild_out}
rmdir ${scanbuild_out}tmp
2009-03-11 16:43:02 +01:00
fi
2004-10-19 09:00:47 +02:00
fi
2010-03-30 16:02:19 +02:00
# Not calculated here because we still print it in compile_target
#etime=`perl -e 'print time();' 2>/dev/null || date +%s`
#duration=$(( $etime - $stime ))
2004-11-05 15:06:24 +01:00
2011-06-03 21:56:13 +02:00
junit "</testcase>"
2006-10-25 21:02:34 +02:00
}
function test_target
{
VENDOR=$1
MAINBOARD=$2
if [ "$hwtest" != "true" ]; then
return 0
fi
# image does not exist. we silently skip the patch.
2008-01-18 16:08:58 +01:00
if [ ! -r "$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" ]; then
2006-10-25 21:02:34 +02:00
return 0
fi
which curl &> /dev/null
if [ $? != 0 ]; then
printf "curl is not installed but required for test submission. skipping test.\n\n"
return 0
fi
CURR=`pwd`
if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/tested" ]; then
printf "Testing image for board $VENDOR $MAINBOARD skipped (previously submitted).\n\n"
return 0
fi
# touch $TARGET/${VENDOR}_${MAINBOARD}/tested
printf "Submitting image for board $VENDOR $MAINBOARD to test system...\n"
2008-01-18 16:08:58 +01:00
curl -f -F "romfile=@$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" \
2006-10-25 21:02:34 +02:00
-F "mode=abuild" -F "mainboard=${VENDOR}_${MAINBOARD}" -F "submit=Upload" \
2008-01-18 16:08:58 +01:00
"http://qa.coreboot.org/deployment/send.php"
2006-10-25 21:02:34 +02:00
printf "\n"
return 0
2004-11-05 15:06:24 +01:00
}
2004-10-19 09:00:47 +02:00
2009-04-15 18:07:27 +02:00
function remove_target
{
if [ "$remove" != "true" ]; then
return 0
fi
VENDOR=$1
MAINBOARD=$2
# Save the generated coreboot.rom file of each board.
if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom" ]; then
cp $TARGET/${VENDOR}_${MAINBOARD}/coreboot.rom \
${VENDOR}_${MAINBOARD}_coreboot.rom
fi
printf "Removing build dir for board $VENDOR $MAINBOARD...\n"
rm -rf $TARGET/${VENDOR}_${MAINBOARD}
return 0
}
2004-11-05 01:25:19 +01:00
function myhelp
{
2015-07-31 16:14:43 +02:00
cat << __END_OF_HELP
Usage: $0 [-v] [-a] [-b] [-r] [-t <vendor/board>] [-p <dir>] [lbroot]
$0 [-V|--version]
$0 [-h|--help]
Options:\n"
[-v|--verbose] print more messages
[-q|--quiet] print fewer messages
[-a|--all] build previously succeeded ports as well
[-r|--remove] remove output dir after build
[-t|--target <vendor/board>] attempt to build target vendor/board only
[-p|--payloads <dir>] use payloads in <dir> to build images
[-V|--version] print version number and exit
[-h|--help] print this help and exit
[-J|--junit] write JUnit formatted xml log file
(defaults to $XMLFILE)
[-T|--test] submit image(s) to automated test system
[-c|--cpus <numcpus>] build on <numcpus> at the same time
[-s|--silent] omit compiler calls in logs
[-y|--ccache] use ccache
[-C|--config] configure-only mode
[-l|--loglevel <num>] set loglevel
[-u|--update] update existing image
[-P|--prefix <name>] file name prefix in CBFS
[-B|--blobs] Allow using binary files
[-z|--clean] Remove build results when finished
[-o|--outdir <path>] store build results in path
(defaults to $TARGET)
[-L|--clang] Use clang
[-x|--chromeos] Build with CHROMEOS enabled
2015-07-31 16:26:19 +02:00
Skip boards without Chrome OS support
2015-07-31 16:14:43 +02:00
[--scan-build] use clang's static analyzer
[cbroot] absolute path to coreboot sources
(defaults to $ROOT)
__END_OF_HELP
2004-11-05 01:25:19 +01:00
}
2010-04-27 08:56:47 +02:00
function myversion
2004-11-05 01:25:19 +01:00
{
cat << EOF
2008-01-18 16:08:58 +01:00
coreboot autobuild v$ABUILD_VERSION ($ABUILD_DATE)
2004-11-05 01:25:19 +01:00
2006-05-27 02:22:02 +02:00
Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
2010-01-30 11:44:28 +01:00
Copyright (C) 2006-2010 by coresystems GmbH <info@coresystems.de>
2006-10-25 21:02:34 +02:00
2004-11-05 01:25:19 +01:00
This program is free software; you may redistribute it under the terms
of the GNU General Public License. This program has absolutely no
warranty.
EOF
}
# default options
target=""
buildall=false
2004-11-05 12:57:00 +01:00
verbose=false
2004-11-05 01:25:19 +01:00
2010-04-08 13:37:43 +02:00
test -f util/sconfig/sconfig.l && ROOT=$( pwd )
test -f ../util/sconfig/sconfig.l && ROOT=$( cd ..; pwd )
2010-01-30 11:44:28 +01:00
test "$ROOT" = "" && ROOT=$( cd ../..; pwd )
2009-07-01 14:26:11 +02:00
2012-04-05 11:17:01 +02:00
# Look if we have getopt. If not, build it.
export PATH=$PATH:util/abuild
getopt - > /dev/null 2>/dev/null || gcc -o util/abuild/getopt util/abuild/getopt.c
2011-11-05 14:44:41 +01:00
# command line for xargs parallelization. Thus overwrite -c X
cmdline="$* -c 1"
2008-05-27 20:29:26 +02:00
# parse parameters.. try to find out whether we're running GNU getopt
2008-05-28 10:40:23 +02:00
getoptbrand="`getopt -V`"
if [ "${getoptbrand:0:6}" == "getopt" ]; then
# Detected GNU getopt that supports long options.
2015-04-22 18:38:10 +02:00
args=`getopt -l version,verbose,quiet,help,all,target:,payloads:,test,cpus:,silent,junit,config,loglevel:,remove,prefix:,update,scan-build,ccache,blobs,clang,clean,outdir:,chromeos -o Vvqhat:p:Tc:sJCl:rP:uyBLzo:x -- "$@"` || exit 1
2010-09-27 23:14:19 +02:00
eval set -- $args
2008-05-27 20:29:26 +02:00
else
# Detected non-GNU getopt
2015-04-22 18:38:10 +02:00
args=`getopt Vvqhat:p:Tc:sJCl:rP:uyBLzo:x $*`
2008-05-27 20:29:26 +02:00
set -- $args
fi
2004-11-05 01:25:19 +01:00
if [ $? != 0 ]; then
myhelp
exit 1
fi
2015-07-31 16:26:19 +02:00
chromeos=false
2014-05-21 22:47:05 +02:00
clean_work=false
2012-05-01 15:14:46 +02:00
customizing=""
configoptions=""
2015-09-15 16:57:04 +02:00
# testclass needs to be undefined if not used for variable expansion to work
unset testclass
2004-11-05 09:50:54 +01:00
while true ; do
2004-11-05 12:24:57 +01:00
case "$1" in
2011-06-03 21:56:13 +02:00
-J|--junit) shift; mode=junit; rm -f $XMLFILE ;;
2004-11-05 15:06:24 +01:00
-t|--target) shift; target="$1"; shift;;
2004-11-05 09:50:54 +01:00
-a|--all) shift; buildall=true;;
2010-09-27 23:14:19 +02:00
-r|--remove) shift; remove=true;;
2010-03-25 20:01:27 +01:00
-v|--verbose) shift; verbose=true; silent='V=1';;
2014-12-08 09:57:52 +01:00
-q|--quiet) shift; quiet=true;;
2004-11-05 12:47:41 +01:00
-V|--version) shift; myversion; exit 0;;
2006-10-25 21:02:34 +02:00
-h|--help) shift; myversion; myhelp; exit 0;;
2006-09-15 19:00:11 +02:00
-p|--payloads) shift; payloads="$1"; shift;;
2006-10-25 21:02:34 +02:00
-T|--test) shift; hwtest=true;;
2012-05-01 15:14:46 +02:00
-c|--cpus) shift
export MAKEFLAGS="-j $1"
2013-12-05 19:53:04 +01:00
cpus=$1
2014-12-08 09:57:52 +01:00
test "$MAKEFLAGS" == "-j max" && export MAKEFLAGS="-j" && cpuconfig=" in parallel"
test "$1" == "1" && cpuconfig=" on 1 cpu"
expr "$1" : '-\?[0-9]\+$' > /dev/null && test 0$1 -gt 1 && cpuconfig=" on $1 cpus in parallel"
2012-05-01 15:14:46 +02:00
shift;;
2008-05-27 20:29:26 +02:00
-s|--silent) shift; silent="-s";;
2014-05-17 18:26:38 +02:00
--scan-build) shift
2012-05-01 15:14:46 +02:00
scanbuild=true
customizing="${customizing}, scan-build"
;;
-y|--ccache) shift
customizing="${customizing}, ccache"
configoptions="${configoptions}CONFIG_CCACHE=y\n"
;;
2009-03-11 16:00:50 +01:00
-C|--config) shift; configureonly=1;;
2012-05-01 15:14:46 +02:00
-l|--loglevel) shift
customizing="${customizing}, loglevel $1"
configoptions="${configoptions}CONFIG_DEFAULT_CONSOLE_LOGLEVEL_$1=y\n"
configoptions="${configoptions}CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$1\n"
shift;;
-u|--update) shift
customizing="${customizing}, update"
configoptions="${configoptions}CONFIG_UPDATE_IMAGE=y\n"
;;
-P|--prefix) shift
customizing="${customizing}, cbfs prefix $1"
configoptions="${configoptions}CONFIG_CBFS_PREFIX=\"$1\""
shift;;
-B|--blobs) shift
customizing="${customizing}, blobs"
configoptions="${configoptions}CONFIG_USE_BLOBS=y\n"
;;
2014-05-14 13:43:58 +02:00
-L|--clang) shift
customizing="${customizing}, clang"
2014-11-28 23:08:51 +01:00
configoptions="${configoptions}CONFIG_COMPILER_LLVM_CLANG=y\n# CONFIG_COMPILER_GCC is not set\n"
2014-05-14 13:43:58 +02:00
;;
2014-05-21 22:47:05 +02:00
-z|--clean) shift
customizing="${customizing}, clean"
clean_work=true
;;
2014-05-21 23:00:32 +02:00
-o|--outdir) shift
TARGET=$1; shift
;;
2015-04-22 18:38:10 +02:00
-x|--chromeos) shift
2015-07-31 16:26:19 +02:00
chromeos=true
2015-07-31 16:30:04 +02:00
testclass=chromeos
2015-07-31 16:26:19 +02:00
customizing="${customizing}, chrome os"
2015-04-22 18:38:10 +02:00
configoptions="${configoptions}CONFIG_CHROMEOS=y\n"
;;
2004-11-05 09:50:54 +01:00
--) shift; break;;
2006-10-25 21:02:34 +02:00
-*) printf "Invalid option\n\n"; myhelp; exit 1;;
2004-11-05 12:24:57 +01:00
*) break;;
2004-11-05 09:50:54 +01:00
esac
2004-11-05 01:25:19 +01:00
done
2014-05-21 23:00:32 +02:00
if [ -z "$TARGET" -o "$TARGET" = "/" ]; then
echo "Please specify a valid, non-root build directory."
exit 1
fi
2012-05-01 15:14:46 +02:00
customizing=`echo $customizing |cut -c3-`
if [ "$customizing" = "" ]; then
customizing="default configuration"
fi
2011-11-05 14:44:41 +01:00
USE_XARGS=0
2011-11-05 12:55:18 +01:00
if [ "$cpus" != "1" ]; then
2013-12-05 19:53:04 +01:00
# Limit to 32 parallel builds for now.
# Thrashing all caches because we run
# 160 abuilds in parallel is no fun.
if [ "$cpus" = "max" ]; then
cpus=32
fi
2011-11-05 14:44:41 +01:00
if [ "$target" = "" ]; then
# Test if xargs supports the non-standard -P flag
2012-05-21 20:10:04 +02:00
# FIXME: disabled until we managed to eliminate all the make(1) quirks
2013-12-05 19:53:04 +01:00
echo | xargs -P ${cpus:-0} -n 1 echo 2>/dev/null >/dev/null && USE_XARGS=1
2011-11-05 14:44:41 +01:00
fi
fi
if [ "$USE_XARGS" = "0" ]; then
2012-05-31 00:03:48 +02:00
test "$MAKEFLAGS" == "" && test "$cpus" != "" && export MAKEFLAGS="-j $cpus"
2011-11-05 14:44:41 +01:00
build_all_targets()
{
for VENDOR in $( vendors ); do
for MAINBOARD in $( mainboards $VENDOR ); do
build_target $VENDOR $MAINBOARD
test_target $VENDOR $MAINBOARD
remove_target $VENDOR $MAINBOARD
done
done
}
else
build_all_targets()
{
# seed shared utils
TMPCFG=`mktemp`
2014-11-28 23:08:51 +01:00
printf "$configoptions" > $TMPCFG
2014-05-17 18:24:45 +02:00
$MAKE -j $cpus DOTCONFIG=$TMPCFG obj=$TARGET/temp objutil=$TARGET/sharedutils allnoconfig
2014-11-28 23:08:51 +01:00
printf "$configoptions" >> $TMPCFG
2015-07-31 16:46:55 +02:00
yes "" 2>/dev/null | $MAKE -j $cpus DOTCONFIG=$TMPCFG obj=$TARGET/temp objutil=$TARGET/sharedutils oldconfig 2>/dev/null |head > /dev/null
2014-05-17 18:26:38 +02:00
BUILDPREFIX=
if [ "$scanbuild" = "true" ]; then
scanbuild_out=$TARGET/sharedutils-scanbuild
rm -rf ${scanbuild_out}
BUILDPREFIX="scan-build -o ${scanbuild_out}tmp"
fi
2015-09-15 17:30:52 +02:00
mkdir -p $TARGET/abuild
local ABSPATH=`cd $TARGET/abuild; pwd`
local XMLFILE=$ABSPATH/__util.xml
local stime=`perl -e 'print time();' 2>/dev/null || date +%s`
$BUILDPREFIX $MAKE -j $cpus DOTCONFIG=$TMPCFG obj=$TARGET/temp objutil=$TARGET/sharedutils tools > $TARGET/sharedutils/make.log 2>&1
local ret=$?
local etime=`perl -e 'print time();' 2>/dev/null || date +%s`
local duration=$(( $etime - $stime ))
junit " <testcase classname='util' name='all' time='$duration' >"
if [ $ret -eq 0 ]; then
junit "<system-out>"
junitfile $TARGET/sharedutils/make.log
junit "</system-out>"
junit "</testcase>"
else
junit "<failure type='BuildFailed'>"
junitfile $TARGET/sharedutils/make.log
junit "</failure>"
junit "</testcase>"
return
fi
if [ $ret -eq 1 ]; then
return
fi
2014-05-17 18:26:38 +02:00
if [ "$scanbuild" = "true" ]; then
mv ${scanbuild_out}tmp/* ${scanbuild_out}
rmdir ${scanbuild_out}tmp
fi
2014-05-17 18:24:45 +02:00
rm -rf $TARGET/temp $TMPCFG
2011-11-05 14:44:41 +01:00
for VENDOR in $( vendors ); do
for MAINBOARD in $( mainboards $VENDOR ); do
echo $VENDOR/$MAINBOARD
done
2013-12-05 19:53:04 +01:00
done | xargs -P ${cpus:-0} -n 1 $0 $cmdline -t
2011-11-05 14:44:41 +01:00
}
2011-11-05 12:55:18 +01:00
fi
2010-01-30 11:44:28 +01:00
test -z "$1" || ROOT=$1
2004-11-05 01:25:19 +01:00
2010-01-30 11:44:28 +01:00
debug "ROOT=$ROOT"
2004-11-05 01:25:19 +01:00
2011-06-03 21:56:13 +02:00
junit '<?xml version="1.0" encoding="utf-8"?>'
junit '<testsuite>'
2004-11-05 01:26:31 +01:00
if [ "$target" != "" ]; then
2004-11-05 11:48:04 +01:00
# build a single board
2006-10-25 21:02:34 +02:00
VENDOR=`printf $target|cut -f1 -d/`
MAINBOARD=`printf $target|cut -f2 -d/`
2009-04-23 01:39:19 +02:00
CONFIG=`printf $target|cut -f3 -d/`
2010-03-29 18:23:42 +02:00
if [ ! -r $ROOT/src/mainboard/$target ]; then
printf "No such target: $target\n"
2011-11-05 14:44:41 +01:00
failed=1
else
build_target $VENDOR $MAINBOARD $CONFIG
test_target $VENDOR $MAINBOARD
2013-12-19 20:13:23 +01:00
remove_target $VENDOR $MAINBOARD
test "$mode" != "text" && cat $TARGET/abuild/${VENDOR}_${MAINBOARD}.xml >> $REAL_XMLFILE
2011-11-05 14:44:41 +01:00
XMLFILE=$REAL_XMLFILE
2010-03-29 18:23:42 +02:00
fi
2004-11-05 01:25:19 +01:00
else
2011-11-05 14:44:41 +01:00
build_all_targets
rm -f $REAL_XMLFILE
2012-05-21 20:10:04 +02:00
XMLFILE=$REAL_XMLFILE
2011-11-05 14:44:41 +01:00
junit '<?xml version="1.0" encoding="utf-8"?>'
junit '<testsuite>'
2011-11-07 19:01:54 +01:00
if [ "$mode" != "text" ]; then
2013-12-19 20:13:23 +01:00
for xmlfile in $TARGET/abuild/*_*.xml; do
2011-11-07 19:01:54 +01:00
cat $xmlfile >> $REAL_XMLFILE
done
fi
2011-11-05 13:21:14 +01:00
XMLFILE=$REAL_XMLFILE
2004-11-05 01:25:19 +01:00
fi
2011-06-03 21:56:13 +02:00
junit '</testsuite>'
2004-10-19 09:00:47 +02:00
2011-06-01 21:29:48 +02:00
exit $failed