Martin Roth | b69ae97 | 2018-08-27 07:10:03 -0600 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 2 | # |
Stefan Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 3 | # coreboot autobuild |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 4 | # |
Stefan Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 5 | # This script builds coreboot images for all available targets. |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 6 | # |
| 7 | # (C) 2004 by Stefan Reinauer <stepan@openbios.org> |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 8 | # (C) 2006-2010 by coresystems GmbH <info@coresystems.de> |
Martin Roth | ddb7a9d | 2014-12-08 01:57:52 -0700 | [diff] [blame] | 9 | # (C) 2013-2014 Sage Electronic Engineering, LLC |
Patrick Georgi | 2d24279 | 2014-05-21 22:48:35 +0200 | [diff] [blame] | 10 | # (C) 2014 Patrick Georgi <patrick@georgi-clan.de> |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 11 | # |
| 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. |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 15 | # |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 16 | |
Eric Biederman | c149210 | 2004-11-05 08:50:54 +0000 | [diff] [blame] | 17 | #set -x # Turn echo on.... |
Stefan Reinauer | 23c3d93 | 2004-10-21 21:41:57 +0000 | [diff] [blame] | 18 | |
Julius Werner | 893eda0 | 2017-03-20 15:33:23 -0700 | [diff] [blame] | 19 | ABUILD_DATE="Mar 28, 2017" |
Martin Roth | 3331426 | 2017-03-27 23:45:31 -0600 | [diff] [blame] | 20 | ABUILD_VERSION="0.10.03" |
Stefan Reinauer | 3a14057 | 2006-10-25 19:02:34 +0000 | [diff] [blame] | 21 | |
Patrick Georgi | 3db85f3 | 2011-11-05 13:21:14 +0100 | [diff] [blame] | 22 | TOP=$PWD |
| 23 | |
Stefan Reinauer | 23c3d93 | 2004-10-21 21:41:57 +0000 | [diff] [blame] | 24 | # Where shall we place all the build trees? |
Patrick Georgi | aab0cce | 2013-12-19 20:43:29 +0100 | [diff] [blame] | 25 | TARGET=${COREBOOT_BUILD_DIR:-coreboot-builds} |
Patrick Georgi | 3db85f3 | 2011-11-05 13:21:14 +0100 | [diff] [blame] | 26 | XMLFILE=$TOP/abuild.xml |
| 27 | REAL_XMLFILE=$XMLFILE |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 28 | |
Patrick Georgi | d03d69b | 2013-12-19 20:13:23 +0100 | [diff] [blame] | 29 | export KCONFIG_OVERWRITECONFIG=1 |
| 30 | |
Stefan Reinauer | 23c3d93 | 2004-10-21 21:41:57 +0000 | [diff] [blame] | 31 | # path to payload. Should be more generic |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 32 | PAYLOAD=/dev/null |
Stefan Reinauer | 23c3d93 | 2004-10-21 21:41:57 +0000 | [diff] [blame] | 33 | |
Martin Roth | 14b9b93 | 2016-11-30 16:38:25 -0700 | [diff] [blame] | 34 | # get path to coreboot XGCC if it's not already set |
| 35 | if [ -z "$XGCCPATH" ]; then |
| 36 | XGCCPATH="${TOP}/util/crossgcc/xgcc/bin/" |
| 37 | fi |
Marc Jones | 66a68a2 | 2013-05-31 13:33:30 -0600 | [diff] [blame] | 38 | |
| 39 | # Add XGCC to the path. |
| 40 | if [ -d "$XGCCPATH" ] && [[ ":$PATH:" != *":$XGCCPATH:"* ]]; then |
| 41 | PATH="$XGCCPATH:$PATH" |
| 42 | fi |
| 43 | |
Stefan Reinauer | 23c3d93 | 2004-10-21 21:41:57 +0000 | [diff] [blame] | 44 | # Lines of error context to be printed in FAILURE case |
Stefan Reinauer | ed56422 | 2015-12-14 16:36:45 -0800 | [diff] [blame] | 45 | CONTEXT=12 |
Stefan Reinauer | 23c3d93 | 2004-10-21 21:41:57 +0000 | [diff] [blame] | 46 | |
Stefan Reinauer | cc44b06 | 2009-03-11 15:00:50 +0000 | [diff] [blame] | 47 | # Configure-only mode |
| 48 | configureonly=0 |
| 49 | |
Patrick Georgi | f9d19f2 | 2011-06-01 19:29:48 +0000 | [diff] [blame] | 50 | # Did any board fail to build? |
| 51 | failed=0 |
| 52 | |
Martin Roth | ba973bd | 2017-07-19 14:13:07 -0600 | [diff] [blame] | 53 | # Exit with a non-zero errorlevel on failure |
| 54 | exitcode=0 |
| 55 | |
Martin Roth | c7e6ad7 | 2017-03-26 18:23:51 -0600 | [diff] [blame] | 56 | # default: don't save checksums |
| 57 | checksum_file="" |
| 58 | |
Patrick Georgi | 5895551 | 2013-12-05 19:53:04 +0100 | [diff] [blame] | 59 | # default: single CPU build |
| 60 | cpus=1 |
| 61 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 62 | # change with -d <directory> |
| 63 | configdir="$TOP/configs" |
| 64 | |
Martin Roth | 3331426 | 2017-03-27 23:45:31 -0600 | [diff] [blame] | 65 | # Timeless builds |
| 66 | TIMELESS=0 |
| 67 | |
Stefan Reinauer | 23c3d93 | 2004-10-21 21:41:57 +0000 | [diff] [blame] | 68 | # One might want to adjust these in case of cross compiling |
Patrick Georgi | a84a99b | 2009-05-26 14:03:51 +0000 | [diff] [blame] | 69 | for i in make gmake gnumake nonexistant_make; do |
| 70 | $i --version 2>/dev/null |grep "GNU Make" >/dev/null && break |
| 71 | done |
| 72 | if [ "$i" = "nonexistant_make" ]; then |
| 73 | echo No GNU Make found. |
| 74 | exit 1 |
| 75 | fi |
| 76 | MAKE=$i |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 77 | |
Patrick Georgi | 6f0e160 | 2013-12-05 19:36:31 +0100 | [diff] [blame] | 78 | # this can be changed to junit by -J |
Stefan Reinauer | 192b7bc | 2006-05-27 00:22:02 +0000 | [diff] [blame] | 79 | mode=text |
| 80 | |
Martin Roth | ddb7a9d | 2014-12-08 01:57:52 -0700 | [diff] [blame] | 81 | # quiet mode: only print pass, failure, and 'skipped' messages |
| 82 | quiet=false |
| 83 | |
Patrick Georgi | d229677 | 2009-03-11 15:43:02 +0000 | [diff] [blame] | 84 | # clang mode enabled by -sb option. |
| 85 | scanbuild=false |
| 86 | |
Martin Roth | 047c2f4 | 2016-12-14 10:16:26 -0700 | [diff] [blame] | 87 | # Mark whether abuild was called recursively |
| 88 | recursive=false |
| 89 | |
Stefan Reinauer | 3a14057 | 2006-10-25 19:02:34 +0000 | [diff] [blame] | 90 | trap interrupt INT |
| 91 | |
| 92 | function interrupt |
| 93 | { |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 94 | printf "\n%s: execution interrupted manually.\n" "$0" |
Patrick Georgi | 6f0e160 | 2013-12-05 19:36:31 +0100 | [diff] [blame] | 95 | if [ "$mode" == "junit" ]; then |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 96 | printf "%s: deleting incomplete xml output file.\n" "$0" |
Stefan Reinauer | 3a14057 | 2006-10-25 19:02:34 +0000 | [diff] [blame] | 97 | fi |
| 98 | exit 1 |
| 99 | } |
| 100 | |
Stefan Reinauer | 173f13b | 2004-11-05 11:57:00 +0000 | [diff] [blame] | 101 | function debug |
| 102 | { |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 103 | test "$verbose" == "true" && echo "$*" |
Stefan Reinauer | 173f13b | 2004-11-05 11:57:00 +0000 | [diff] [blame] | 104 | } |
Eric Biederman | 692f2c7 | 2004-11-05 19:55:06 +0000 | [diff] [blame] | 105 | |
Patrick Georgi | 140a990 | 2011-06-03 21:56:13 +0200 | [diff] [blame] | 106 | function junit |
| 107 | { |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 108 | test "$mode" == "junit" && echo "$*" >> "$XMLFILE" |
Patrick Georgi | 140a990 | 2011-06-03 21:56:13 +0200 | [diff] [blame] | 109 | return 0 |
| 110 | } |
| 111 | |
| 112 | function junitfile |
| 113 | { |
| 114 | test "$mode" == "junit" && { |
| 115 | printf '<![CDATA[\n' |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 116 | cat "$1" |
Patrick Georgi | 140a990 | 2011-06-03 21:56:13 +0200 | [diff] [blame] | 117 | printf ']]>\n' |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 118 | } >> "$XMLFILE" |
Patrick Georgi | 140a990 | 2011-06-03 21:56:13 +0200 | [diff] [blame] | 119 | } |
Stefan Reinauer | 192b7bc | 2006-05-27 00:22:02 +0000 | [diff] [blame] | 120 | |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 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 |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 126 | { |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 127 | local search_space=${1-*/*} |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 128 | # shellcheck disable=SC2086 |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 129 | grep -h "^[[:space:]]*config\>[[:space:]]*\<BOARD_" \ |
Patrick Georgi | f6dc544 | 2015-10-31 09:13:26 +0100 | [diff] [blame] | 130 | ${ROOT}/src/mainboard/${search_space}/Kconfig.name 2>/dev/null | \ |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 131 | sed "s,^.*\<BOARD_\([A-Z0-9_]*\)\>.*$,\1," |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 132 | } |
| 133 | |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 134 | # Given a mainboard descriptor, return its directory below src/mainboard |
| 135 | function mainboard_directory |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 136 | { |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 137 | local MAINBOARD=$1 |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 138 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 139 | # shellcheck disable=SC2086 |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 140 | grep -l "^[[:space:]]*config\>[[:space:]]*\<BOARD_${MAINBOARD}\>" \ |
| 141 | ${ROOT}/src/mainboard/*/*/Kconfig.name | \ |
| 142 | sed "s:^$ROOT/src/mainboard/\(.*\)/Kconfig.name$:\1:" |
| 143 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 144 | |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 145 | # Given a mainboard descriptor, return its vendor (CONFIG_VENDOR_*) |
| 146 | function mainboard_vendor |
| 147 | { |
| 148 | local MAINBOARD=$1 |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 149 | local kconfig_file |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 150 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 151 | # shellcheck disable=SC2086 |
| 152 | kconfig_file=$( \ |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 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 |
| 157 | exit 1 |
| 158 | fi |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 159 | grep "^[[:space:]]*config\>[[:space:]]*\<VENDOR_" "$kconfig_file" | \ |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 160 | sed "s,^.*\<VENDOR_\([A-Z0-9_]*\)\>.*$,\1," |
| 161 | } |
| 162 | |
| 163 | # Accepts directory names (eg. emulation/qemu-i440fx) and mainboard |
| 164 | # descriptors (eg. EMULATION_QEMU_X86_I440F} and returns the latter |
| 165 | # format. |
| 166 | # If a directory contains multiple boards, returns them all. |
| 167 | function normalize_target |
| 168 | { |
Martin Roth | 5b7c6f5 | 2018-07-22 10:54:11 -0600 | [diff] [blame] | 169 | # TODO: Change 'targets' variable to an array |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 170 | local targets |
Martin Roth | 5b7c6f5 | 2018-07-22 10:54:11 -0600 | [diff] [blame] | 171 | local VARIANT_UC |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 172 | |
Martin Roth | 5b7c6f5 | 2018-07-22 10:54:11 -0600 | [diff] [blame] | 173 | VARIANT_UC=$(echo "${variant}" | tr '[:lower:]' '[:upper:]') |
Furquan Shaikh | 57ccb9c | 2018-06-23 01:00:32 -0700 | [diff] [blame] | 174 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 175 | targets=$(get_mainboards "$1") |
Patrick Georgi | f6dc544 | 2015-10-31 09:13:26 +0100 | [diff] [blame] | 176 | if [ -n "$targets" ]; then |
Martin Roth | 5b7c6f5 | 2018-07-22 10:54:11 -0600 | [diff] [blame] | 177 | # shellcheck disable=SC2086 |
| 178 | targets="$(grep "${VARIANT_UC}\$" <<< ${targets})" |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 179 | echo "$targets" |
Patrick Georgi | f6dc544 | 2015-10-31 09:13:26 +0100 | [diff] [blame] | 180 | return |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 181 | fi |
Patrick Georgi | f6dc544 | 2015-10-31 09:13:26 +0100 | [diff] [blame] | 182 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 183 | targets=$(echo "$1" | tr ',' ' ') |
Patrick Georgi | f6dc544 | 2015-10-31 09:13:26 +0100 | [diff] [blame] | 184 | for i in $targets; do |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 185 | if [ -n "$(mainboard_directory "$i")" ]; then |
| 186 | echo "$i" |
Patrick Georgi | f6dc544 | 2015-10-31 09:13:26 +0100 | [diff] [blame] | 187 | else |
| 188 | echo "$i is not a valid target" >&2 |
| 189 | exit 1 |
| 190 | fi |
| 191 | done |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 194 | # shellcheck disable=SC2129 |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 195 | function create_config |
| 196 | { |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 197 | local BUILD_NAME=$1 |
| 198 | local build_dir=$2 |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 199 | local board_srcdir |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 200 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 201 | local config_file="${build_dir}/config.build" |
| 202 | board_srcdir="$(mainboard_directory "${BUILD_NAME}")" |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 203 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 204 | mkdir -p "${build_dir}" |
| 205 | mkdir -p "$TARGET/sharedutils" |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 206 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 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}" |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 213 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 214 | update_config "$BUILD_NAME" "$build_dir" "$config_file" |
Patrick Georgi | e6adabd | 2015-10-30 22:59:30 +0100 | [diff] [blame] | 215 | |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 216 | ret=$? |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 217 | if [ $ret -eq 0 ]; then |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 218 | if [ "$quiet" == "false" ]; then echo " $BUILD_NAME config created."; fi |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 219 | return 0 |
| 220 | else |
Stefan Reinauer | abdf848 | 2010-03-30 14:02:19 +0000 | [diff] [blame] | 221 | # Does this ever happen? |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 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" |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 224 | return 1 |
| 225 | fi |
| 226 | } |
| 227 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 228 | function update_config |
| 229 | { |
| 230 | local BUILD_NAME=$1 |
| 231 | local build_dir=$2 |
| 232 | local config_file=$3 |
| 233 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 234 | local PAYLOAD |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 235 | local defconfig_file |
| 236 | defconfig_file=${build_dir}/config.$(echo "${BUILD_NAME}" | tr '[:upper:]' '[:lower:]').default |
| 237 | |
| 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. |
| 243 | |
| 244 | if [ -f "$payloads/payload.sh" ]; then |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 245 | PAYLOAD=$(sh "$payloads/payload.sh" "$BUILD_NAME") |
| 246 | local PAYLOAD_OK=$? |
| 247 | if [ $PAYLOAD_OK -gt 0 ]; then |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 248 | echo "problem with payload" |
| 249 | exit 1 |
| 250 | fi |
| 251 | if [ "$quiet" == "false" ]; then printf "Using payload %s\n" "$PAYLOAD"; fi |
| 252 | elif [ "$payloads" = "none" ]; then |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 253 | PAYLOAD=none |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 254 | fi |
| 255 | |
| 256 | if [ "$PAYLOAD" = "none" ]; then |
| 257 | { |
| 258 | echo "CONFIG_PAYLOAD_NONE=y" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 259 | echo "# CONFIG_PAYLOAD_ELF is not set" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 260 | } >> "${config_file}" |
| 261 | elif [ "$PAYLOAD" != "/dev/null" ]; then |
| 262 | { |
| 263 | echo "# CONFIG_PAYLOAD_NONE is not set" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 264 | echo "CONFIG_PAYLOAD_ELF=y" |
| 265 | echo "CONFIG_PAYLOAD_FILE=\"$PAYLOAD\"" |
| 266 | } >> "${config_file}" |
| 267 | fi |
Martin Roth | 735b9a0 | 2018-05-07 21:44:37 -0500 | [diff] [blame] | 268 | # Disable all other payload config options |
| 269 | { |
| 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" |
Philipp Deppenwiese | 0f0e4e6 | 2018-06-19 20:22:32 +0200 | [diff] [blame] | 276 | echo "# CONFIG_PAYLOAD_LINUXBOOT is not set" |
Martin Roth | 735b9a0 | 2018-05-07 21:44:37 -0500 | [diff] [blame] | 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}" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 286 | |
| 287 | if [ "$quiet" == "false" ]; then echo " $MAINBOARD ($customizing)"; fi |
Martin Roth | 6bc4416 | 2016-12-13 15:29:30 -0700 | [diff] [blame] | 288 | # shellcheck disable=SC2059 |
| 289 | printf "$configoptions" >> "${config_file}" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 290 | |
Patrick Georgi | 55ea013 | 2017-06-27 14:02:18 +0200 | [diff] [blame] | 291 | yes "" 2>/dev/null | $MAKE oldconfig "$verboseopt" "DOTCONFIG=${config_file}" "obj=${build_dir}" "objutil=$TARGET/sharedutils" &> "${build_dir}/config.log" ; \ |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 292 | CONFIG_OK=$? |
| 293 | if [ $CONFIG_OK -eq 0 ]; then |
Patrick Georgi | 55ea013 | 2017-06-27 14:02:18 +0200 | [diff] [blame] | 294 | $MAKE savedefconfig "$verboseopt" DEFCONFIG="${defconfig_file}" DOTCONFIG="${config_file}" obj="${build_dir}" objutil="$TARGET/sharedutils" &>> "${build_dir}/config.log" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 295 | return $? |
| 296 | else |
| 297 | return 1 |
| 298 | fi |
| 299 | } |
| 300 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 301 | # shellcheck disable=SC2129 |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 302 | function create_buildenv |
| 303 | { |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 304 | local BUILD_NAME=$1 |
| 305 | local build_dir=$2 |
| 306 | local config_file=$3 |
Stefan Reinauer | 0ed0b7c | 2010-03-30 15:49:14 +0000 | [diff] [blame] | 307 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 308 | if [ -z "$config_file" ]; then |
| 309 | create_config "$BUILD_NAME" "$build_dir" |
| 310 | else |
| 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" |
| 314 | fi |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 315 | local ret=$? |
Stefan Reinauer | 86dbe15 | 2010-03-25 14:18:57 +0000 | [diff] [blame] | 316 | |
| 317 | # Allow simple "make" in the target directory |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 318 | local MAKEFILE=$TARGET/${BUILD_NAME}/Makefile |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 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" |
Stefan Reinauer | 0ed0b7c | 2010-03-30 15:49:14 +0000 | [diff] [blame] | 331 | |
| 332 | return $ret |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 333 | } |
| 334 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 335 | function check_config |
| 336 | { |
| 337 | local BUILD_DIR="$1" |
| 338 | local TEST_TYPE="$2" |
| 339 | local TEST_STRING="$3" |
| 340 | |
| 341 | local CONFIG_FILE="$BUILD_DIR/config.build" |
| 342 | local CONFIG_LOG="$BUILD_DIR/config.log" |
| 343 | |
| 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" |
| 347 | return 1 |
| 348 | fi |
| 349 | |
| 350 | return 0 |
| 351 | } |
| 352 | |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 353 | function compile_target |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 354 | { |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 355 | local BUILD_NAME=$1 |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 356 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 357 | if [ "$quiet" == "false" ]; then echo " Compiling $MAINBOARD image$cpuconfig..."; fi |
Stefan Reinauer | 02a4e7f | 2008-05-27 18:29:26 +0000 | [diff] [blame] | 358 | |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 359 | CURR=$( pwd ) |
Stefan Reinauer | abdf848 | 2010-03-30 14:02:19 +0000 | [diff] [blame] | 360 | #stime=`perl -e 'print time();' 2>/dev/null || date +%s` |
Martin Roth | 5b7c6f5 | 2018-07-22 10:54:11 -0600 | [diff] [blame] | 361 | eval "$BUILDPREFIX" "$MAKE" "$verboseopt" DOTCONFIG="${build_dir}/config.build" obj="${build_dir}" objutil="$TARGET/sharedutils" BUILD_TIMELESS=$TIMELESS \ |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 362 | &> "${build_dir}/make.log" ; \ |
| 363 | MAKE_FAILED=$? |
Martin Roth | 5b7c6f5 | 2018-07-22 10:54:11 -0600 | [diff] [blame] | 364 | cp "${ROOT}/.xcompile" "${build_dir}/xcompile.build" |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 365 | cd "${build_dir}" || return $? |
Stefan Reinauer | abdf848 | 2010-03-30 14:02:19 +0000 | [diff] [blame] | 366 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 367 | etime=$(perl -e 'print time();' 2>/dev/null || date +%s) |
| 368 | duration=$(( etime - stime )) |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 369 | junit " <testcase classname='board${testclass/#/.}' name='$BUILD_NAME' time='$duration' >" |
Stefan Reinauer | abdf848 | 2010-03-30 14:02:19 +0000 | [diff] [blame] | 370 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 371 | if [ $MAKE_FAILED -eq 0 ]; then |
Patrick Georgi | 140a990 | 2011-06-03 21:56:13 +0200 | [diff] [blame] | 372 | junit "<system-out>" |
| 373 | junitfile make.log |
| 374 | junit "</system-out>" |
Stefan Reinauer | 3a14057 | 2006-10-25 19:02:34 +0000 | [diff] [blame] | 375 | printf "ok\n" > compile.status |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 376 | printf "%s built successfully. (took %ss)\n" "$BUILD_NAME" "${duration}" |
Martin Roth | d16022b | 2017-06-25 14:21:09 -0600 | [diff] [blame] | 377 | echo "$BUILD_NAME" >> "$PASSED_BOARDS" |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 378 | else |
Patrick Georgi | 140a990 | 2011-06-03 21:56:13 +0200 | [diff] [blame] | 379 | junit "<failure type='BuildFailed'>" |
| 380 | junitfile make.log |
| 381 | junit "</failure>" |
Patrick Georgi | 8bf5c15 | 2015-04-22 18:24:01 +0200 | [diff] [blame] | 382 | printf "failed\n" > compile.status |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 383 | printf "%s build FAILED after %ss!\nLog excerpt:\n" "$BUILD_NAME" "${duration}" |
Patrick Georgi | a84a99b | 2009-05-26 14:03:51 +0000 | [diff] [blame] | 384 | tail -n $CONTEXT make.log 2> /dev/null || tail -$CONTEXT make.log |
Martin Roth | 7a98591 | 2018-07-22 10:31:19 -0600 | [diff] [blame] | 385 | if [ "$clean_work" = "true" ]; then |
| 386 | echo "$BUILD_NAME" >> "$FAILED_BOARDS" |
| 387 | else |
| 388 | echo "$BUILD_NAME - Log: ${build_dir}/make.log" >> "$FAILED_BOARDS" |
| 389 | fi |
Patrick Georgi | f9d19f2 | 2011-06-01 19:29:48 +0000 | [diff] [blame] | 390 | failed=1 |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 391 | fi |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 392 | cd "$CURR" || return $? |
Martin Roth | c7e6ad7 | 2017-03-26 18:23:51 -0600 | [diff] [blame] | 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" |
| 397 | fi |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 398 | if [ "$clean_work" = "true" ]; then |
| 399 | rm -rf "${build_dir}" |
Patrick Georgi | b0bc63b | 2014-05-21 22:47:05 +0200 | [diff] [blame] | 400 | fi |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 401 | return $MAKE_FAILED |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 402 | } |
| 403 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 404 | function build_config |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 405 | { |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 406 | local MAINBOARD=$1 |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 407 | local build_dir=$2 |
| 408 | local BUILD_NAME=$3 |
| 409 | local config_file=$4 |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 410 | local board_srcdir |
| 411 | local ret |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 412 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 413 | board_srcdir=$(mainboard_directory "${MAINBOARD}") |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 414 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 415 | if [ "$(cat "${build_dir}/compile.status" 2>/dev/null)" = "ok" ] && \ |
| 416 | [ "$buildall" = "false" ]; then |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 417 | echo "Skipping $BUILD_NAME; (already successful)" |
Patrick Georgi | 1a5301d | 2012-11-22 14:19:43 +0100 | [diff] [blame] | 418 | return |
| 419 | fi |
| 420 | |
Paul Menzel | d2bbaff | 2016-12-09 08:47:45 +0100 | [diff] [blame] | 421 | export HOSTCC='gcc' |
Eric Biederman | 709850a | 2004-11-05 10:48:04 +0000 | [diff] [blame] | 422 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 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." |
Patrick Georgi | f43b06d | 2015-07-31 16:26:19 +0200 | [diff] [blame] | 425 | return |
| 426 | fi |
| 427 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 428 | if [ -f "src/mainboard/${board_srcdir}/abuild.disabled" ]; then |
| 429 | echo "${BUILD_NAME} disabled:" |
| 430 | cat "src/mainboard/${board_srcdir}/abuild.disabled" |
Patrick Georgi | 3ac3c4eb | 2015-07-14 20:20:13 +0200 | [diff] [blame] | 431 | return |
| 432 | fi |
| 433 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 434 | if [ "$quiet" == "false" ]; then echo "Building $BUILD_NAME"; fi |
| 435 | mkdir -p "$TARGET/${BUILD_NAME}" "$TARGET/abuild" |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 436 | ABSPATH="$(cd "$TARGET/abuild" && pwd)" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 437 | XMLFILE="$ABSPATH/${BUILD_NAME}.xml" |
| 438 | rm -f "${XMLFILE}" |
| 439 | |
| 440 | stime=$(perl -e 'print time();' 2>/dev/null || date +%s) |
| 441 | create_buildenv "$BUILD_NAME" "$build_dir" "$config_file" |
| 442 | local BUILDENV_CREATED=$? |
| 443 | |
| 444 | check_config "$build_dir" "mainboard" "CONFIG_BOARD_${MAINBOARD}=y" |
| 445 | local MAINBOARD_OK=$? |
| 446 | |
| 447 | check_config "$build_dir" "vendor" "CONFIG_VENDOR_$(mainboard_vendor "${MAINBOARD}")=y" |
| 448 | local VENDOR_OK=$? |
| 449 | |
| 450 | if [ $BUILDENV_CREATED -ne 0 ] || [ $MAINBOARD_OK -ne 0 ] || [ $VENDOR_OK -ne 0 ]; then |
Martin Roth | 16c49b5 | 2017-05-23 22:06:30 -0600 | [diff] [blame] | 451 | junit " <testcase classname='board${testclass/#/.}' name='$BUILD_NAME' >" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 452 | |
| 453 | junit "<failure type='BuildFailed'>" |
| 454 | junitfile "$build_dir/config.log" |
| 455 | junit "</failure>" |
| 456 | printf "failed\n" > compile.status |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 457 | printf "%s build configuration FAILED!\nLog excerpt:\n" "$BUILD_NAME" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 458 | tail -n $CONTEXT "$build_dir/config.log" 2> /dev/null || tail -$CONTEXT "$build_dir/config.log" |
| 459 | |
| 460 | junit "</testcase>" |
Martin Roth | d16022b | 2017-06-25 14:21:09 -0600 | [diff] [blame] | 461 | echo "$BUILD_NAME - Log: ${TOP}/$build_dir/config.log" >> "$FAILED_BOARDS" |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 462 | return |
| 463 | fi |
Stefan Reinauer | 192b7bc | 2006-05-27 00:22:02 +0000 | [diff] [blame] | 464 | |
Martin Roth | 5b7c6f5 | 2018-07-22 10:54:11 -0600 | [diff] [blame] | 465 | required_arches=$(grep -E "^CONFIG_ARCH_(BOOTBLOCK|R.MSTAGE|VERSTAGE)" "$TARGET/${BUILD_NAME}/config.build" | \ |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 466 | sed "s,^CONFIG_ARCH_[^_]*_\([^=]*\)=.*$,\1," |sort -u |tr 'A-Z\n\r' 'a-z ') |
| 467 | # shellcheck disable=SC2016,SC2059 |
Arthur Heymans | 4dfb5f1 | 2018-06-13 22:30:10 +0200 | [diff] [blame] | 468 | missing_arches=$(printf 'include .xcompile\nall: ; @echo $(foreach arch,'"$required_arches"',$(if $(filter $(arch),$(SUBARCH_SUPPORTED)),,$(arch)))' | $MAKE --no-print-directory -f -) |
Patrick Georgi | 02802df | 2014-10-18 11:57:11 +0200 | [diff] [blame] | 469 | if [ -n "$missing_arches" ]; then |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 470 | printf "skipping %s because we're missing compilers for (%s)\n" "$BUILD_NAME" "$missing_arches" |
Patrick Georgi | 02802df | 2014-10-18 11:57:11 +0200 | [diff] [blame] | 471 | return |
| 472 | fi |
| 473 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 474 | if [ $BUILDENV_CREATED -eq 0 ] && [ $configureonly -eq 0 ]; then |
Patrick Georgi | fadbe5f | 2014-05-17 18:26:38 +0200 | [diff] [blame] | 475 | BUILDPREFIX= |
Patrick Georgi | 1cd76e7 | 2010-04-19 20:39:22 +0000 | [diff] [blame] | 476 | if [ "$scanbuild" = "true" ]; then |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 477 | scanbuild_out=$TARGET/${BUILD_NAME}-scanbuild |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 478 | rm -rf "${scanbuild_out}" |
Martin Roth | 21e09b1 | 2018-07-22 10:11:26 -0600 | [diff] [blame] | 479 | BUILDPREFIX="scan-build ${SCANBUILD_ARGS} -o ${scanbuild_out}tmp" |
Patrick Georgi | 1cd76e7 | 2010-04-19 20:39:22 +0000 | [diff] [blame] | 480 | fi |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 481 | compile_target "${BUILD_NAME}" |
Patrick Georgi | d229677 | 2009-03-11 15:43:02 +0000 | [diff] [blame] | 482 | if [ "$scanbuild" = "true" ]; then |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 483 | mv "${scanbuild_out}"tmp/* "${scanbuild_out}" |
| 484 | rmdir "${scanbuild_out}tmp" |
Patrick Georgi | d229677 | 2009-03-11 15:43:02 +0000 | [diff] [blame] | 485 | fi |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 486 | fi |
Stefan Reinauer | 2f285ae | 2004-11-05 14:06:24 +0000 | [diff] [blame] | 487 | |
Patrick Georgi | 140a990 | 2011-06-03 21:56:13 +0200 | [diff] [blame] | 488 | junit "</testcase>" |
Stefan Reinauer | 3a14057 | 2006-10-25 19:02:34 +0000 | [diff] [blame] | 489 | } |
| 490 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 491 | # One target may build several configs |
| 492 | function build_target |
| 493 | { |
| 494 | local MAINBOARD=$1 |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 495 | local MAINBOARD_LC |
| 496 | MAINBOARD_LC=$(echo "$MAINBOARD" | tr '[:upper:]' '[:lower:]') |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 497 | |
| 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 |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 500 | for config in "$configdir/config.${MAINBOARD_LC}"*; do |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 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" |
| 508 | |
| 509 | done |
| 510 | else |
| 511 | echo "Building board $MAINBOARD (using default config)" |
| 512 | build_dir=$TARGET/${MAINBOARD} |
| 513 | |
| 514 | build_config "$MAINBOARD" "$build_dir" "$MAINBOARD" |
| 515 | remove_target "$MAINBOARD" |
| 516 | fi |
| 517 | |
| 518 | } |
| 519 | |
Uwe Hermann | 4e00640 | 2009-04-15 16:07:27 +0000 | [diff] [blame] | 520 | function remove_target |
| 521 | { |
| 522 | if [ "$remove" != "true" ]; then |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 523 | return |
Uwe Hermann | 4e00640 | 2009-04-15 16:07:27 +0000 | [diff] [blame] | 524 | fi |
| 525 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 526 | local BUILD_NAME=$1 |
Uwe Hermann | 4e00640 | 2009-04-15 16:07:27 +0000 | [diff] [blame] | 527 | |
| 528 | # Save the generated coreboot.rom file of each board. |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 529 | if [ -r "$TARGET/${BUILD_NAME}/coreboot.rom" ]; then |
| 530 | cp "$TARGET/${BUILD_NAME}/coreboot.rom" \ |
| 531 | "${BUILD_NAME}_coreboot.rom" |
Uwe Hermann | 4e00640 | 2009-04-15 16:07:27 +0000 | [diff] [blame] | 532 | fi |
| 533 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 534 | echo "Removing build dir for $BUILD_NAME..." |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 535 | rm -rf "${TARGET:?}/${BUILD_NAME}" |
Uwe Hermann | 4e00640 | 2009-04-15 16:07:27 +0000 | [diff] [blame] | 536 | |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 537 | return |
Uwe Hermann | 4e00640 | 2009-04-15 16:07:27 +0000 | [diff] [blame] | 538 | } |
| 539 | |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 540 | function myhelp |
| 541 | { |
Patrick Georgi | 86980bb | 2015-07-31 16:14:43 +0200 | [diff] [blame] | 542 | cat << __END_OF_HELP |
Martin Roth | 5b0d2db | 2016-12-06 09:18:36 -0700 | [diff] [blame] | 543 | Usage: $0 [options] |
Patrick Georgi | 86980bb | 2015-07-31 16:14:43 +0200 | [diff] [blame] | 544 | $0 [-V|--version] |
| 545 | $0 [-h|--help] |
Stefan Reinauer | ca63120 | 2006-11-10 13:30:28 +0000 | [diff] [blame] | 546 | |
Patrick Georgi | 86980bb | 2015-07-31 16:14:43 +0200 | [diff] [blame] | 547 | Options:\n" |
Martin Roth | b06bfa4 | 2016-12-05 09:15:33 -0700 | [diff] [blame] | 548 | [-a|--all] Build previously succeeded ports as well |
Damien Zammit | b40c72a | 2017-09-02 15:02:04 +1000 | [diff] [blame] | 549 | [-A|--any-toolchain] Use any toolchain |
Furquan Shaikh | 57ccb9c | 2018-06-23 01:00:32 -0700 | [diff] [blame] | 550 | [-b|--board-variant <name>] Build specific board variant under the |
| 551 | given target. |
Patrick Georgi | 86980bb | 2015-07-31 16:14:43 +0200 | [diff] [blame] | 552 | [-B|--blobs] Allow using binary files |
Martin Roth | c7e6ad7 | 2017-03-26 18:23:51 -0600 | [diff] [blame] | 553 | [--checksum <path/basefile>] Store checksums at path/basefile |
Martin Roth | b06bfa4 | 2016-12-05 09:15:33 -0700 | [diff] [blame] | 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 |
Martin Roth | ba973bd | 2017-07-19 14:13:07 -0600 | [diff] [blame] | 557 | [-e|--exitcode] Exit with a non-zero errorlevel on failure |
Martin Roth | b06bfa4 | 2016-12-05 09:15:33 -0700 | [diff] [blame] | 558 | [-J|--junit] Write JUnit formatted xml log file |
| 559 | [-K|--kconfig <name>] Prepend file to generated Kconfig |
| 560 | [-l|--loglevel <num>] Set loglevel |
Patrick Georgi | 86980bb | 2015-07-31 16:14:43 +0200 | [diff] [blame] | 561 | [-L|--clang] Use clang |
Martin Roth | b06bfa4 | 2016-12-05 09:15:33 -0700 | [diff] [blame] | 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 |
Martin Roth | 5b0d2db | 2016-12-06 09:18:36 -0700 | [diff] [blame] | 568 | [-R|--root <path>] Absolute path to coreboot sources |
| 569 | (defaults to $ROOT) |
Martin Roth | b06bfa4 | 2016-12-05 09:15:33 -0700 | [diff] [blame] | 570 | [--scan-build] Use clang's static analyzer |
Martin Roth | 3331426 | 2017-03-27 23:45:31 -0600 | [diff] [blame] | 571 | [--timeless] Generate timeless builds |
Martin Roth | b06bfa4 | 2016-12-05 09:15:33 -0700 | [diff] [blame] | 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 |
Patrick Georgi | 86980bb | 2015-07-31 16:14:43 +0200 | [diff] [blame] | 576 | [-x|--chromeos] Build with CHROMEOS enabled |
Patrick Georgi | f43b06d | 2015-07-31 16:26:19 +0200 | [diff] [blame] | 577 | Skip boards without Chrome OS support |
Martin Roth | b06bfa4 | 2016-12-05 09:15:33 -0700 | [diff] [blame] | 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 |
| 582 | |
Martin Roth | b06bfa4 | 2016-12-05 09:15:33 -0700 | [diff] [blame] | 583 | [-V|--version] Print version number and exit |
| 584 | [-h|--help] Print this help and exit |
Patrick Georgi | 86980bb | 2015-07-31 16:14:43 +0200 | [diff] [blame] | 585 | |
Patrick Georgi | 55ea013 | 2017-06-27 14:02:18 +0200 | [diff] [blame] | 586 | [-s|--silent] obsolete |
Patrick Georgi | 86980bb | 2015-07-31 16:14:43 +0200 | [diff] [blame] | 587 | __END_OF_HELP |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 588 | } |
| 589 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 590 | function myversion |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 591 | { |
| 592 | cat << EOF |
| 593 | |
Stefan Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 594 | coreboot autobuild v$ABUILD_VERSION ($ABUILD_DATE) |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 595 | |
Stefan Reinauer | 192b7bc | 2006-05-27 00:22:02 +0000 | [diff] [blame] | 596 | Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org> |
Stefan Reinauer | 68003b8 | 2010-01-30 10:44:28 +0000 | [diff] [blame] | 597 | Copyright (C) 2006-2010 by coresystems GmbH <info@coresystems.de> |
Stefan Reinauer | 3a14057 | 2006-10-25 19:02:34 +0000 | [diff] [blame] | 598 | |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 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 |
| 601 | warranty. |
| 602 | |
| 603 | EOF |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | # default options |
| 607 | target="" |
| 608 | buildall=false |
Stefan Reinauer | 173f13b | 2004-11-05 11:57:00 +0000 | [diff] [blame] | 609 | verbose=false |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 610 | |
Patrick Georgi | 7e8c9aa | 2010-04-08 11:37:43 +0000 | [diff] [blame] | 611 | test -f util/sconfig/sconfig.l && ROOT=$( pwd ) |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 612 | test -f ../util/sconfig/sconfig.l && ROOT=$( cd .. && pwd ) |
| 613 | test "$ROOT" = "" && ROOT=$( cd ../.. && pwd ) |
Stefan Reinauer | 0d4a08e | 2009-07-01 12:26:11 +0000 | [diff] [blame] | 614 | |
Patrick Georgi | 92cfe18 | 2012-04-05 11:17:01 +0200 | [diff] [blame] | 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 |
| 618 | |
Julius Werner | 893eda0 | 2017-03-20 15:33:23 -0700 | [diff] [blame] | 619 | # Save command line for xargs parallelization. |
| 620 | cmdline=("$@") |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 621 | |
Stefan Reinauer | 02a4e7f | 2008-05-27 18:29:26 +0000 | [diff] [blame] | 622 | # parse parameters.. try to find out whether we're running GNU getopt |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 623 | getoptbrand="$(getopt -V)" |
| 624 | |
| 625 | # shellcheck disable=SC2086 |
Stefan Reinauer | 39d4e5f | 2008-05-28 08:40:23 +0000 | [diff] [blame] | 626 | if [ "${getoptbrand:0:6}" == "getopt" ]; then |
| 627 | # Detected GNU getopt that supports long options. |
Furquan Shaikh | 57ccb9c | 2018-06-23 01:00:32 -0700 | [diff] [blame] | 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 |
Warren Turkal | 0e8f204 | 2010-09-27 21:14:19 +0000 | [diff] [blame] | 629 | eval set -- $args |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 630 | retval=$? |
Stefan Reinauer | 02a4e7f | 2008-05-27 18:29:26 +0000 | [diff] [blame] | 631 | else |
| 632 | # Detected non-GNU getopt |
Furquan Shaikh | 57ccb9c | 2018-06-23 01:00:32 -0700 | [diff] [blame] | 633 | args=$(getopt Vvqhat:b:p:c:sJCl:rP:uyBLAzo:xX:K:d:R:Ie "$@") |
Stefan Reinauer | 02a4e7f | 2008-05-27 18:29:26 +0000 | [diff] [blame] | 634 | set -- $args |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 635 | retval=$? |
Stefan Reinauer | 02a4e7f | 2008-05-27 18:29:26 +0000 | [diff] [blame] | 636 | fi |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 637 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 638 | if [ $retval != 0 ]; then |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 639 | myhelp |
| 640 | exit 1 |
| 641 | fi |
| 642 | |
Patrick Georgi | f43b06d | 2015-07-31 16:26:19 +0200 | [diff] [blame] | 643 | chromeos=false |
Patrick Georgi | b0bc63b | 2014-05-21 22:47:05 +0200 | [diff] [blame] | 644 | clean_work=false |
Patrick Georgi | 55ea013 | 2017-06-27 14:02:18 +0200 | [diff] [blame] | 645 | verboseopt='V=0' |
Patrick Georgi | 64d9a77 | 2012-05-01 15:14:46 +0200 | [diff] [blame] | 646 | customizing="" |
| 647 | configoptions="" |
Patrick Georgi | 098c4a8 | 2015-09-15 16:57:04 +0200 | [diff] [blame] | 648 | # testclass needs to be undefined if not used for variable expansion to work |
| 649 | unset testclass |
Eric Biederman | c149210 | 2004-11-05 08:50:54 +0000 | [diff] [blame] | 650 | while true ; do |
Eric Biederman | ca883c9 | 2004-11-05 11:24:57 +0000 | [diff] [blame] | 651 | case "$1" in |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 652 | -J|--junit) shift; mode=junit; rm -f "$XMLFILE" ;; |
Stefan Reinauer | 2f285ae | 2004-11-05 14:06:24 +0000 | [diff] [blame] | 653 | -t|--target) shift; target="$1"; shift;; |
Furquan Shaikh | 57ccb9c | 2018-06-23 01:00:32 -0700 | [diff] [blame] | 654 | -b|--board-variant) shift; variant="$1"; shift;; |
Eric Biederman | c149210 | 2004-11-05 08:50:54 +0000 | [diff] [blame] | 655 | -a|--all) shift; buildall=true;; |
Martin Roth | 26174c9 | 2016-11-23 18:47:53 -0700 | [diff] [blame] | 656 | -d|--dir) shift; configdir="$1"; shift;; |
Martin Roth | ba973bd | 2017-07-19 14:13:07 -0600 | [diff] [blame] | 657 | -e|--exitcode) shift; exitcode=1;; |
Warren Turkal | 0e8f204 | 2010-09-27 21:14:19 +0000 | [diff] [blame] | 658 | -r|--remove) shift; remove=true;; |
Patrick Georgi | 55ea013 | 2017-06-27 14:02:18 +0200 | [diff] [blame] | 659 | -v|--verbose) shift; verbose=true; verboseopt='V=1';; |
Martin Roth | ddb7a9d | 2014-12-08 01:57:52 -0700 | [diff] [blame] | 660 | -q|--quiet) shift; quiet=true;; |
Stefan Reinauer | d4c6846 | 2004-11-05 11:47:41 +0000 | [diff] [blame] | 661 | -V|--version) shift; myversion; exit 0;; |
Stefan Reinauer | 3a14057 | 2006-10-25 19:02:34 +0000 | [diff] [blame] | 662 | -h|--help) shift; myversion; myhelp; exit 0;; |
Stefan Reinauer | 7fe2b7c | 2006-09-15 17:00:11 +0000 | [diff] [blame] | 663 | -p|--payloads) shift; payloads="$1"; shift;; |
Arthur Heymans | 4dfb5f1 | 2018-06-13 22:30:10 +0200 | [diff] [blame] | 664 | -R|--root) shift; ROOT="$1"; MAKE="$MAKE -C $1"; shift;; |
Patrick Georgi | 64d9a77 | 2012-05-01 15:14:46 +0200 | [diff] [blame] | 665 | -c|--cpus) shift |
| 666 | export MAKEFLAGS="-j $1" |
Patrick Georgi | 5895551 | 2013-12-05 19:53:04 +0100 | [diff] [blame] | 667 | cpus=$1 |
Martin Roth | ddb7a9d | 2014-12-08 01:57:52 -0700 | [diff] [blame] | 668 | test "$MAKEFLAGS" == "-j max" && export MAKEFLAGS="-j" && cpuconfig=" in parallel" |
| 669 | test "$1" == "1" && cpuconfig=" on 1 cpu" |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 670 | expr "$1" : '-\?[0-9]\+$' > /dev/null && test "0$1" -gt 1 && cpuconfig=" on $1 cpus in parallel" |
Patrick Georgi | 64d9a77 | 2012-05-01 15:14:46 +0200 | [diff] [blame] | 671 | shift;; |
Patrick Georgi | 55ea013 | 2017-06-27 14:02:18 +0200 | [diff] [blame] | 672 | # obsolete option |
| 673 | -s|--silent) shift;; |
Patrick Georgi | fadbe5f | 2014-05-17 18:26:38 +0200 | [diff] [blame] | 674 | --scan-build) shift |
Patrick Georgi | 64d9a77 | 2012-05-01 15:14:46 +0200 | [diff] [blame] | 675 | scanbuild=true |
| 676 | customizing="${customizing}, scan-build" |
Martin Roth | 21e09b1 | 2018-07-22 10:11:26 -0600 | [diff] [blame] | 677 | SCANBUILD_ARGS=${SCANBUILD_ARGS:-'-k'} |
Patrick Georgi | 64d9a77 | 2012-05-01 15:14:46 +0200 | [diff] [blame] | 678 | ;; |
| 679 | -y|--ccache) shift |
| 680 | customizing="${customizing}, ccache" |
| 681 | configoptions="${configoptions}CONFIG_CCACHE=y\n" |
| 682 | ;; |
Stefan Reinauer | cc44b06 | 2009-03-11 15:00:50 +0000 | [diff] [blame] | 683 | -C|--config) shift; configureonly=1;; |
Patrick Georgi | 64d9a77 | 2012-05-01 15:14:46 +0200 | [diff] [blame] | 684 | -l|--loglevel) shift |
| 685 | customizing="${customizing}, loglevel $1" |
Patrick Georgi | 64d9a77 | 2012-05-01 15:14:46 +0200 | [diff] [blame] | 686 | configoptions="${configoptions}CONFIG_DEFAULT_CONSOLE_LOGLEVEL_$1=y\n" |
| 687 | configoptions="${configoptions}CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$1\n" |
| 688 | shift;; |
| 689 | -u|--update) shift |
| 690 | customizing="${customizing}, update" |
| 691 | configoptions="${configoptions}CONFIG_UPDATE_IMAGE=y\n" |
| 692 | ;; |
| 693 | -P|--prefix) shift |
| 694 | customizing="${customizing}, cbfs prefix $1" |
| 695 | configoptions="${configoptions}CONFIG_CBFS_PREFIX=\"$1\"" |
| 696 | shift;; |
| 697 | -B|--blobs) shift |
| 698 | customizing="${customizing}, blobs" |
Patrick Georgi | c366f90 | 2018-09-27 21:24:44 +0200 | [diff] [blame] | 699 | configoptions="${configoptions}CONFIG_USE_BLOBS=y\nCONFIG_ADD_FSP_BINARIES=y\nCONFIG_FSP_USE_REPO=y\n" |
Patrick Georgi | 64d9a77 | 2012-05-01 15:14:46 +0200 | [diff] [blame] | 700 | ;; |
Damien Zammit | b40c72a | 2017-09-02 15:02:04 +1000 | [diff] [blame] | 701 | -A|--any-toolchain) shift |
| 702 | customizing="${customizing}, any-toolchain" |
| 703 | configoptions="${configoptions}CONFIG_ANY_TOOLCHAIN=y\n" |
| 704 | ;; |
Patrick Georgi | e9fe654 | 2014-05-14 13:43:58 +0200 | [diff] [blame] | 705 | -L|--clang) shift |
| 706 | customizing="${customizing}, clang" |
Patrick Georgi | 02ac6c3 | 2014-11-28 23:08:51 +0100 | [diff] [blame] | 707 | configoptions="${configoptions}CONFIG_COMPILER_LLVM_CLANG=y\n# CONFIG_COMPILER_GCC is not set\n" |
Patrick Georgi | e9fe654 | 2014-05-14 13:43:58 +0200 | [diff] [blame] | 708 | ;; |
Patrick Georgi | b0bc63b | 2014-05-21 22:47:05 +0200 | [diff] [blame] | 709 | -z|--clean) shift |
| 710 | customizing="${customizing}, clean" |
| 711 | clean_work=true |
| 712 | ;; |
Patrick Georgi | ad27322 | 2014-05-21 23:00:32 +0200 | [diff] [blame] | 713 | -o|--outdir) shift |
| 714 | TARGET=$1; shift |
| 715 | ;; |
Patrick Georgi | dd78736 | 2015-04-22 18:38:10 +0200 | [diff] [blame] | 716 | -x|--chromeos) shift |
Patrick Georgi | f43b06d | 2015-07-31 16:26:19 +0200 | [diff] [blame] | 717 | chromeos=true |
Patrick Georgi | 58474df | 2015-07-31 16:30:04 +0200 | [diff] [blame] | 718 | testclass=chromeos |
Patrick Georgi | f43b06d | 2015-07-31 16:26:19 +0200 | [diff] [blame] | 719 | customizing="${customizing}, chrome os" |
Patrick Georgi | dd78736 | 2015-04-22 18:38:10 +0200 | [diff] [blame] | 720 | configoptions="${configoptions}CONFIG_CHROMEOS=y\n" |
| 721 | ;; |
Martin Roth | 21ca9be | 2015-10-13 12:27:56 -0600 | [diff] [blame] | 722 | -X|--xmlfile) shift; XMLFILE=$1; REAL_XMLFILE=$1; shift;; |
Martin Roth | 047c2f4 | 2016-12-14 10:16:26 -0700 | [diff] [blame] | 723 | -I|--recursive) shift; recursive=true;; |
Martin Roth | 1000810 | 2016-03-09 13:12:10 -0700 | [diff] [blame] | 724 | -K|--kconfig) shift |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 725 | testclass="$(basename "$1" | tr '.' '_' )" |
Martin Roth | 1000810 | 2016-03-09 13:12:10 -0700 | [diff] [blame] | 726 | customizing="${customizing}, $1 config" |
| 727 | configoptions="$(cat "$1")${configoptions}\n" |
| 728 | shift;; |
Martin Roth | c7e6ad7 | 2017-03-26 18:23:51 -0600 | [diff] [blame] | 729 | --checksum) shift; checksum_file="$1"; shift;; |
Martin Roth | 3331426 | 2017-03-27 23:45:31 -0600 | [diff] [blame] | 730 | --timeless) shift; TIMELESS=1;; |
Eric Biederman | c149210 | 2004-11-05 08:50:54 +0000 | [diff] [blame] | 731 | --) shift; break;; |
Martin Roth | 9fdb41a | 2016-12-06 09:51:54 -0700 | [diff] [blame] | 732 | -*) printf "Invalid option '%s'\n\n" "$1"; myhelp; exit 1;; |
Eric Biederman | ca883c9 | 2004-11-05 11:24:57 +0000 | [diff] [blame] | 733 | *) break;; |
Eric Biederman | c149210 | 2004-11-05 08:50:54 +0000 | [diff] [blame] | 734 | esac |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 735 | done |
Martin Roth | 9fdb41a | 2016-12-06 09:51:54 -0700 | [diff] [blame] | 736 | if [ -n "$1" ]; then |
| 737 | printf "Invalid option '%s'\n\n" "$1"; myhelp; exit 1; |
| 738 | fi |
Stefan Reinauer | 9f12caa | 2004-10-19 07:00:47 +0000 | [diff] [blame] | 739 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 740 | if [ -z "$TARGET" ] || [ "$TARGET" = "/" ]; then |
Patrick Georgi | ad27322 | 2014-05-21 23:00:32 +0200 | [diff] [blame] | 741 | echo "Please specify a valid, non-root build directory." |
| 742 | exit 1 |
| 743 | fi |
| 744 | |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 745 | customizing=$(echo "$customizing" | cut -c3-) |
Patrick Georgi | 64d9a77 | 2012-05-01 15:14:46 +0200 | [diff] [blame] | 746 | if [ "$customizing" = "" ]; then |
| 747 | customizing="default configuration" |
| 748 | fi |
| 749 | |
Martin Roth | 7a98591 | 2018-07-22 10:31:19 -0600 | [diff] [blame] | 750 | FAILED_BOARDS="${TARGET}/failed_boards" |
| 751 | PASSED_BOARDS="${TARGET}/passing_boards" |
Martin Roth | 047c2f4 | 2016-12-14 10:16:26 -0700 | [diff] [blame] | 752 | |
| 753 | if [ "$recursive" = "false" ]; then |
Martin Roth | d16022b | 2017-06-25 14:21:09 -0600 | [diff] [blame] | 754 | rm -f "$FAILED_BOARDS" "$PASSED_BOARDS" |
Martin Roth | 047c2f4 | 2016-12-14 10:16:26 -0700 | [diff] [blame] | 755 | fi |
| 756 | |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 757 | USE_XARGS=0 |
Patrick Georgi | f49f7c8 | 2011-11-05 12:55:18 +0100 | [diff] [blame] | 758 | if [ "$cpus" != "1" ]; then |
Patrick Georgi | 5895551 | 2013-12-05 19:53:04 +0100 | [diff] [blame] | 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 |
| 763 | cpus=32 |
| 764 | fi |
Patrick Georgi | 0c65dcc | 2015-10-31 00:42:50 +0100 | [diff] [blame] | 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 |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 768 | fi |
| 769 | |
| 770 | if [ "$USE_XARGS" = "0" ]; then |
Raymond Danks | c95da25 | 2012-05-30 16:03:48 -0600 | [diff] [blame] | 771 | test "$MAKEFLAGS" == "" && test "$cpus" != "" && export MAKEFLAGS="-j $cpus" |
Patrick Georgi | 0c65dcc | 2015-10-31 00:42:50 +0100 | [diff] [blame] | 772 | build_targets() |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 773 | { |
Patrick Georgi | 0c65dcc | 2015-10-31 00:42:50 +0100 | [diff] [blame] | 774 | local targets=${*-$(get_mainboards)} |
| 775 | for MAINBOARD in $targets; do |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 776 | build_target "${MAINBOARD}" |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 777 | done |
| 778 | } |
| 779 | else |
Patrick Georgi | 0c65dcc | 2015-10-31 00:42:50 +0100 | [diff] [blame] | 780 | build_targets() |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 781 | { |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 782 | local ABSPATH |
| 783 | local stime |
| 784 | local etime |
Julius Werner | 893eda0 | 2017-03-20 15:33:23 -0700 | [diff] [blame] | 785 | local num_targets |
| 786 | local cpus_per_target |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 787 | |
Patrick Georgi | 0c65dcc | 2015-10-31 00:42:50 +0100 | [diff] [blame] | 788 | local targets=${*-$(get_mainboards)} |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 789 | # seed shared utils |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 790 | TMPCFG=$(mktemp) |
| 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 |
Patrick Georgi | fadbe5f | 2014-05-17 18:26:38 +0200 | [diff] [blame] | 795 | BUILDPREFIX= |
| 796 | if [ "$scanbuild" = "true" ]; then |
| 797 | scanbuild_out=$TARGET/sharedutils-scanbuild |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 798 | rm -rf "${scanbuild_out}" |
Patrick Georgi | fadbe5f | 2014-05-17 18:26:38 +0200 | [diff] [blame] | 799 | BUILDPREFIX="scan-build -o ${scanbuild_out}tmp" |
| 800 | fi |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 801 | mkdir -p "$TARGET/abuild" |
| 802 | ABSPATH="$(cd "$TARGET/abuild" && pwd)" |
| 803 | local XMLFILE="$ABSPATH/__util.xml" |
| 804 | rm -f "${XMLFILE}" |
| 805 | stime=$(perl -e 'print time();' 2>/dev/null || date +%s) |
Martin Roth | 5b7c6f5 | 2018-07-22 10:54:11 -0600 | [diff] [blame] | 806 | $BUILDPREFIX "$MAKE" -j "$cpus" DOTCONFIG="$TMPCFG" obj="$TARGET/temp" objutil="$TARGET/sharedutils" tools > "$TARGET/sharedutils/make.log" 2>&1 |
Patrick Georgi | 053322f | 2015-09-15 17:30:52 +0200 | [diff] [blame] | 807 | local ret=$? |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 808 | etime=$(perl -e 'print time();' 2>/dev/null || date +%s) |
| 809 | local duration=$(( etime - stime )) |
Patrick Georgi | 053322f | 2015-09-15 17:30:52 +0200 | [diff] [blame] | 810 | |
| 811 | junit " <testcase classname='util' name='all' time='$duration' >" |
| 812 | if [ $ret -eq 0 ]; then |
| 813 | junit "<system-out>" |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 814 | junitfile "$TARGET/sharedutils/make.log" |
Patrick Georgi | 053322f | 2015-09-15 17:30:52 +0200 | [diff] [blame] | 815 | junit "</system-out>" |
| 816 | junit "</testcase>" |
| 817 | else |
| 818 | junit "<failure type='BuildFailed'>" |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 819 | junitfile "$TARGET/sharedutils/make.log" |
Patrick Georgi | 053322f | 2015-09-15 17:30:52 +0200 | [diff] [blame] | 820 | junit "</failure>" |
| 821 | junit "</testcase>" |
Martin Roth | 6228b9e | 2017-07-16 17:02:47 -0700 | [diff] [blame] | 822 | echo "Shared Utilities - Log: $TARGET/sharedutils/make.log" >> "$FAILED_BOARDS" |
Patrick Georgi | 053322f | 2015-09-15 17:30:52 +0200 | [diff] [blame] | 823 | return |
| 824 | fi |
| 825 | |
Patrick Georgi | fadbe5f | 2014-05-17 18:26:38 +0200 | [diff] [blame] | 826 | if [ "$scanbuild" = "true" ]; then |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 827 | mv "${scanbuild_out}tmp/"* "${scanbuild_out}" |
| 828 | rmdir "${scanbuild_out}tmp" |
Patrick Georgi | fadbe5f | 2014-05-17 18:26:38 +0200 | [diff] [blame] | 829 | fi |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 830 | rm -rf "$TARGET/temp" "$TMPCFG" |
Julius Werner | 893eda0 | 2017-03-20 15:33:23 -0700 | [diff] [blame] | 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 |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 834 | } |
Patrick Georgi | f49f7c8 | 2011-11-05 12:55:18 +0100 | [diff] [blame] | 835 | fi |
| 836 | |
Patrick Georgi | 140a990 | 2011-06-03 21:56:13 +0200 | [diff] [blame] | 837 | junit '<?xml version="1.0" encoding="utf-8"?>' |
| 838 | junit '<testsuite>' |
| 839 | |
Stefan Reinauer | 3779f6a | 2004-11-05 00:26:31 +0000 | [diff] [blame] | 840 | if [ "$target" != "" ]; then |
Eric Biederman | 709850a | 2004-11-05 10:48:04 +0000 | [diff] [blame] | 841 | # build a single board |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 842 | MAINBOARD=$(normalize_target "${target}") |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 843 | if [ -z "${MAINBOARD}" ]; then |
Furquan Shaikh | 57ccb9c | 2018-06-23 01:00:32 -0700 | [diff] [blame] | 844 | printf "No such target: %s" "${target}" |
| 845 | if [ -n "${variant}" ]; then |
| 846 | printf ", variant: %s" "${variant}" |
| 847 | fi |
| 848 | printf "\n" |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 849 | exit 1 |
| 850 | fi |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 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}" |
Patrick Georgi | c2050f0 | 2015-10-31 00:35:44 +0100 | [diff] [blame] | 856 | exit 1 |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 857 | else |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 858 | build_target "${MAINBOARD}" |
Patrick Georgi | a0e7738 | 2015-09-15 19:32:28 +0200 | [diff] [blame] | 859 | test "$mode" != "text" && \ |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 860 | test -f "$TARGET/abuild/${MAINBOARD}.xml" && \ |
| 861 | cat "$TARGET/abuild/${MAINBOARD}.xml" >> "$REAL_XMLFILE" |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 862 | XMLFILE=$REAL_XMLFILE |
Stefan Reinauer | 002c9ff | 2010-03-29 16:23:42 +0000 | [diff] [blame] | 863 | fi |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 864 | else |
Patrick Georgi | 0c65dcc | 2015-10-31 00:42:50 +0100 | [diff] [blame] | 865 | build_targets |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 866 | rm -f "$REAL_XMLFILE" |
| 867 | XMLFILE="$REAL_XMLFILE" |
Patrick Georgi | 43105d6 | 2011-11-05 14:44:41 +0100 | [diff] [blame] | 868 | junit '<?xml version="1.0" encoding="utf-8"?>' |
| 869 | junit '<testsuite>' |
Patrick Georgi | 3fd44c3 | 2011-11-07 19:01:54 +0100 | [diff] [blame] | 870 | if [ "$mode" != "text" ]; then |
Patrick Georgi | d03d69b | 2013-12-19 20:13:23 +0100 | [diff] [blame] | 871 | for xmlfile in $TARGET/abuild/*_*.xml; do |
Martin Roth | 02c93b9 | 2016-11-30 16:32:20 -0700 | [diff] [blame] | 872 | cat "$xmlfile" >> "$REAL_XMLFILE" |
Patrick Georgi | 3fd44c3 | 2011-11-07 19:01:54 +0100 | [diff] [blame] | 873 | done |
| 874 | fi |
Patrick Georgi | 3db85f3 | 2011-11-05 13:21:14 +0100 | [diff] [blame] | 875 | XMLFILE=$REAL_XMLFILE |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 876 | fi |
Patrick Georgi | 140a990 | 2011-06-03 21:56:13 +0200 | [diff] [blame] | 877 | junit '</testsuite>' |
Stefan Reinauer | d87ce96 | 2004-11-05 00:25:19 +0000 | [diff] [blame] | 878 | |
Martin Roth | 047c2f4 | 2016-12-14 10:16:26 -0700 | [diff] [blame] | 879 | if [ "$recursive" = "false" ]; then |
| 880 | |
Martin Roth | d16022b | 2017-06-25 14:21:09 -0600 | [diff] [blame] | 881 | # Print the list of failed configurations |
Martin Roth | 047c2f4 | 2016-12-14 10:16:26 -0700 | [diff] [blame] | 882 | if [ -f "$FAILED_BOARDS" ]; then |
Martin Roth | d16022b | 2017-06-25 14:21:09 -0600 | [diff] [blame] | 883 | printf "%s configuration(s) failed:\n" "$( wc -l < "$FAILED_BOARDS" )" |
Martin Roth | 047c2f4 | 2016-12-14 10:16:26 -0700 | [diff] [blame] | 884 | cat "$FAILED_BOARDS" |
Martin Roth | d16022b | 2017-06-25 14:21:09 -0600 | [diff] [blame] | 885 | echo |
Martin Roth | ba973bd | 2017-07-19 14:13:07 -0600 | [diff] [blame] | 886 | if [ "$exitcode" != "0" ]; then |
| 887 | failed=1 |
| 888 | fi |
Martin Roth | 047c2f4 | 2016-12-14 10:16:26 -0700 | [diff] [blame] | 889 | else |
Martin Roth | d16022b | 2017-06-25 14:21:09 -0600 | [diff] [blame] | 890 | printf "All %s tested configurations passed.\n" "$( wc -l < "$PASSED_BOARDS" )" |
Martin Roth | 047c2f4 | 2016-12-14 10:16:26 -0700 | [diff] [blame] | 891 | fi |
| 892 | fi |
| 893 | |
Patrick Georgi | f9d19f2 | 2011-06-01 19:29:48 +0000 | [diff] [blame] | 894 | exit $failed |