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
|
|
|
|
2016-12-06 17:18:36 +01:00
|
|
|
ABUILD_DATE="Dec 6, 2016"
|
|
|
|
ABUILD_VERSION="0.10.01"
|
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
|
2016-12-01 00:32:20 +01:00
|
|
|
XGCCPATH="${TOP}/util/crossgcc/xgcc/bin/"
|
2013-05-31 21:33:30 +02:00
|
|
|
|
|
|
|
# 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
|
2015-12-15 01:36:45 +01:00
|
|
|
CONTEXT=12
|
2004-10-21 23:41:57 +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
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
# change with -d <directory>
|
|
|
|
configdir="$TOP/configs"
|
|
|
|
|
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
|
|
|
|
|
2006-10-25 21:02:34 +02:00
|
|
|
trap interrupt INT
|
|
|
|
|
|
|
|
function interrupt
|
|
|
|
{
|
2016-12-01 00:32:20 +01:00
|
|
|
printf "\n%s: execution interrupted manually.\n" "$0"
|
2013-12-05 19:36:31 +01:00
|
|
|
if [ "$mode" == "junit" ]; then
|
2016-12-01 00:32:20 +01:00
|
|
|
printf "%s: deleting incomplete xml output file.\n" "$0"
|
2006-10-25 21:02:34 +02:00
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2004-11-05 12:57:00 +01:00
|
|
|
function debug
|
|
|
|
{
|
2016-12-01 00:32:20 +01:00
|
|
|
test "$verbose" == "true" && echo "$*"
|
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
|
|
|
|
{
|
2016-12-01 00:32:20 +01:00
|
|
|
test "$mode" == "junit" && echo "$*" >> "$XMLFILE"
|
2011-06-03 21:56:13 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
function junitfile
|
|
|
|
{
|
|
|
|
test "$mode" == "junit" && {
|
|
|
|
printf '<![CDATA[\n'
|
2016-12-01 00:32:20 +01:00
|
|
|
cat "$1"
|
2011-06-03 21:56:13 +02:00
|
|
|
printf ']]>\n'
|
2016-12-01 00:32:20 +01:00
|
|
|
} >> "$XMLFILE"
|
2011-06-03 21:56:13 +02:00
|
|
|
}
|
2006-05-27 02:22:02 +02:00
|
|
|
|
2015-10-31 00:35:44 +01:00
|
|
|
# Return mainboard descriptors.
|
|
|
|
# By default all mainboards are listed, but when passing a two-level path
|
|
|
|
# below src/mainboard, such as emulation/qemu-i440fx, or emulation/*, it
|
|
|
|
# returns all board descriptors in that hierarchy.
|
|
|
|
function get_mainboards
|
|
|
|
{
|
|
|
|
local search_space=${1-*/*}
|
2016-12-01 00:32:20 +01:00
|
|
|
# shellcheck disable=SC2086
|
2015-10-31 00:35:44 +01:00
|
|
|
grep -h "^[[:space:]]*config\>[[:space:]]*\<BOARD_" \
|
2015-10-31 09:13:26 +01:00
|
|
|
${ROOT}/src/mainboard/${search_space}/Kconfig.name 2>/dev/null | \
|
2015-10-31 00:35:44 +01:00
|
|
|
sed "s,^.*\<BOARD_\([A-Z0-9_]*\)\>.*$,\1,"
|
|
|
|
}
|
2006-05-27 02:22:02 +02:00
|
|
|
|
2015-10-31 00:35:44 +01:00
|
|
|
# Given a mainboard descriptor, return its directory below src/mainboard
|
|
|
|
function mainboard_directory
|
2004-10-19 09:00:47 +02:00
|
|
|
{
|
2015-10-31 00:35:44 +01:00
|
|
|
local MAINBOARD=$1
|
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
# shellcheck disable=SC2086
|
2015-10-31 00:35:44 +01:00
|
|
|
grep -l "^[[:space:]]*config\>[[:space:]]*\<BOARD_${MAINBOARD}\>" \
|
|
|
|
${ROOT}/src/mainboard/*/*/Kconfig.name | \
|
|
|
|
sed "s:^$ROOT/src/mainboard/\(.*\)/Kconfig.name$:\1:"
|
2004-10-19 09:00:47 +02:00
|
|
|
}
|
|
|
|
|
2015-10-31 00:35:44 +01:00
|
|
|
# Given a mainboard descriptor, return its vendor (CONFIG_VENDOR_*)
|
|
|
|
function mainboard_vendor
|
2004-10-19 09:00:47 +02:00
|
|
|
{
|
2015-10-31 00:35:44 +01:00
|
|
|
local MAINBOARD=$1
|
2016-12-01 00:32:20 +01:00
|
|
|
local kconfig_file
|
2010-04-27 08:56:47 +02:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
kconfig_file=$( \
|
2015-10-31 00:35:44 +01:00
|
|
|
grep -l "^[[:space:]]*config\>[[:space:]]*\<BOARD_${MAINBOARD}\>" \
|
|
|
|
${ROOT}/src/mainboard/*/*/Kconfig.name | \
|
|
|
|
sed "s:^\(${ROOT}/src/mainboard/.*\)/.*/\(Kconfig.name\)$:\1/\2:" )
|
|
|
|
if [ ! -f "$kconfig_file" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-12-01 00:32:20 +01:00
|
|
|
grep "^[[:space:]]*config\>[[:space:]]*\<VENDOR_" "$kconfig_file" | \
|
2015-10-31 00:35:44 +01:00
|
|
|
sed "s,^.*\<VENDOR_\([A-Z0-9_]*\)\>.*$,\1,"
|
|
|
|
}
|
2010-04-27 08:56:47 +02:00
|
|
|
|
2015-10-31 00:35:44 +01:00
|
|
|
# Accepts directory names (eg. emulation/qemu-i440fx) and mainboard
|
|
|
|
# descriptors (eg. EMULATION_QEMU_X86_I440F} and returns the latter
|
|
|
|
# format.
|
|
|
|
# If a directory contains multiple boards, returns them all.
|
|
|
|
function normalize_target
|
|
|
|
{
|
2016-12-01 00:32:20 +01:00
|
|
|
local targets
|
|
|
|
|
|
|
|
targets=$(get_mainboards "$1")
|
2015-10-31 09:13:26 +01:00
|
|
|
if [ -n "$targets" ]; then
|
2016-12-01 00:32:20 +01:00
|
|
|
echo "$targets"
|
2015-10-31 09:13:26 +01:00
|
|
|
return
|
2015-10-31 00:35:44 +01:00
|
|
|
fi
|
2015-10-31 09:13:26 +01:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
targets=$(echo "$1" | tr ',' ' ')
|
2015-10-31 09:13:26 +01:00
|
|
|
for i in $targets; do
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ -n "$(mainboard_directory "$i")" ]; then
|
|
|
|
echo "$i"
|
2015-10-31 09:13:26 +01:00
|
|
|
else
|
|
|
|
echo "$i is not a valid target" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
2004-10-19 09:00:47 +02:00
|
|
|
}
|
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
# shellcheck disable=SC2129
|
2010-01-30 11:44:28 +01:00
|
|
|
function create_config
|
|
|
|
{
|
2016-11-24 02:47:53 +01:00
|
|
|
local BUILD_NAME=$1
|
|
|
|
local build_dir=$2
|
2016-12-01 00:32:20 +01:00
|
|
|
local board_srcdir
|
2010-01-30 11:44:28 +01:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
local config_file="${build_dir}/config.build"
|
|
|
|
board_srcdir="$(mainboard_directory "${BUILD_NAME}")"
|
2016-11-24 02:47:53 +01:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
mkdir -p "${build_dir}"
|
|
|
|
mkdir -p "$TARGET/sharedutils"
|
2016-11-24 02:47:53 +01:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ "$quiet" == "false" ]; then echo " Creating config file for $BUILD_NAME..."; fi
|
|
|
|
echo "CONFIG_VENDOR_$(mainboard_vendor "${BUILD_NAME}")=y" > "${config_file}"
|
|
|
|
echo "CONFIG_BOARD_${BUILD_NAME}=y" >> "${config_file}"
|
|
|
|
grep "select[\t ]*ARCH" "${ROOT}/src/mainboard/${board_srcdir}/Kconfig" | \
|
|
|
|
sed "s,^.*\(ARCH_.*\)[^A-Z0-9_]*,CONFIG_\1=y," >> "${config_file}"
|
|
|
|
echo "CONFIG_MAINBOARD_DIR=\"${board_srcdir}\"" >> "${config_file}"
|
2016-11-24 02:47:53 +01:00
|
|
|
|
|
|
|
update_config "$BUILD_NAME" "$build_dir" "$config_file"
|
|
|
|
|
|
|
|
ret=$?
|
|
|
|
if [ $ret -eq 0 ]; then
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ "$quiet" == "false" ]; then echo " $BUILD_NAME config created."; fi
|
2016-11-24 02:47:53 +01:00
|
|
|
return 0
|
|
|
|
else
|
|
|
|
# Does this ever happen?
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ "$quiet" == "false" ]; then printf "%s config creation FAILED!\nLog excerpt:\n" "$BUILD_NAME"; fi
|
|
|
|
tail -n $CONTEXT "$build_dir/config.log" 2> /dev/null || tail -$CONTEXT "$build_dir/config.log"
|
2016-11-24 02:47:53 +01:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_config
|
|
|
|
{
|
|
|
|
local BUILD_NAME=$1
|
|
|
|
local build_dir=$2
|
|
|
|
local config_file=$3
|
2010-01-30 11:44:28 +01:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
local PAYLOAD
|
2016-11-24 02:47:53 +01:00
|
|
|
local defconfig_file
|
|
|
|
defconfig_file=${build_dir}/config.$(echo "${BUILD_NAME}" | tr '[:upper:]' '[:lower:]').default
|
|
|
|
|
|
|
|
# get a working payload for the board if we have one.
|
|
|
|
# the --payload option expects a directory containing
|
2010-01-30 11:44:28 +01:00
|
|
|
# a shell script payload.sh
|
2015-10-31 00:35:44 +01:00
|
|
|
# Usage: payload.sh [BOARD]
|
2010-01-30 11:44:28 +01:00
|
|
|
# the script returns an absolute path to the payload binary.
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
if [ -f "$payloads/payload.sh" ]; then
|
2016-12-01 00:32:20 +01:00
|
|
|
PAYLOAD=$(sh "$payloads/payload.sh" "$BUILD_NAME")
|
|
|
|
local PAYLOAD_OK=$?
|
|
|
|
if [ $PAYLOAD_OK -gt 0 ]; then
|
2012-09-24 20:52:42 +02:00
|
|
|
echo "problem with payload"
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-11-24 02:47:53 +01:00
|
|
|
if [ "$quiet" == "false" ]; then printf "Using payload %s\n" "$PAYLOAD"; fi
|
2012-10-07 15:05:42 +02:00
|
|
|
elif [ "$payloads" = "none" ]; then
|
2016-12-01 00:32:20 +01:00
|
|
|
PAYLOAD=none
|
2010-01-30 11:44:28 +01:00
|
|
|
fi
|
|
|
|
|
2015-10-30 22:59:30 +01:00
|
|
|
if [ "$PAYLOAD" = "none" ]; then
|
2016-11-24 02:47:53 +01:00
|
|
|
{
|
|
|
|
echo "CONFIG_PAYLOAD_NONE=y"
|
|
|
|
echo "# CONFIG_PAYLOAD_SEABIOS is not set"
|
|
|
|
echo "# CONFIG_PAYLOAD_ELF is not set"
|
|
|
|
echo "# CONFIG_PAYLOAD_BAYOU is not set"
|
|
|
|
echo "# CONFIG_PAYLOAD_FILO is not set"
|
|
|
|
echo "# CONFIG_PAYLOAD_GRUB2 is not set"
|
|
|
|
echo "# CONFIG_PAYLOAD_OPENBIOS is not set"
|
|
|
|
echo "# CONFIG_PAYLOAD_DEPTHCHARGE is not set"
|
|
|
|
echo "# CONFIG_PAYLOAD_UBOOT is not set"
|
|
|
|
echo "# CONFIG_PAYLOAD_TIANOCORE is not set"
|
|
|
|
} >> "${config_file}"
|
2015-10-30 22:59:30 +01:00
|
|
|
elif [ "$PAYLOAD" != "/dev/null" ]; then
|
2016-11-24 02:47:53 +01:00
|
|
|
{
|
|
|
|
echo "# CONFIG_PAYLOAD_NONE is not set"
|
|
|
|
echo "# CONFIG_PAYLOAD_SEABIOS is not set"
|
|
|
|
echo "CONFIG_PAYLOAD_ELF=y"
|
|
|
|
echo "CONFIG_PAYLOAD_FILE=\"$PAYLOAD\""
|
|
|
|
} >> "${config_file}"
|
2010-01-30 11:44:28 +01:00
|
|
|
fi
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
if [ "$quiet" == "false" ]; then echo " $MAINBOARD ($customizing)"; fi
|
2016-12-13 23:29:30 +01:00
|
|
|
# shellcheck disable=SC2059
|
|
|
|
printf "$configoptions" >> "${config_file}"
|
2015-10-30 22:59:30 +01:00
|
|
|
|
2016-12-13 23:29:30 +01:00
|
|
|
yes "" 2>/dev/null | $MAKE oldconfig $silent "DOTCONFIG=${config_file}" "obj=${build_dir}" "objutil=$TARGET/sharedutils" &> "${build_dir}/config.log" ; \
|
2016-12-01 00:32:20 +01:00
|
|
|
CONFIG_OK=$?
|
|
|
|
if [ $CONFIG_OK -eq 0 ]; then
|
2016-12-13 23:29:30 +01:00
|
|
|
$MAKE savedefconfig $silent DEFCONFIG="${defconfig_file}" DOTCONFIG="${config_file}" obj="${build_dir}" objutil="$TARGET/sharedutils" &>> "${build_dir}/config.log"
|
2016-11-24 02:47:53 +01:00
|
|
|
return $?
|
2010-01-30 11:44:28 +01:00
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
# shellcheck disable=SC2129
|
2004-10-19 09:00:47 +02:00
|
|
|
function create_buildenv
|
|
|
|
{
|
2016-11-24 02:47:53 +01:00
|
|
|
local BUILD_NAME=$1
|
|
|
|
local build_dir=$2
|
|
|
|
local config_file=$3
|
2010-03-30 17:49:14 +02:00
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
if [ -z "$config_file" ]; then
|
|
|
|
create_config "$BUILD_NAME" "$build_dir"
|
|
|
|
else
|
|
|
|
local new_config_file="${build_dir}/config.build"
|
|
|
|
cp "$config_file" "$new_config_file"
|
|
|
|
update_config "$BUILD_NAME" "$build_dir" "$new_config_file"
|
|
|
|
fi
|
2016-12-01 00:32:20 +01:00
|
|
|
local ret=$?
|
2010-03-25 15:18:57 +01:00
|
|
|
|
|
|
|
# Allow simple "make" in the target directory
|
2016-11-24 02:47:53 +01:00
|
|
|
local MAKEFILE=$TARGET/${BUILD_NAME}/Makefile
|
2016-12-01 00:32:20 +01:00
|
|
|
echo "# autogenerated" > "$MAKEFILE"
|
|
|
|
echo "TOP=$ROOT" >> "$MAKEFILE"
|
|
|
|
echo "BUILD=$TARGET" >> "$MAKEFILE"
|
|
|
|
echo "OBJ=\$(BUILD)/${MAINBOARD}" >> "$MAKEFILE"
|
|
|
|
echo "OBJUTIL=\$(BUILD)/sharedutils" >> "$MAKEFILE"
|
|
|
|
echo "all:" >> "$MAKEFILE"
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
function check_config
|
|
|
|
{
|
|
|
|
local BUILD_DIR="$1"
|
|
|
|
local TEST_TYPE="$2"
|
|
|
|
local TEST_STRING="$3"
|
|
|
|
|
|
|
|
local CONFIG_FILE="$BUILD_DIR/config.build"
|
|
|
|
local CONFIG_LOG="$BUILD_DIR/config.log"
|
|
|
|
|
|
|
|
if ! grep -q "$TEST_STRING" "$CONFIG_FILE"; then
|
|
|
|
echo "config file: $CONFIG_FILE has incorrect $TEST_TYPE"
|
|
|
|
echo "Error: Expected '$TEST_STRING' in config file." >> "$CONFIG_LOG"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2004-10-19 09:00:47 +02:00
|
|
|
function compile_target
|
2010-04-27 08:56:47 +02:00
|
|
|
{
|
2016-11-24 02:47:53 +01:00
|
|
|
local BUILD_NAME=$1
|
2004-10-19 09:00:47 +02:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ "$quiet" == "false" ]; then echo " Compiling $MAINBOARD image$cpuconfig..."; 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`
|
2016-12-01 00:32:20 +01:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
eval $BUILDPREFIX $MAKE $silent DOTCONFIG="${build_dir}/config.build" obj="${build_dir}" objutil="$TARGET/sharedutils" \
|
|
|
|
&> "${build_dir}/make.log" ; \
|
|
|
|
MAKE_FAILED=$?
|
|
|
|
cp .xcompile "${build_dir}/xcompile.build"
|
|
|
|
cd "${build_dir}" || return $?
|
|
|
|
|
|
|
|
etime=$(perl -e 'print time();' 2>/dev/null || date +%s)
|
|
|
|
duration=$(( etime - stime ))
|
2016-11-24 02:47:53 +01:00
|
|
|
junit " <testcase classname='board${testclass/#/.}' name='$BUILD_NAME' time='$duration' >"
|
2010-03-30 16:02:19 +02:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ $MAKE_FAILED -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
|
2016-12-01 00:32:20 +01:00
|
|
|
printf "%s built successfully. (took %ss)\n" "$BUILD_NAME" "${duration}"
|
2004-10-19 09:00:47 +02:00
|
|
|
else
|
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
|
2016-12-01 00:32:20 +01:00
|
|
|
printf "%s build FAILED after %ss!\nLog excerpt:\n" "$BUILD_NAME" "${duration}"
|
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
|
2016-12-01 00:32:20 +01:00
|
|
|
cd "$CURR" || return $?
|
|
|
|
if [ "$clean_work" = "true" ]; then
|
|
|
|
rm -rf "${build_dir}"
|
2014-05-21 22:47:05 +02:00
|
|
|
fi
|
2016-12-01 00:32:20 +01:00
|
|
|
return $MAKE_FAILED
|
2004-10-19 09:00:47 +02:00
|
|
|
}
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
function build_config
|
2004-10-19 09:00:47 +02:00
|
|
|
{
|
2015-10-31 00:35:44 +01:00
|
|
|
local MAINBOARD=$1
|
2016-11-24 02:47:53 +01:00
|
|
|
local build_dir=$2
|
|
|
|
local BUILD_NAME=$3
|
|
|
|
local config_file=$4
|
2016-12-01 00:32:20 +01:00
|
|
|
local board_srcdir
|
|
|
|
local ret
|
2004-11-05 01:25:19 +01:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
board_srcdir=$(mainboard_directory "${MAINBOARD}")
|
2016-11-24 02:47:53 +01:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ "$(cat "${build_dir}/compile.status" 2>/dev/null)" = "ok" ] && \
|
|
|
|
[ "$buildall" = "false" ]; then
|
2016-11-24 02:47:53 +01:00
|
|
|
echo "Skipping $BUILD_NAME; (already successful)"
|
2012-11-22 14:19:43 +01:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
export HOSTCC='gcc'
|
2004-11-05 11:48:04 +01:00
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
if [ "$chromeos" = true ] && [ "$(grep -c "^[[:space:]]*select[[:space:]]*MAINBOARD_HAS_CHROMEOS\>" "${ROOT}/src/mainboard/${board_srcdir}/Kconfig")" -eq 0 ]; then
|
|
|
|
echo "${BUILD_NAME} doesn't support Chrome OS, skipping."
|
2015-07-31 16:26:19 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
if [ -f "src/mainboard/${board_srcdir}/abuild.disabled" ]; then
|
|
|
|
echo "${BUILD_NAME} disabled:"
|
|
|
|
cat "src/mainboard/${board_srcdir}/abuild.disabled"
|
2015-07-14 20:20:13 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
if [ "$quiet" == "false" ]; then echo "Building $BUILD_NAME"; fi
|
|
|
|
mkdir -p "$TARGET/${BUILD_NAME}" "$TARGET/abuild"
|
2016-12-01 00:32:20 +01:00
|
|
|
ABSPATH="$(cd "$TARGET/abuild" && pwd)"
|
2016-11-24 02:47:53 +01:00
|
|
|
XMLFILE="$ABSPATH/${BUILD_NAME}.xml"
|
|
|
|
rm -f "${XMLFILE}"
|
|
|
|
|
|
|
|
stime=$(perl -e 'print time();' 2>/dev/null || date +%s)
|
|
|
|
create_buildenv "$BUILD_NAME" "$build_dir" "$config_file"
|
|
|
|
local BUILDENV_CREATED=$?
|
|
|
|
|
|
|
|
check_config "$build_dir" "mainboard" "CONFIG_BOARD_${MAINBOARD}=y"
|
|
|
|
local MAINBOARD_OK=$?
|
|
|
|
|
|
|
|
check_config "$build_dir" "vendor" "CONFIG_VENDOR_$(mainboard_vendor "${MAINBOARD}")=y"
|
|
|
|
local VENDOR_OK=$?
|
|
|
|
|
|
|
|
if [ $BUILDENV_CREATED -ne 0 ] || [ $MAINBOARD_OK -ne 0 ] || [ $VENDOR_OK -ne 0 ]; then
|
|
|
|
|
|
|
|
junit "<failure type='BuildFailed'>"
|
|
|
|
junitfile "$build_dir/config.log"
|
|
|
|
junit "</failure>"
|
|
|
|
printf "failed\n" > compile.status
|
2016-12-01 00:32:20 +01:00
|
|
|
printf "%s build configuration FAILED!\nLog excerpt:\n" "$BUILD_NAME"
|
2016-11-24 02:47:53 +01:00
|
|
|
tail -n $CONTEXT "$build_dir/config.log" 2> /dev/null || tail -$CONTEXT "$build_dir/config.log"
|
2006-05-27 02:22:02 +02:00
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
junit "</testcase>"
|
|
|
|
return
|
|
|
|
fi
|
2009-03-11 16:43:02 +01:00
|
|
|
|
2014-10-18 11:57:11 +02:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
required_arches=$(egrep "^CONFIG_ARCH_(BOOTBLOCK|R.MSTAGE|VERSTAGE)" "$TARGET/${BUILD_NAME}/config.build" | \
|
|
|
|
sed "s,^CONFIG_ARCH_[^_]*_\([^=]*\)=.*$,\1," |sort -u |tr 'A-Z\n\r' 'a-z ')
|
|
|
|
# shellcheck disable=SC2016,SC2059
|
|
|
|
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
|
2016-12-01 00:32:20 +01:00
|
|
|
printf "skipping %s because we're missing compilers for (%s)\n" "$BUILD_NAME" "$missing_arches"
|
2014-10-18 11:57:11 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ $BUILDENV_CREATED -eq 0 ] && [ $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
|
2016-11-24 02:47:53 +01:00
|
|
|
scanbuild_out=$TARGET/${BUILD_NAME}-scanbuild
|
2016-12-01 00:32:20 +01:00
|
|
|
rm -rf "${scanbuild_out}"
|
2014-05-17 18:26:38 +02:00
|
|
|
BUILDPREFIX="scan-build -o ${scanbuild_out}tmp"
|
2010-04-19 22:39:22 +02:00
|
|
|
fi
|
2016-12-01 00:32:20 +01:00
|
|
|
compile_target "${BUILD_NAME}"
|
2009-03-11 16:43:02 +01:00
|
|
|
if [ "$scanbuild" = "true" ]; then
|
2016-12-01 00:32:20 +01: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
|
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
|
|
|
}
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
# One target may build several configs
|
|
|
|
function build_target
|
|
|
|
{
|
|
|
|
local MAINBOARD=$1
|
2016-12-01 00:32:20 +01:00
|
|
|
local MAINBOARD_LC
|
|
|
|
MAINBOARD_LC=$(echo "$MAINBOARD" | tr '[:upper:]' '[:lower:]')
|
2016-11-24 02:47:53 +01:00
|
|
|
|
|
|
|
# look for config files in the config directory that match the boardname
|
|
|
|
if [ -n "$( find "$configdir" -maxdepth 1 -name "config.${MAINBOARD_LC}*" -print -quit )" ]; then
|
2016-12-01 00:32:20 +01:00
|
|
|
for config in "$configdir/config.${MAINBOARD_LC}"*; do
|
2016-11-24 02:47:53 +01:00
|
|
|
BUILD_NAME="${config##*/}"
|
|
|
|
BUILD_NAME="${BUILD_NAME##config.}"
|
|
|
|
BUILD_NAME=$(echo "${BUILD_NAME}" | tr '[:lower:]' '[:upper:]')
|
|
|
|
echo "Building config $BUILD_NAME"
|
|
|
|
build_dir=$TARGET/${BUILD_NAME}
|
|
|
|
build_config "$MAINBOARD" "$build_dir" "$BUILD_NAME" "$config"
|
|
|
|
remove_target "$BUILD_NAME"
|
|
|
|
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "Building board $MAINBOARD (using default config)"
|
|
|
|
build_dir=$TARGET/${MAINBOARD}
|
|
|
|
|
|
|
|
build_config "$MAINBOARD" "$build_dir" "$MAINBOARD"
|
|
|
|
remove_target "$MAINBOARD"
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-04-15 18:07:27 +02:00
|
|
|
function remove_target
|
|
|
|
{
|
|
|
|
if [ "$remove" != "true" ]; then
|
2016-11-24 02:47:53 +01:00
|
|
|
return
|
2009-04-15 18:07:27 +02:00
|
|
|
fi
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
local BUILD_NAME=$1
|
2009-04-15 18:07:27 +02:00
|
|
|
|
|
|
|
# Save the generated coreboot.rom file of each board.
|
2016-11-24 02:47:53 +01:00
|
|
|
if [ -r "$TARGET/${BUILD_NAME}/coreboot.rom" ]; then
|
|
|
|
cp "$TARGET/${BUILD_NAME}/coreboot.rom" \
|
|
|
|
"${BUILD_NAME}_coreboot.rom"
|
2009-04-15 18:07:27 +02:00
|
|
|
fi
|
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
echo "Removing build dir for $BUILD_NAME..."
|
2016-12-01 00:32:20 +01:00
|
|
|
rm -rf "${TARGET:?}/${BUILD_NAME}"
|
2009-04-15 18:07:27 +02:00
|
|
|
|
2016-11-24 02:47:53 +01:00
|
|
|
return
|
2009-04-15 18:07:27 +02:00
|
|
|
}
|
|
|
|
|
2004-11-05 01:25:19 +01:00
|
|
|
function myhelp
|
|
|
|
{
|
2015-07-31 16:14:43 +02:00
|
|
|
cat << __END_OF_HELP
|
2016-12-06 17:18:36 +01:00
|
|
|
Usage: $0 [options]
|
2015-07-31 16:14:43 +02:00
|
|
|
$0 [-V|--version]
|
|
|
|
$0 [-h|--help]
|
|
|
|
|
|
|
|
Options:\n"
|
2016-12-05 17:15:33 +01:00
|
|
|
[-a|--all] Build previously succeeded ports as well
|
2015-07-31 16:14:43 +02:00
|
|
|
[-B|--blobs] Allow using binary files
|
2016-12-05 17:15:33 +01:00
|
|
|
[-c|--cpus <numcpus>] Build on <numcpus> at the same time
|
|
|
|
[-C|--config] Configure-only mode
|
|
|
|
[-d|--dir <dir>] Directory containing config files
|
|
|
|
[-J|--junit] Write JUnit formatted xml log file
|
|
|
|
[-K|--kconfig <name>] Prepend file to generated Kconfig
|
|
|
|
[-l|--loglevel <num>] Set loglevel
|
2015-07-31 16:14:43 +02:00
|
|
|
[-L|--clang] Use clang
|
2016-12-05 17:15:33 +01:00
|
|
|
[-o|--outdir <path>] Store build results in path
|
|
|
|
(defaults to $TARGET)
|
|
|
|
[-p|--payloads <dir>] Use payloads in <dir> to build images
|
|
|
|
[-P|--prefix <name>] File name prefix in CBFS
|
|
|
|
[-q|--quiet] Print fewer messages
|
|
|
|
[-r|--remove] Remove output dir after build
|
2016-12-06 17:18:36 +01:00
|
|
|
[-R|--root <path>] Absolute path to coreboot sources
|
|
|
|
(defaults to $ROOT)
|
2016-12-05 17:15:33 +01:00
|
|
|
[--scan-build] Use clang's static analyzer
|
|
|
|
[-s|--silent] Omit compiler calls in logs
|
|
|
|
[-t|--target <vendor/board>] Attempt to build target vendor/board only
|
|
|
|
[-T|--test] Submit image(s) to automated test system
|
|
|
|
[-u|--update] Update existing image
|
|
|
|
[-v|--verbose] Print more messages
|
2015-07-31 16:14:43 +02:00
|
|
|
[-x|--chromeos] Build with CHROMEOS enabled
|
2015-07-31 16:26:19 +02:00
|
|
|
Skip boards without Chrome OS support
|
2016-12-05 17:15:33 +01:00
|
|
|
[-X|--xmlfile <name>] Set JUnit XML log file filename
|
|
|
|
(defaults to $XMLFILE)
|
|
|
|
[-y|--ccache] Use ccache
|
|
|
|
[-z|--clean] Remove build results when finished
|
|
|
|
|
|
|
|
[-V|--version] Print version number and exit
|
|
|
|
[-h|--help] Print this help and exit
|
2015-07-31 16:14:43 +02:00
|
|
|
|
|
|
|
__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 )
|
2016-12-01 00:32:20 +01:00
|
|
|
test -f ../util/sconfig/sconfig.l && ROOT=$( cd .. && pwd )
|
|
|
|
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
|
2016-12-01 00:32:20 +01:00
|
|
|
getoptbrand="$(getopt -V)"
|
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
2008-05-28 10:40:23 +02:00
|
|
|
if [ "${getoptbrand:0:6}" == "getopt" ]; then
|
|
|
|
# Detected GNU getopt that supports long options.
|
2016-12-06 17:18:36 +01:00
|
|
|
args=$(getopt -l version,verbose,quiet,help,all,target:,payloads:,cpus:,silent,junit,config,loglevel:,remove,prefix:,update,scan-build,ccache,blobs,clang,clean,outdir:,chromeos,xmlfile:,kconfig:,dir:,root: -o Vvqhat:p:c:sJCl:rP:uyBLzo:xX:K:d:R: -- "$@") || exit 1
|
2010-09-27 23:14:19 +02:00
|
|
|
eval set -- $args
|
2016-12-01 00:32:20 +01:00
|
|
|
retval=$?
|
2008-05-27 20:29:26 +02:00
|
|
|
else
|
|
|
|
# Detected non-GNU getopt
|
2016-12-06 17:18:36 +01:00
|
|
|
args=$(getopt Vvqhat:p:c:sJCl:rP:uyBLzo:xX:K:d:R: "$@")
|
2008-05-27 20:29:26 +02:00
|
|
|
set -- $args
|
2016-12-01 00:32:20 +01:00
|
|
|
retval=$?
|
2008-05-27 20:29:26 +02:00
|
|
|
fi
|
2004-11-05 01:25:19 +01:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ $retval != 0 ]; then
|
2004-11-05 01:25:19 +01:00
|
|
|
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
|
2016-12-01 00:32:20 +01: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;;
|
2016-11-24 02:47:53 +01:00
|
|
|
-d|--dir) shift; configdir="$1"; shift;;
|
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;;
|
2016-12-06 17:18:36 +01:00
|
|
|
-R|--root) shift; ROOT="$1"; shift;;
|
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"
|
2016-12-01 00:32:20 +01:00
|
|
|
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"
|
|
|
|
;;
|
2015-10-13 20:27:56 +02:00
|
|
|
-X|--xmlfile) shift; XMLFILE=$1; REAL_XMLFILE=$1; shift;;
|
2016-03-09 21:12:10 +01:00
|
|
|
-K|--kconfig) shift
|
2016-12-01 00:32:20 +01:00
|
|
|
testclass="$(basename "$1" | tr '.' '_' )"
|
2016-03-09 21:12:10 +01:00
|
|
|
customizing="${customizing}, $1 config"
|
|
|
|
configoptions="$(cat "$1")${configoptions}\n"
|
|
|
|
shift;;
|
2004-11-05 09:50:54 +01:00
|
|
|
--) shift; break;;
|
2016-12-06 17:51:54 +01:00
|
|
|
-*) printf "Invalid option '%s'\n\n" "$1"; 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
|
2016-12-06 17:51:54 +01:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
printf "Invalid option '%s'\n\n" "$1"; myhelp; exit 1;
|
|
|
|
fi
|
2004-11-05 01:25:19 +01:00
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
if [ -z "$TARGET" ] || [ "$TARGET" = "/" ]; then
|
2014-05-21 23:00:32 +02:00
|
|
|
echo "Please specify a valid, non-root build directory."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-12-01 00:32:20 +01:00
|
|
|
customizing=$(echo "$customizing" | cut -c3-)
|
2012-05-01 15:14:46 +02:00
|
|
|
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
|
2015-10-31 00:42:50 +01:00
|
|
|
# Test if xargs supports the non-standard -P flag
|
|
|
|
# FIXME: disabled until we managed to eliminate all the make(1) quirks
|
|
|
|
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
|
|
|
|
|
|
|
|
if [ "$USE_XARGS" = "0" ]; then
|
2012-05-31 00:03:48 +02:00
|
|
|
test "$MAKEFLAGS" == "" && test "$cpus" != "" && export MAKEFLAGS="-j $cpus"
|
2015-10-31 00:42:50 +01:00
|
|
|
build_targets()
|
2011-11-05 14:44:41 +01:00
|
|
|
{
|
2015-10-31 00:42:50 +01:00
|
|
|
local targets=${*-$(get_mainboards)}
|
|
|
|
for MAINBOARD in $targets; do
|
2016-12-01 00:32:20 +01:00
|
|
|
build_target "${MAINBOARD}"
|
2011-11-05 14:44:41 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
else
|
2015-10-31 00:42:50 +01:00
|
|
|
build_targets()
|
2011-11-05 14:44:41 +01:00
|
|
|
{
|
2016-12-01 00:32:20 +01:00
|
|
|
local ABSPATH
|
|
|
|
local stime
|
|
|
|
local etime
|
|
|
|
|
2015-10-31 00:42:50 +01:00
|
|
|
local targets=${*-$(get_mainboards)}
|
2011-11-05 14:44:41 +01:00
|
|
|
# seed shared utils
|
2016-12-01 00:32:20 +01:00
|
|
|
TMPCFG=$(mktemp)
|
|
|
|
printf "%s" "$configoptions" > "$TMPCFG"
|
|
|
|
$MAKE -j "$cpus" DOTCONFIG="$TMPCFG" obj="$TARGET/temp" objutil="$TARGET/sharedutils" allnoconfig
|
|
|
|
printf "%s" "$configoptions" >> "$TMPCFG"
|
|
|
|
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
|
2016-12-01 00:32:20 +01:00
|
|
|
rm -rf "${scanbuild_out}"
|
2014-05-17 18:26:38 +02:00
|
|
|
BUILDPREFIX="scan-build -o ${scanbuild_out}tmp"
|
|
|
|
fi
|
2016-12-01 00:32:20 +01:00
|
|
|
mkdir -p "$TARGET/abuild"
|
|
|
|
ABSPATH="$(cd "$TARGET/abuild" && pwd)"
|
|
|
|
local XMLFILE="$ABSPATH/__util.xml"
|
|
|
|
rm -f "${XMLFILE}"
|
|
|
|
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
|
2015-09-15 17:30:52 +02:00
|
|
|
local ret=$?
|
2016-12-01 00:32:20 +01:00
|
|
|
etime=$(perl -e 'print time();' 2>/dev/null || date +%s)
|
|
|
|
local duration=$(( etime - stime ))
|
2015-09-15 17:30:52 +02:00
|
|
|
|
|
|
|
junit " <testcase classname='util' name='all' time='$duration' >"
|
|
|
|
if [ $ret -eq 0 ]; then
|
|
|
|
junit "<system-out>"
|
2016-12-01 00:32:20 +01:00
|
|
|
junitfile "$TARGET/sharedutils/make.log"
|
2015-09-15 17:30:52 +02:00
|
|
|
junit "</system-out>"
|
|
|
|
junit "</testcase>"
|
|
|
|
else
|
|
|
|
junit "<failure type='BuildFailed'>"
|
2016-12-01 00:32:20 +01:00
|
|
|
junitfile "$TARGET/sharedutils/make.log"
|
2015-09-15 17:30:52 +02:00
|
|
|
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
|
2016-12-01 00:32:20 +01:00
|
|
|
mv "${scanbuild_out}tmp/"* "${scanbuild_out}"
|
|
|
|
rmdir "${scanbuild_out}tmp"
|
2014-05-17 18:26:38 +02:00
|
|
|
fi
|
2016-12-01 00:32:20 +01:00
|
|
|
rm -rf "$TARGET/temp" "$TMPCFG"
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
echo $targets | 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
|
|
|
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
|
2016-12-01 00:32:20 +01:00
|
|
|
MAINBOARD=$(normalize_target "${target}")
|
2015-10-31 00:35:44 +01:00
|
|
|
if [ -z "${MAINBOARD}" ]; then
|
2016-12-01 00:32:20 +01:00
|
|
|
printf "No such target: %s\n" "$target"
|
2015-10-31 00:35:44 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-12-01 00:32:20 +01:00
|
|
|
build_srcdir="$(mainboard_directory "${MAINBOARD}")"
|
|
|
|
if [ "$(echo "${MAINBOARD}" | wc -w)" -gt 1 ]; then
|
|
|
|
build_targets "${MAINBOARD}"
|
|
|
|
elif [ ! -r "$ROOT/src/mainboard/${build_srcdir}" ]; then
|
|
|
|
echo "No such target: ${MAINBOARD}"
|
2015-10-31 00:35:44 +01:00
|
|
|
exit 1
|
2011-11-05 14:44:41 +01:00
|
|
|
else
|
2016-12-01 00:32:20 +01:00
|
|
|
build_target "${MAINBOARD}"
|
2015-09-15 19:32:28 +02:00
|
|
|
test "$mode" != "text" && \
|
2016-12-01 00:32:20 +01:00
|
|
|
test -f "$TARGET/abuild/${MAINBOARD}.xml" && \
|
|
|
|
cat "$TARGET/abuild/${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
|
2015-10-31 00:42:50 +01:00
|
|
|
build_targets
|
2016-12-01 00:32:20 +01:00
|
|
|
rm -f "$REAL_XMLFILE"
|
|
|
|
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
|
2016-12-01 00:32:20 +01:00
|
|
|
cat "$xmlfile" >> "$REAL_XMLFILE"
|
2011-11-07 19:01:54 +01:00
|
|
|
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
|