2015-06-30 22:38:01 +02:00
|
|
|
#!/bin/bash
|
2016-04-07 20:51:52 +02:00
|
|
|
# testbuild.sh
|
2015-06-30 22:38:01 +02:00
|
|
|
#
|
2017-01-01 22:34:23 +01:00
|
|
|
# Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
2015-06-30 22:38:01 +02: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.
|
|
|
|
#
|
|
|
|
|
|
|
|
WD=$PWD
|
|
|
|
nuttx=$WD/../nuttx
|
2016-06-05 21:19:41 +02:00
|
|
|
TOOLSDIR=$nuttx/tools
|
|
|
|
UNLINK=$TOOLSDIR/unlink.sh
|
2015-06-30 22:38:01 +02:00
|
|
|
|
|
|
|
progname=$0
|
2015-07-01 22:32:59 +02:00
|
|
|
host=linux
|
|
|
|
wenv=cygwin
|
|
|
|
sizet=uint
|
2016-06-05 20:14:18 +02:00
|
|
|
APPSDIR=../apps
|
|
|
|
NXWDIR=../NxWidgets
|
2017-06-10 18:12:37 +02:00
|
|
|
MAKE_FLAGS=-i
|
|
|
|
MAKE=make
|
2015-06-30 22:38:01 +02:00
|
|
|
unset testfile
|
|
|
|
|
|
|
|
function showusage {
|
|
|
|
echo ""
|
2017-01-01 22:34:23 +01:00
|
|
|
echo "USAGE: $progname [-w|l] [-c|u|n] [-s] [-a <appsdir>] [-n <nxdir>] <testlist-file>"
|
2016-01-28 16:53:47 +01:00
|
|
|
echo " $progname -h"
|
2015-06-30 22:38:01 +02:00
|
|
|
echo ""
|
2016-01-28 16:53:47 +01:00
|
|
|
echo "Where:"
|
2015-06-30 22:38:01 +02:00
|
|
|
echo " -w|l selects Windows (w) or Linux (l). Default: Linux"
|
2017-01-01 22:34:23 +01:00
|
|
|
echo " -c|u|n selects Windows environment option: Cygwin (c), Ubuntu under"
|
|
|
|
echo " Windows 10 (u), or Windows native (n). Default Cygwin"
|
2015-11-30 20:06:16 +01:00
|
|
|
echo " -s Use C++ unsigned long size_t in new operator. Default unsigned int"
|
2016-06-05 21:19:41 +02:00
|
|
|
echo " -a <appsdir> provides the relative path to the apps/ directory. Default ../apps"
|
2016-06-05 20:14:18 +02:00
|
|
|
echo " -n <nxdir> provides the relative path to the NxWidgets/ directory. Default ../NxWidgets"
|
2017-03-10 20:12:56 +01:00
|
|
|
echo " -d enables script debug output"
|
2017-06-10 18:12:37 +02:00
|
|
|
echo " -x exit on build failures"
|
2015-06-30 22:38:01 +02: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
|
|
|
|
}
|
|
|
|
|
|
|
|
# Parse command line
|
|
|
|
|
|
|
|
while [ ! -z "$1" ]; do
|
|
|
|
case $1 in
|
|
|
|
-w )
|
2015-07-01 22:32:59 +02:00
|
|
|
host=windows
|
2015-06-30 22:38:01 +02:00
|
|
|
;;
|
|
|
|
-l )
|
2015-07-01 22:32:59 +02:00
|
|
|
host=linux
|
2015-06-30 22:38:01 +02:00
|
|
|
;;
|
|
|
|
-c )
|
2017-01-01 22:39:24 +01:00
|
|
|
host=windows
|
2015-07-01 22:32:59 +02:00
|
|
|
wenv=cygwin
|
2015-06-30 22:38:01 +02:00
|
|
|
;;
|
2017-03-10 20:12:56 +01:00
|
|
|
-d )
|
|
|
|
set -x
|
|
|
|
;;
|
2017-01-01 22:34:23 +01:00
|
|
|
-u )
|
2017-01-01 22:39:24 +01:00
|
|
|
host=windows
|
2017-01-01 22:34:23 +01:00
|
|
|
wenv=ubuntu
|
|
|
|
;;
|
2015-06-30 22:38:01 +02:00
|
|
|
-n )
|
2017-01-01 22:39:24 +01:00
|
|
|
host=windows
|
2015-11-30 20:06:16 +01:00
|
|
|
wenv=native
|
2015-06-30 22:38:01 +02:00
|
|
|
;;
|
2015-07-01 22:32:59 +02:00
|
|
|
-s )
|
2017-01-01 22:39:24 +01:00
|
|
|
host=windows
|
2015-07-01 22:32:59 +02:00
|
|
|
sizet=long
|
|
|
|
;;
|
2017-06-10 18:12:37 +02:00
|
|
|
-x )
|
|
|
|
MAKE_FLAGS='--silent --no-print-directory'
|
|
|
|
set -e
|
|
|
|
;;
|
2016-06-05 20:14:18 +02:00
|
|
|
-a )
|
|
|
|
shift
|
|
|
|
APPSDIR="$1"
|
|
|
|
;;
|
|
|
|
-n )
|
|
|
|
shift
|
|
|
|
NXWDIR="$1"
|
|
|
|
;;
|
2015-06-30 22:38:01 +02:00
|
|
|
-h )
|
|
|
|
showusage
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
testfile="$1"
|
|
|
|
shift
|
|
|
|
break;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -z "$1" ]; then
|
|
|
|
echo "ERROR: Garbage at the end of line"
|
|
|
|
showusage
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$testfile" ]; then
|
|
|
|
echo "ERROR: Missing test list file"
|
|
|
|
showusage
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -r "$testfile" ]; then
|
|
|
|
echo "ERROR: No readable file exists at $testfile"
|
|
|
|
showusage
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$nuttx" ]; then
|
|
|
|
echo "ERROR: Expected to find nuttx/ at $nuttx"
|
|
|
|
showusage
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Clean up after the last build
|
|
|
|
|
|
|
|
function distclean {
|
|
|
|
cd $nuttx || { echo "ERROR: failed to CD to $nuttx"; exit 1; }
|
|
|
|
if [ -f .config ]; then
|
|
|
|
echo " Cleaning..."
|
2017-06-10 18:12:37 +02:00
|
|
|
${MAKE} ${MAKE_FLAGS} distclean 1>/dev/null
|
2015-06-30 22:38:01 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Configure for the next build
|
|
|
|
|
|
|
|
function configure {
|
|
|
|
cd $nuttx/tools || { echo "ERROR: failed to CD to $nuttx/tools"; exit 1; }
|
|
|
|
echo " Configuring..."
|
|
|
|
./configure.sh $config
|
|
|
|
|
|
|
|
cd $nuttx || { echo "ERROR: failed to CD to $nuttx"; exit 1; }
|
|
|
|
|
2015-07-01 22:32:59 +02:00
|
|
|
if [ "X$host" == "Xlinux" ]; then
|
2015-06-30 22:38:01 +02:00
|
|
|
echo " Select CONFIG_HOST_LINUX=y"
|
|
|
|
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_LINUX
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_WINDOWS
|
|
|
|
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_NATIVE
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_CYGWIN
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_MSYS
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_OTHER
|
|
|
|
|
2015-11-30 20:06:16 +01:00
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_SIM_X8664_SYSTEMV
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_SIM_X8664_MICROSOFT
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_SIM_M32
|
2015-06-30 22:38:01 +02:00
|
|
|
else
|
|
|
|
echo " Select CONFIG_HOST_WINDOWS=y"
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_WINDOWS
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX
|
|
|
|
|
2015-07-01 22:32:59 +02:00
|
|
|
if [ "X$wenv" == "Xcygwin" ]; then
|
2015-11-30 20:06:16 +01:00
|
|
|
echo " Select CONFIG_WINDOWS_CYGWIN=y"
|
2015-06-30 22:38:01 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_CYGWIN
|
2017-01-01 22:34:23 +01:00
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_UBUNTU
|
2015-06-30 22:38:01 +02:00
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_NATIVE
|
|
|
|
else
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_CYGWIN
|
2017-01-01 22:34:23 +01:00
|
|
|
if [ "X$wenv" == "Xubuntu" ]; then
|
|
|
|
echo " Select CONFIG_WINDOWS_UBUNTU=y"
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_UBUNTU
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_NATIVE
|
|
|
|
else
|
|
|
|
echo " Select CONFIG_WINDOWS_NATIVE=y"
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_UBUNTU
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_NATIVE
|
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_MSYS
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_OTHER
|
2015-11-30 20:06:16 +01:00
|
|
|
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_SIM_X8664_MICROSOFT
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_SIM_X8664_SYSTEMV
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_SIM_M32
|
2015-06-30 22:38:01 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_OSX
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_OTHER
|
|
|
|
|
2015-07-01 22:32:59 +02:00
|
|
|
if [ "X$sizet" == "Xlong" ]; then
|
|
|
|
echo " Select CONFIG_CXX_NEWLONG=y"
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable CONFIG_CXX_NEWLONG
|
|
|
|
else
|
|
|
|
echo " Disable CONFIG_CXX_NEWLONG"
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable CONFIG_CXX_NEWLONG
|
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2015-11-29 21:42:32 +01:00
|
|
|
if [ "X$toolchain" != "X" ]; then
|
2017-05-13 21:28:15 +02:00
|
|
|
setting=`grep TOOLCHAIN $nuttx/.config | grep -v CONFIG_ARCH_TOOLCHAIN_GNU=y | grep =y`
|
2015-11-29 21:42:32 +01:00
|
|
|
varname=`echo $setting | cut -d'=' -f1`
|
|
|
|
if [ ! -z "varname" ]; then
|
|
|
|
echo " Disabling $varname"
|
|
|
|
kconfig-tweak --file $nuttx/.config --disable $varname
|
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2015-11-29 21:42:32 +01:00
|
|
|
echo " Enabling $toolchain"
|
|
|
|
kconfig-tweak --file $nuttx/.config --enable $toolchain
|
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
|
|
|
echo " Refreshing..."
|
2016-03-08 21:12:44 +01:00
|
|
|
cd $nuttx || { echo "ERROR: failed to CD to $nuttx"; exit 1; }
|
2017-06-10 18:12:37 +02:00
|
|
|
${MAKE} ${MAKE_FLAGS} olddefconfig 1>/dev/null 2>&1
|
2015-06-30 22:38:01 +02:00
|
|
|
}
|
|
|
|
|
2016-06-05 20:14:18 +02:00
|
|
|
# Build the NxWidgets libraries
|
|
|
|
|
|
|
|
function nxbuild {
|
2016-06-05 21:19:41 +02:00
|
|
|
if [ -e $APPSDIR/external ]; then
|
|
|
|
$UNLINK $APPSDIR/external
|
2016-06-05 20:14:18 +02:00
|
|
|
fi
|
|
|
|
|
2016-06-05 22:21:02 +02:00
|
|
|
unset nxconfig
|
|
|
|
if [ -d $NXWDIR ]; then
|
2017-06-10 18:12:37 +02:00
|
|
|
nxconfig=`grep CONFIG_NXWM=y $nuttx/.config` || true
|
2016-06-05 22:21:02 +02:00
|
|
|
fi
|
|
|
|
|
2016-06-05 20:14:18 +02:00
|
|
|
if [ ! -z "$nxconfig" ]; then
|
|
|
|
echo " Building NxWidgets..."
|
|
|
|
echo "------------------------------------------------------------------------------------"
|
|
|
|
|
|
|
|
cd $nuttx/$NXTOOLS || { echo "Failed to CD to $NXTOOLS"; exit 1; }
|
|
|
|
./install.sh $nuttx/$APPSDIR nxwm 1>/dev/null
|
|
|
|
|
2017-06-10 18:12:37 +02:00
|
|
|
${MAKE} ${MAKE_FLAGS} -C $nuttx/$APPSDIR/external TOPDIR=$nuttx APPDIR=$nuttx/$APPSDIR TOPDIR=$nuttx clean 1>/dev/null
|
2016-06-05 21:19:41 +02:00
|
|
|
|
2016-06-05 20:14:18 +02:00
|
|
|
cd $nuttx || { echo "Failed to CD to $nuttx"; exit 1; }
|
2017-06-10 18:12:37 +02:00
|
|
|
${MAKE} ${MAKE_FLAGS} context 1>/dev/null
|
2016-06-05 20:14:18 +02:00
|
|
|
|
|
|
|
cd $nuttx/$NXWIDGETSDIR || { echo "Failed to CD to $NXWIDGETSDIR"; exit 1; }
|
2017-06-10 18:12:37 +02:00
|
|
|
${MAKE} ${MAKE_FLAGS} TOPDIR=$nuttx clean 1>/dev/null
|
|
|
|
${MAKE} ${MAKE_FLAGS} TOPDIR=$nuttx 1>/dev/null
|
2016-06-05 20:14:18 +02:00
|
|
|
|
|
|
|
cd $nuttx/$NXWMDIR || { echo "Failed to CD to $NXWMDIR"; exit 1; }
|
2017-06-10 18:12:37 +02:00
|
|
|
${MAKE} ${MAKE_FLAGS} TOPDIR=$nuttx clean 1>/dev/null
|
|
|
|
${MAKE} ${MAKE_FLAGS} TOPDIR=$nuttx 1>/dev/null
|
2016-06-05 20:14:18 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-06-30 22:38:01 +02:00
|
|
|
# Perform the next build
|
|
|
|
|
|
|
|
function build {
|
|
|
|
cd $nuttx || { echo "ERROR: failed to CD to $nuttx"; exit 1; }
|
2016-06-05 21:19:41 +02:00
|
|
|
echo " Building NuttX..."
|
2015-06-30 22:38:01 +02:00
|
|
|
echo "------------------------------------------------------------------------------------"
|
2017-06-10 18:12:37 +02:00
|
|
|
${MAKE} ${MAKE_FLAGS} 1>/dev/null
|
2015-06-30 22:38:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Coordinate the steps for the next build test
|
|
|
|
|
|
|
|
function dotest {
|
|
|
|
echo "------------------------------------------------------------------------------------"
|
|
|
|
distclean
|
|
|
|
configure
|
2016-06-05 20:14:18 +02:00
|
|
|
nxbuild
|
2015-06-30 22:38:01 +02:00
|
|
|
build
|
|
|
|
}
|
|
|
|
|
2015-07-03 22:38:16 +02:00
|
|
|
# Perform the build test for each entry in the test list file
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2016-06-05 20:14:18 +02:00
|
|
|
if [ ! -d $APPSDIR ]; then
|
|
|
|
export "ERROR: No directory found at $APPSDIR"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
export APPSDIR
|
|
|
|
|
|
|
|
if [ -d $NXWDIR ]; then
|
|
|
|
NXWIDGETSDIR=$NXWDIR/libnxwidgets
|
|
|
|
NXWMDIR=$NXWDIR/nxwm
|
|
|
|
NXTOOLS=$NXWDIR/tools
|
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
|
|
|
# Shouldn't have to do this
|
|
|
|
|
|
|
|
testlist=`cat $testfile`
|
|
|
|
|
|
|
|
#while read -r line || [[ -n $line ]]; do
|
|
|
|
for line in $testlist; do
|
|
|
|
echo "===================================================================================="
|
2015-07-22 21:20:35 +02:00
|
|
|
firstch=${line:0:1}
|
|
|
|
if [ "X$firstch" == "X#" ]; then
|
|
|
|
echo "Skipping: $line"
|
|
|
|
else
|
|
|
|
echo "Configuration/Tool: $line"
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2015-07-22 21:20:35 +02:00
|
|
|
# Parse the next line
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2015-07-22 21:20:35 +02:00
|
|
|
config=`echo $line | cut -d',' -f1`
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2015-07-22 21:20:35 +02:00
|
|
|
path=$nuttx/configs/$config
|
|
|
|
if [ ! -r "$path/defconfig" ]; then
|
2015-07-03 22:38:16 +02:00
|
|
|
echo "ERROR: no configuration found at $path"
|
2015-06-30 22:38:01 +02:00
|
|
|
showusage
|
2015-07-22 21:20:35 +02:00
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2015-11-29 21:42:32 +01:00
|
|
|
unset toolchain;
|
|
|
|
if [ "X$config" != "X$line" ]; then
|
|
|
|
toolchain=`echo $line | cut -d',' -f2`
|
|
|
|
if [ -z "$toolchain" ]; then
|
|
|
|
echo " Warning: no tool configuration"
|
|
|
|
fi
|
2015-07-22 21:20:35 +02:00
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2015-07-22 21:20:35 +02:00
|
|
|
# Perform the build test
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2015-07-22 21:20:35 +02:00
|
|
|
dotest
|
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
cd $WD || { echo "ERROR: Failed to CD to $WD"; exit 1; }
|
|
|
|
done # < $testfile
|
|
|
|
|
|
|
|
echo "===================================================================================="
|