2019-08-10 23:57:26 +08:00
|
|
|
#!/usr/bin/env bash
|
2020-01-20 01:03:11 +08:00
|
|
|
# tools/testbuild.sh
|
2015-07-01 04:38:01 +08:00
|
|
|
#
|
2020-01-24 22:12:20 +08:00
|
|
|
# Copyright (C) 2016-2020 Gregory Nutt. All rights reserved.
|
2015-07-01 04:38:01 +08:00
|
|
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in
|
|
|
|
# the documentation and/or other materials provided with the
|
|
|
|
# distribution.
|
|
|
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
# used to endorse or promote products derived from this software
|
|
|
|
# without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
|
2020-02-10 11:47:03 +08:00
|
|
|
WD=$(cd $(dirname $0) && cd .. && pwd)
|
2015-07-01 04:38:01 +08:00
|
|
|
nuttx=$WD/../nuttx
|
|
|
|
|
|
|
|
progname=$0
|
2020-01-21 17:53:06 +08:00
|
|
|
fail=0
|
2020-02-10 11:47:03 +08:00
|
|
|
APPSDIR=$WD/../apps
|
2020-01-21 17:53:06 +08:00
|
|
|
MAKE_FLAGS=-k
|
2020-04-10 11:15:46 +08:00
|
|
|
EXTRA_FLAGS=
|
2017-06-11 00:12:37 +08:00
|
|
|
MAKE=make
|
2015-07-01 04:38:01 +08:00
|
|
|
unset testfile
|
2020-01-20 01:29:34 +08:00
|
|
|
unset HOPTION
|
2019-10-03 21:52:16 +08:00
|
|
|
unset JOPTION
|
2020-04-01 12:19:07 +08:00
|
|
|
PRINTLISTONLY=0
|
2020-04-03 10:35:30 +08:00
|
|
|
GITCLEAN=0
|
2015-07-01 04:38:01 +08:00
|
|
|
|
|
|
|
function showusage {
|
2020-01-06 00:29:59 +08:00
|
|
|
echo ""
|
2020-04-10 11:15:46 +08:00
|
|
|
echo "USAGE: $progname [-l|m|c|u|g|n] [-d] [-e <extraflags>] [-x] [-j <ncpus>] [-a <appsdir>] [-t <topdir>] [-p] [-G] <testlist-file>"
|
2020-01-06 00:29:59 +08:00
|
|
|
echo " $progname -h"
|
|
|
|
echo ""
|
|
|
|
echo "Where:"
|
2020-01-20 01:29:34 +08:00
|
|
|
echo " -l|m|c|u|g|n selects Linux (l), macOS (m), Cygwin (c),"
|
|
|
|
echo " Ubuntu under Windows 10 (u), MSYS/MSYS2 (g) or Windows native (n). Default Linux"
|
2020-01-06 00:29:59 +08:00
|
|
|
echo " -d enables script debug output"
|
2020-04-10 11:15:46 +08:00
|
|
|
echo " -e pass extra c/c++ flags such as -Wno-cpp via make command line"
|
2020-01-06 00:29:59 +08:00
|
|
|
echo " -x exit on build failures"
|
|
|
|
echo " -j <ncpus> passed on to make. Default: No -j make option."
|
|
|
|
echo " -a <appsdir> provides the relative path to the apps/ directory. Default ../apps"
|
|
|
|
echo " -t <topdir> provides the absolute path to top nuttx/ directory. Default $PWD/../nuttx"
|
2020-04-01 12:19:07 +08:00
|
|
|
echo " -p only print the list of configs without running any builds"
|
2020-04-03 10:35:30 +08:00
|
|
|
echo " -G Use \"git clean -xfdq\" instead of \"make distclean\" to clean the tree."
|
|
|
|
echo " This option may speed up the builds. However, note that:"
|
|
|
|
echo " * This assumes that your trees are git based."
|
|
|
|
echo " * This assumes that only nuttx and apps repos need to be cleaned."
|
|
|
|
echo " * If the tree has files not managed by git, they will be removed"
|
|
|
|
echo " as well."
|
2020-01-06 00:29:59 +08:00
|
|
|
echo " -h will show this help test and terminate"
|
|
|
|
echo " <testlist-file> selects the list of configurations to test. No default"
|
|
|
|
echo ""
|
|
|
|
echo "Your PATH variable must include the path to both the build tools and the"
|
|
|
|
echo "kconfig-frontends tools"
|
|
|
|
echo ""
|
|
|
|
exit 1
|
2015-07-01 04:38:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Parse command line
|
|
|
|
|
|
|
|
while [ ! -z "$1" ]; do
|
2020-01-06 00:29:59 +08:00
|
|
|
case $1 in
|
2020-01-20 01:29:34 +08:00
|
|
|
-l | -m | -c | -u | -g | -n )
|
|
|
|
HOPTION+=" $1"
|
2015-07-01 04:38:01 +08:00
|
|
|
;;
|
2020-01-06 00:29:59 +08:00
|
|
|
-d )
|
2017-03-11 03:12:56 +08:00
|
|
|
set -x
|
|
|
|
;;
|
2020-04-10 11:15:46 +08:00
|
|
|
-e )
|
|
|
|
shift
|
|
|
|
EXTRA_FLAGS="EXTRAFLAGS=$1"
|
|
|
|
;;
|
2020-01-06 00:29:59 +08:00
|
|
|
-x )
|
2017-06-11 00:12:37 +08:00
|
|
|
MAKE_FLAGS='--silent --no-print-directory'
|
|
|
|
set -e
|
|
|
|
;;
|
2020-01-06 00:29:59 +08:00
|
|
|
-a )
|
2016-06-06 02:14:18 +08:00
|
|
|
shift
|
|
|
|
APPSDIR="$1"
|
|
|
|
;;
|
2020-01-06 00:29:59 +08:00
|
|
|
-j )
|
2019-10-03 07:11:33 +08:00
|
|
|
shift
|
|
|
|
JOPTION="-j $1"
|
|
|
|
;;
|
2020-01-06 00:29:59 +08:00
|
|
|
-t )
|
2018-06-28 02:27:34 +08:00
|
|
|
shift
|
|
|
|
nuttx="$1"
|
|
|
|
;;
|
2020-04-01 12:19:07 +08:00
|
|
|
-p )
|
|
|
|
PRINTLISTONLY=1
|
|
|
|
;;
|
2020-04-03 10:35:30 +08:00
|
|
|
-G )
|
|
|
|
GITCLEAN=1
|
|
|
|
;;
|
2020-01-06 00:29:59 +08:00
|
|
|
-h )
|
2015-07-01 04:38:01 +08:00
|
|
|
showusage
|
|
|
|
;;
|
2020-01-06 00:29:59 +08:00
|
|
|
* )
|
2015-07-01 04:38:01 +08:00
|
|
|
testfile="$1"
|
|
|
|
shift
|
2020-03-21 21:23:44 +08:00
|
|
|
break
|
2015-07-01 04:38:01 +08:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -z "$1" ]; then
|
2020-01-06 00:29:59 +08:00
|
|
|
echo "ERROR: Garbage at the end of line"
|
|
|
|
showusage
|
2015-07-01 04:38:01 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$testfile" ]; then
|
2020-01-06 00:29:59 +08:00
|
|
|
echo "ERROR: Missing test list file"
|
|
|
|
showusage
|
2015-07-01 04:38:01 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -r "$testfile" ]; then
|
2020-01-06 00:29:59 +08:00
|
|
|
echo "ERROR: No readable file exists at $testfile"
|
|
|
|
showusage
|
2015-07-01 04:38:01 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$nuttx" ]; then
|
2020-01-06 00:29:59 +08:00
|
|
|
echo "ERROR: Expected to find nuttx/ at $nuttx"
|
|
|
|
showusage
|
2015-07-01 04:38:01 +08:00
|
|
|
fi
|
|
|
|
|
2020-01-21 00:51:26 +08:00
|
|
|
if [ ! -d $APPSDIR ]; then
|
|
|
|
echo "ERROR: No directory found at $APPSDIR"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
export APPSDIR
|
|
|
|
|
2020-03-28 20:25:27 +08:00
|
|
|
testlist=`grep -v -E "^(-|#)" $testfile || true`
|
2020-03-03 17:44:03 +08:00
|
|
|
blacklist=`grep "^-" $testfile || true`
|
2020-01-21 00:51:26 +08:00
|
|
|
|
|
|
|
cd $nuttx || { echo "ERROR: failed to CD to $nuttx"; exit 1; }
|
|
|
|
|
2020-02-07 09:58:24 +08:00
|
|
|
function makefunc {
|
2020-04-19 16:58:55 +08:00
|
|
|
if ! ${MAKE} ${MAKE_FLAGS} "${EXTRA_FLAGS}" $@ 1>/dev/null; then
|
|
|
|
fail=1
|
2020-02-07 09:58:24 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-07-01 04:38:01 +08:00
|
|
|
# Clean up after the last build
|
|
|
|
|
|
|
|
function distclean {
|
2020-04-19 17:51:59 +08:00
|
|
|
echo " Cleaning..."
|
2020-01-06 00:29:59 +08:00
|
|
|
if [ -f .config ]; then
|
2020-04-03 10:35:30 +08:00
|
|
|
if [ ${GITCLEAN} -eq 1 ]; then
|
2020-04-19 17:51:59 +08:00
|
|
|
git -C $nuttx clean -xfdq
|
|
|
|
git -C $APPSDIR clean -xfdq
|
2020-04-03 10:35:30 +08:00
|
|
|
else
|
2020-04-14 19:57:32 +08:00
|
|
|
makefunc ${JOPTION} distclean
|
2020-04-22 00:39:56 +08:00
|
|
|
|
|
|
|
# Ensure nuttx and apps directory in clean state even with --ignored
|
|
|
|
|
|
|
|
if [ -d $nuttx/.git ] || [ -d $APPSDIR/.git ]; then
|
|
|
|
if [[ -n $(git -C $nuttx status --ignored -s) ]]; then
|
|
|
|
git -C $nuttx status --ignored
|
|
|
|
fail=1
|
|
|
|
fi
|
|
|
|
if [[ -n $(git -C $APPSDIR status --ignored -s) ]]; then
|
|
|
|
git -C $APPSDIR status --ignored
|
|
|
|
fail=1
|
|
|
|
fi
|
|
|
|
fi
|
2020-04-03 10:35:30 +08:00
|
|
|
fi
|
2020-01-06 00:29:59 +08:00
|
|
|
fi
|
2015-07-01 04:38:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Configure for the next build
|
|
|
|
|
|
|
|
function configure {
|
2020-01-06 00:29:59 +08:00
|
|
|
echo " Configuring..."
|
2020-04-19 17:25:27 +08:00
|
|
|
if ! ./tools/configure.sh ${HOPTION} $config; then
|
|
|
|
fail=1
|
|
|
|
fi
|
2020-01-06 00:29:59 +08:00
|
|
|
|
|
|
|
if [ "X$toolchain" != "X" ]; then
|
2020-03-07 22:22:11 +08:00
|
|
|
setting=`grep _TOOLCHAIN_ $nuttx/.config | grep -v CONFIG_ARCH_TOOLCHAIN_* | grep =y`
|
2020-01-06 00:29:59 +08:00
|
|
|
varname=`echo $setting | cut -d'=' -f1`
|
|
|
|
if [ ! -z "$varname" ]; then
|
|
|
|
echo " Disabling $varname"
|
2020-01-20 01:29:34 +08:00
|
|
|
sed -i -e "/$varname/d" $nuttx/.config
|
2015-07-02 04:32:59 +08:00
|
|
|
fi
|
2015-07-01 04:38:01 +08:00
|
|
|
|
2020-02-15 12:22:32 +08:00
|
|
|
echo " Enabling $toolchain"
|
2020-03-07 22:22:11 +08:00
|
|
|
sed -i -e "/$toolchain/d" $nuttx/.config
|
2020-02-15 12:22:32 +08:00
|
|
|
echo "$toolchain=y" >> $nuttx/.config
|
|
|
|
|
|
|
|
if [ "X$sizet" == "Xuint" ]; then
|
|
|
|
echo " Disabling CONFIG_ARCH_SIZET_LONG"
|
2020-02-17 20:19:25 +08:00
|
|
|
sed -i -e "/CONFIG_ARCH_SIZET_LONG/d" $nuttx/.config
|
2020-02-15 12:22:32 +08:00
|
|
|
elif [ "X$sizet" == "Xulong" ]; then
|
|
|
|
echo " Enabling CONFIG_ARCH_SIZET_LONG"
|
|
|
|
sed -i -e "\$aCONFIG_ARCH_SIZET_LONG=y" $nuttx/.config
|
2020-01-24 22:12:20 +08:00
|
|
|
fi
|
|
|
|
|
2020-04-19 17:25:27 +08:00
|
|
|
makefunc olddefconfig
|
2020-01-06 00:29:59 +08:00
|
|
|
fi
|
2015-07-01 04:38:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Perform the next build
|
|
|
|
|
|
|
|
function build {
|
2020-01-06 00:29:59 +08:00
|
|
|
echo " Building NuttX..."
|
2020-04-14 19:57:32 +08:00
|
|
|
makefunc ${JOPTION}
|
2020-04-19 17:25:27 +08:00
|
|
|
|
|
|
|
# Ensure defconfig in the canonical form
|
|
|
|
|
|
|
|
if ! ./tools/refresh.sh --silent $config; then
|
|
|
|
fail=1
|
|
|
|
fi
|
2020-04-19 17:51:59 +08:00
|
|
|
|
|
|
|
# Ensure nuttx and apps directory in clean state
|
|
|
|
|
|
|
|
if [ -d $nuttx/.git ] || [ -d $APPSDIR/.git ]; then
|
|
|
|
if [[ -n $(git -C $nuttx status -s) ]]; then
|
|
|
|
git -C $nuttx status
|
|
|
|
fail=1
|
|
|
|
fi
|
|
|
|
if [[ -n $(git -C $APPSDIR status -s) ]]; then
|
|
|
|
git -C $APPSDIR status
|
|
|
|
fail=1
|
|
|
|
fi
|
|
|
|
fi
|
2015-07-01 04:38:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Coordinate the steps for the next build test
|
|
|
|
|
|
|
|
function dotest {
|
2020-01-06 00:29:59 +08:00
|
|
|
echo "===================================================================================="
|
2020-01-21 00:51:26 +08:00
|
|
|
config=`echo $1 | cut -d',' -f1`
|
2020-03-28 20:19:40 +08:00
|
|
|
re="-${config/\//:}[[:space:]]"
|
|
|
|
if [[ "${blacklist} " =~ $re ]]; then
|
2020-01-21 00:51:26 +08:00
|
|
|
echo "Skipping: $1"
|
2020-01-06 00:29:59 +08:00
|
|
|
else
|
2020-01-21 00:51:26 +08:00
|
|
|
echo "Configuration/Tool: $1"
|
2020-04-01 12:19:07 +08:00
|
|
|
if [ ${PRINTLISTONLY} -eq 1 ]; then
|
|
|
|
return
|
|
|
|
fi
|
2020-01-06 00:29:59 +08:00
|
|
|
|
|
|
|
# Parse the next line
|
|
|
|
|
|
|
|
configdir=`echo $config | cut -s -d':' -f2`
|
|
|
|
if [ -z "${configdir}" ]; then
|
|
|
|
configdir=`echo $config | cut -s -d'/' -f2`
|
2019-08-06 06:53:39 +08:00
|
|
|
if [ -z "${configdir}" ]; then
|
2020-01-06 00:29:59 +08:00
|
|
|
echo "ERROR: Malformed configuration: ${config}"
|
|
|
|
showusage
|
2019-08-06 06:53:39 +08:00
|
|
|
else
|
2020-01-06 00:29:59 +08:00
|
|
|
boarddir=`echo $config | cut -d'/' -f1`
|
2019-08-06 06:53:39 +08:00
|
|
|
fi
|
2020-01-06 00:29:59 +08:00
|
|
|
else
|
|
|
|
boarddir=`echo $config | cut -d':' -f1`
|
|
|
|
fi
|
2015-07-01 04:38:01 +08:00
|
|
|
|
2020-01-16 09:16:14 +08:00
|
|
|
path=$nuttx/boards/*/*/$boarddir/configs/$configdir
|
|
|
|
if [ ! -r $path/defconfig ]; then
|
2020-01-06 00:29:59 +08:00
|
|
|
echo "ERROR: no configuration found at $path"
|
|
|
|
showusage
|
|
|
|
fi
|
2015-07-01 04:38:01 +08:00
|
|
|
|
2020-02-15 12:22:32 +08:00
|
|
|
unset toolchain
|
|
|
|
unset sizet
|
2020-01-21 00:51:26 +08:00
|
|
|
if [ "X$config" != "X$1" ]; then
|
|
|
|
toolchain=`echo $1 | cut -d',' -f2`
|
2020-01-06 00:29:59 +08:00
|
|
|
if [ -z "$toolchain" ]; then
|
|
|
|
echo " Warning: no tool configuration"
|
2015-07-23 03:20:35 +08:00
|
|
|
fi
|
2020-02-15 12:22:32 +08:00
|
|
|
archsizet=`echo $line | cut -d',' -f3`
|
|
|
|
if [ "X$archsizet" == "XCONFIG_ARCH_SIZET_LONG" ]; then
|
|
|
|
sizet=ulong
|
|
|
|
elif [ "X$archsizet" == "X-CONFIG_ARCH_SIZET_LONG" ]; then
|
|
|
|
sizet=uint
|
|
|
|
fi
|
2020-01-06 00:29:59 +08:00
|
|
|
fi
|
2015-07-01 04:38:01 +08:00
|
|
|
|
2020-01-06 00:29:59 +08:00
|
|
|
# Perform the build test
|
2015-07-01 04:38:01 +08:00
|
|
|
|
2020-01-21 00:51:26 +08:00
|
|
|
echo "------------------------------------------------------------------------------------"
|
|
|
|
distclean
|
|
|
|
configure
|
|
|
|
build
|
2020-01-06 00:29:59 +08:00
|
|
|
fi
|
2020-01-21 00:51:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Perform the build test for each entry in the test list file
|
|
|
|
|
|
|
|
for line in $testlist; do
|
|
|
|
firstch=${line:0:1}
|
|
|
|
if [ "X$firstch" == "X/" ]; then
|
|
|
|
dir=`echo $line | cut -d',' -f1`
|
|
|
|
list=`find boards$dir -name defconfig | cut -d'/' -f4,6`
|
|
|
|
for i in ${list}; do
|
|
|
|
dotest $i${line/$dir/}
|
|
|
|
done
|
2020-03-28 20:25:27 +08:00
|
|
|
else
|
2020-01-21 00:51:26 +08:00
|
|
|
dotest $line
|
|
|
|
fi
|
|
|
|
done
|
2015-07-01 04:38:01 +08:00
|
|
|
|
|
|
|
echo "===================================================================================="
|
2020-01-21 17:53:06 +08:00
|
|
|
|
|
|
|
exit $fail
|