2019-08-10 17:57:26 +02:00
|
|
|
#!/usr/bin/env bash
|
2020-01-19 18:03:11 +01:00
|
|
|
# tools/testbuild.sh
|
2015-06-30 22:38:01 +02:00
|
|
|
#
|
2021-02-18 13:48:10 +01:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership. The
|
|
|
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance with the
|
|
|
|
# License. You may obtain a copy of the License at
|
2015-06-30 22:38:01 +02:00
|
|
|
#
|
2021-02-18 13:48:10 +01:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2015-06-30 22:38:01 +02:00
|
|
|
#
|
2021-02-18 13:48:10 +01:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2015-06-30 22:38:01 +02:00
|
|
|
#
|
|
|
|
|
2020-02-10 04:47:03 +01:00
|
|
|
WD=$(cd $(dirname $0) && cd .. && pwd)
|
2015-06-30 22:38:01 +02:00
|
|
|
nuttx=$WD/../nuttx
|
|
|
|
|
|
|
|
progname=$0
|
2020-01-21 10:53:06 +01:00
|
|
|
fail=0
|
2020-02-10 04:47:03 +01:00
|
|
|
APPSDIR=$WD/../apps
|
2020-10-26 05:18:43 +01:00
|
|
|
if [ -z $ARTIFACTDIR ]; then
|
|
|
|
ARTIFACTDIR=$WD/../buildartifacts
|
|
|
|
fi
|
2020-01-21 10:53:06 +01:00
|
|
|
MAKE_FLAGS=-k
|
2020-05-26 13:58:49 +02:00
|
|
|
EXTRA_FLAGS="EXTRAFLAGS="
|
2017-06-10 18:12:37 +02:00
|
|
|
MAKE=make
|
2015-06-30 22:38:01 +02:00
|
|
|
unset testfile
|
2020-01-19 18:29:34 +01:00
|
|
|
unset HOPTION
|
2019-10-03 15:52:16 +02:00
|
|
|
unset JOPTION
|
2020-04-01 06:19:07 +02:00
|
|
|
PRINTLISTONLY=0
|
2020-04-03 04:35:30 +02:00
|
|
|
GITCLEAN=0
|
2020-10-26 05:18:43 +01:00
|
|
|
SAVEARTIFACTS=0
|
2020-11-10 15:15:22 +01:00
|
|
|
CHECKCLEAN=1
|
2022-09-14 11:59:17 +02:00
|
|
|
CODECHECKER=0
|
2024-07-16 18:07:08 +02:00
|
|
|
NINJACMAKE=0
|
2022-01-31 03:12:10 +01:00
|
|
|
RUN=0
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2020-10-26 18:44:23 +01:00
|
|
|
case $(uname -s) in
|
|
|
|
Darwin*)
|
|
|
|
HOST=Darwin
|
|
|
|
;;
|
|
|
|
CYGWIN*)
|
|
|
|
HOST=Cygwin
|
|
|
|
;;
|
|
|
|
MINGW32*)
|
|
|
|
HOST=MinGw
|
|
|
|
;;
|
2024-07-16 18:07:08 +02:00
|
|
|
MSYS*)
|
|
|
|
HOST=Msys
|
|
|
|
;;
|
2020-10-26 18:44:23 +01:00
|
|
|
*)
|
|
|
|
|
|
|
|
# Assume linux as a fallback
|
|
|
|
HOST=Linux
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2015-06-30 22:38:01 +02:00
|
|
|
function showusage {
|
2020-01-05 17:29:59 +01:00
|
|
|
echo ""
|
2024-07-16 18:07:08 +02:00
|
|
|
echo "USAGE: $progname -h [-l|m|c|g|n] [-d] [-e <extraflags>] [-x] [-j <ncpus>] [-a <appsdir>] [-t <topdir>] [-p]"
|
|
|
|
echo " [-A] [-C] [-G] [-N] [-R] [--codechecker] <testlist-file>"
|
2020-01-05 17:29:59 +01:00
|
|
|
echo ""
|
|
|
|
echo "Where:"
|
2024-07-16 18:07:08 +02:00
|
|
|
echo " -h will show this help test and terminate"
|
2020-10-18 15:28:35 +02:00
|
|
|
echo " -l|m|c|g|n selects Linux (l), macOS (m), Cygwin (c),"
|
|
|
|
echo " MSYS/MSYS2 (g) or Windows native (n). Default Linux"
|
2020-01-05 17:29:59 +01:00
|
|
|
echo " -d enables script debug output"
|
2020-04-10 05:15:46 +02:00
|
|
|
echo " -e pass extra c/c++ flags such as -Wno-cpp via make command line"
|
2020-01-05 17:29:59 +01: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"
|
2020-10-26 05:18:43 +01:00
|
|
|
echo " -t <topdir> provides the absolute path to top nuttx/ directory. Default ../nuttx"
|
2020-04-01 06:19:07 +02:00
|
|
|
echo " -p only print the list of configs without running any builds"
|
2020-10-26 05:18:43 +01:00
|
|
|
echo " -A store the build executable artifact in ARTIFACTDIR (defaults to ../buildartifacts"
|
2020-11-10 15:15:22 +01:00
|
|
|
echo " -C Skip tree cleanness check."
|
2020-04-03 04:35:30 +02: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."
|
2024-07-16 18:07:08 +02:00
|
|
|
echo " -N Use CMake with Ninja as the backend."
|
2022-01-31 03:12:10 +01:00
|
|
|
echo " -R execute \"run\" script in the config directories if exists."
|
2022-09-14 11:59:17 +02:00
|
|
|
echo " --codechecker enables CodeChecker statically analyze the code."
|
2020-01-05 17:29:59 +01:00
|
|
|
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-06-30 22:38:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Parse command line
|
|
|
|
|
|
|
|
while [ ! -z "$1" ]; do
|
2020-01-05 17:29:59 +01:00
|
|
|
case $1 in
|
2020-10-18 15:28:35 +02:00
|
|
|
-l | -m | -c | -g | -n )
|
2020-01-19 18:29:34 +01:00
|
|
|
HOPTION+=" $1"
|
2015-06-30 22:38:01 +02:00
|
|
|
;;
|
2020-01-05 17:29:59 +01:00
|
|
|
-d )
|
2017-03-10 20:12:56 +01:00
|
|
|
set -x
|
|
|
|
;;
|
2020-04-10 05:15:46 +02:00
|
|
|
-e )
|
|
|
|
shift
|
2020-05-26 13:58:49 +02:00
|
|
|
EXTRA_FLAGS+="$1"
|
2020-04-10 05:15:46 +02:00
|
|
|
;;
|
2020-01-05 17:29:59 +01:00
|
|
|
-x )
|
2017-06-10 18:12:37 +02:00
|
|
|
MAKE_FLAGS='--silent --no-print-directory'
|
|
|
|
set -e
|
|
|
|
;;
|
2020-01-05 17:29:59 +01:00
|
|
|
-a )
|
2016-06-05 20:14:18 +02:00
|
|
|
shift
|
|
|
|
APPSDIR="$1"
|
|
|
|
;;
|
2020-01-05 17:29:59 +01:00
|
|
|
-j )
|
2019-10-03 01:11:33 +02:00
|
|
|
shift
|
|
|
|
JOPTION="-j $1"
|
|
|
|
;;
|
2020-01-05 17:29:59 +01:00
|
|
|
-t )
|
2018-06-27 20:27:34 +02:00
|
|
|
shift
|
|
|
|
nuttx="$1"
|
|
|
|
;;
|
2020-04-01 06:19:07 +02:00
|
|
|
-p )
|
|
|
|
PRINTLISTONLY=1
|
|
|
|
;;
|
2020-04-03 04:35:30 +02:00
|
|
|
-G )
|
|
|
|
GITCLEAN=1
|
|
|
|
;;
|
2020-10-26 05:18:43 +01:00
|
|
|
-A )
|
|
|
|
SAVEARTIFACTS=1
|
|
|
|
;;
|
2020-11-10 15:15:22 +01:00
|
|
|
-C )
|
|
|
|
CHECKCLEAN=0
|
|
|
|
;;
|
2024-07-16 18:07:08 +02:00
|
|
|
-N )
|
|
|
|
NINJACMAKE=1
|
|
|
|
;;
|
2022-01-31 03:12:10 +01:00
|
|
|
-R )
|
|
|
|
RUN=1
|
|
|
|
;;
|
2022-09-14 11:59:17 +02:00
|
|
|
--codechecker )
|
|
|
|
CODECHECKER=1
|
|
|
|
;;
|
2020-01-05 17:29:59 +01:00
|
|
|
-h )
|
2015-06-30 22:38:01 +02:00
|
|
|
showusage
|
|
|
|
;;
|
2020-01-05 17:29:59 +01:00
|
|
|
* )
|
2015-06-30 22:38:01 +02:00
|
|
|
testfile="$1"
|
|
|
|
shift
|
2020-03-21 14:23:44 +01:00
|
|
|
break
|
2015-06-30 22:38:01 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -z "$1" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "ERROR: Garbage at the end of line"
|
|
|
|
showusage
|
2015-06-30 22:38:01 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$testfile" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "ERROR: Missing test list file"
|
|
|
|
showusage
|
2015-06-30 22:38:01 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -r "$testfile" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "ERROR: No readable file exists at $testfile"
|
|
|
|
showusage
|
2015-06-30 22:38:01 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$nuttx" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "ERROR: Expected to find nuttx/ at $nuttx"
|
|
|
|
showusage
|
2015-06-30 22:38:01 +02:00
|
|
|
fi
|
|
|
|
|
2020-01-20 17:51:26 +01:00
|
|
|
if [ ! -d $APPSDIR ]; then
|
|
|
|
echo "ERROR: No directory found at $APPSDIR"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
export APPSDIR
|
|
|
|
|
2023-07-13 10:32:56 +02:00
|
|
|
testlist=`grep -v -E "^(-|#)|^[C|c][M|m][A|a][K|k][E|e]" $testfile || true`
|
2020-03-03 10:44:03 +01:00
|
|
|
blacklist=`grep "^-" $testfile || true`
|
2020-01-20 17:51:26 +01:00
|
|
|
|
2024-07-16 18:07:08 +02:00
|
|
|
if [ ${NINJACMAKE} -eq 1 ]; then
|
2023-07-13 10:32:56 +02:00
|
|
|
cmakelist=`grep "^[C|c][M|m][A|a][K|k][E|e]" $testfile | cut -d',' -f2 || true`
|
|
|
|
fi
|
|
|
|
|
2020-01-20 17:51:26 +01:00
|
|
|
cd $nuttx || { echo "ERROR: failed to CD to $nuttx"; exit 1; }
|
|
|
|
|
2022-07-27 07:07:32 +02:00
|
|
|
function exportandimport {
|
2024-07-30 12:09:23 +02:00
|
|
|
# Do nothing until we finish to build the nuttx.
|
2022-07-27 07:07:32 +02:00
|
|
|
if [ ! -f nuttx ]; then
|
|
|
|
return $fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If CONFIG_BUILD_KERNEL=y does not exist in .config, do nothing
|
|
|
|
if ! grep CONFIG_BUILD_KERNEL=y .config 1>/dev/null; then
|
|
|
|
return $fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! ${MAKE} export ${JOPTION} 1>/dev/null; then
|
|
|
|
fail=1
|
|
|
|
return $fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
pushd ../apps/
|
|
|
|
|
|
|
|
if ! ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz 1>/dev/null; then
|
|
|
|
fail=1
|
|
|
|
popd
|
|
|
|
return $fail
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! ${MAKE} import ${JOPTION} 1>/dev/null; then
|
|
|
|
fail=1
|
|
|
|
fi
|
|
|
|
popd
|
|
|
|
return $fail
|
|
|
|
}
|
|
|
|
|
2022-09-14 11:59:17 +02:00
|
|
|
function compressartifacts {
|
|
|
|
local target_path=$1
|
|
|
|
local target_name=$2
|
|
|
|
|
|
|
|
pushd $target_path >/dev/null
|
|
|
|
|
|
|
|
tar zcf ${target_name}.tar.gz ${target_name}
|
2023-02-25 19:14:11 +01:00
|
|
|
rm -rf ${target_name}
|
2022-09-14 11:59:17 +02:00
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
|
2020-02-07 02:58:24 +01:00
|
|
|
function makefunc {
|
2020-05-18 10:11:50 +02:00
|
|
|
if ! ${MAKE} ${MAKE_FLAGS} "${EXTRA_FLAGS}" ${JOPTION} $@ 1>/dev/null; then
|
2020-04-19 10:58:55 +02:00
|
|
|
fail=1
|
2022-07-27 07:07:32 +02:00
|
|
|
else
|
|
|
|
exportandimport
|
2020-02-07 02:58:24 +01:00
|
|
|
fi
|
2020-09-12 21:18:19 +02:00
|
|
|
|
|
|
|
return $fail
|
2020-02-07 02:58:24 +01:00
|
|
|
}
|
|
|
|
|
2022-09-14 11:59:17 +02:00
|
|
|
function checkfunc {
|
|
|
|
build_cmd="${MAKE} ${MAKE_FLAGS} \"${EXTRA_FLAGS}\" ${JOPTION} 1>/dev/null"
|
|
|
|
|
|
|
|
local config_sub_path=$(echo "$config" | sed "s/:/\//")
|
|
|
|
local sub_target_name=${config_sub_path#$(dirname "${config_sub_path}")/}
|
|
|
|
local codechecker_dir=${ARTIFACTDIR}/codechecker_logs/${config_sub_path}
|
|
|
|
|
|
|
|
mkdir -p "${codechecker_dir}"
|
|
|
|
|
|
|
|
echo " Checking NuttX by Codechecker..."
|
|
|
|
CodeChecker check -b "${build_cmd}" -o "${codechecker_dir}/logs" -e sensitive --ctu
|
|
|
|
codecheck_ret=$?
|
|
|
|
echo " Storing analysis result to CodeChecker..."
|
|
|
|
echo " Generating HTML report..."
|
|
|
|
CodeChecker parse --export html --output "${codechecker_dir}/html" "${codechecker_dir}/logs" 1>/dev/null
|
|
|
|
echo " Compressing logs..."
|
|
|
|
compressartifacts "$(dirname "${codechecker_dir}")" "${sub_target_name}"
|
|
|
|
|
|
|
|
# If you need to stop CI, uncomment the following line.
|
|
|
|
# if [ $codecheck_ret -ne 0 ]; then
|
|
|
|
# fail=1
|
|
|
|
# fi
|
|
|
|
|
|
|
|
return $fail
|
|
|
|
}
|
|
|
|
|
2015-06-30 22:38:01 +02:00
|
|
|
# Clean up after the last build
|
|
|
|
|
|
|
|
function distclean {
|
2020-04-19 11:51:59 +02:00
|
|
|
echo " Cleaning..."
|
2023-07-13 10:32:56 +02:00
|
|
|
if [ -f .config ] || [ -f build/.config ]; then
|
|
|
|
if [ ${GITCLEAN} -eq 1 ] || [ ! -z ${cmake} ]; then
|
2020-04-19 11:51:59 +02:00
|
|
|
git -C $nuttx clean -xfdq
|
|
|
|
git -C $APPSDIR clean -xfdq
|
2020-04-03 04:35:30 +02:00
|
|
|
else
|
2020-05-18 10:11:50 +02:00
|
|
|
makefunc distclean
|
2020-04-21 18:39:56 +02:00
|
|
|
|
2020-04-28 18:56:17 +02:00
|
|
|
# Remove .version manually because this file is shipped with
|
2024-07-16 18:07:08 +02:00
|
|
|
# the release package and then distclean has to keep it.
|
2020-04-28 18:56:17 +02:00
|
|
|
|
|
|
|
rm -f .version
|
|
|
|
|
2020-04-21 18:39:56 +02:00
|
|
|
# Ensure nuttx and apps directory in clean state even with --ignored
|
|
|
|
|
2020-11-10 15:15:22 +01:00
|
|
|
if [ ${CHECKCLEAN} -ne 0 ]; then
|
|
|
|
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
|
2020-04-21 18:39:56 +02:00
|
|
|
fi
|
|
|
|
fi
|
2020-04-03 04:35:30 +02:00
|
|
|
fi
|
2020-01-05 17:29:59 +01:00
|
|
|
fi
|
2020-09-12 21:18:19 +02:00
|
|
|
|
|
|
|
return $fail
|
2015-06-30 22:38:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Configure for the next build
|
|
|
|
|
2023-07-13 10:32:56 +02:00
|
|
|
function configure_default {
|
2020-07-16 14:27:07 +02:00
|
|
|
if ! ./tools/configure.sh ${HOPTION} $config ${JOPTION} 1>/dev/null; then
|
2020-04-19 11:25:27 +02:00
|
|
|
fail=1
|
|
|
|
fi
|
2020-01-05 17:29:59 +01:00
|
|
|
|
|
|
|
if [ "X$toolchain" != "X" ]; then
|
2020-03-07 15:22:11 +01:00
|
|
|
setting=`grep _TOOLCHAIN_ $nuttx/.config | grep -v CONFIG_ARCH_TOOLCHAIN_* | grep =y`
|
2023-07-20 04:41:42 +02:00
|
|
|
original_toolchain=`echo $setting | cut -d'=' -f1`
|
|
|
|
if [ ! -z "$original_toolchain" ]; then
|
|
|
|
echo " Disabling $original_toolchain"
|
|
|
|
kconfig-tweak --file $nuttx/.config -d $original_toolchain
|
2015-07-01 22:32:59 +02:00
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2020-02-15 05:22:32 +01:00
|
|
|
echo " Enabling $toolchain"
|
2021-01-05 05:29:08 +01:00
|
|
|
kconfig-tweak --file $nuttx/.config -e $toolchain
|
2020-02-15 05:22:32 +01:00
|
|
|
|
2020-04-19 11:25:27 +02:00
|
|
|
makefunc olddefconfig
|
2020-01-05 17:29:59 +01:00
|
|
|
fi
|
2020-09-12 21:18:19 +02:00
|
|
|
|
|
|
|
return $fail
|
2015-06-30 22:38:01 +02:00
|
|
|
}
|
|
|
|
|
2023-07-13 10:32:56 +02:00
|
|
|
function configure_cmake {
|
|
|
|
if ! cmake -B build -DBOARD_CONFIG=$config -GNinja 1>/dev/null; then
|
|
|
|
cmake -B build -DBOARD_CONFIG=$config -GNinja
|
|
|
|
fail=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "X$toolchain" != "X" ]; then
|
|
|
|
setting=`grep _TOOLCHAIN_ $nuttx/build/.config | grep -v CONFIG_ARCH_TOOLCHAIN_* | grep =y`
|
2023-07-20 04:41:42 +02:00
|
|
|
original_toolchain=`echo $setting | cut -d'=' -f1`
|
|
|
|
if [ ! -z "$original_toolchain" ]; then
|
|
|
|
echo " Disabling $original_toolchain"
|
|
|
|
kconfig-tweak --file $nuttx/build/.config -d $original_toolchain
|
2023-07-13 10:32:56 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo " Enabling $toolchain"
|
|
|
|
kconfig-tweak --file $nuttx/build/.config -e $toolchain
|
|
|
|
fi
|
|
|
|
|
|
|
|
return $fail
|
|
|
|
}
|
|
|
|
|
|
|
|
function configure {
|
|
|
|
echo " Configuring..."
|
|
|
|
if [ ! -z ${cmake} ]; then
|
|
|
|
configure_cmake
|
|
|
|
else
|
|
|
|
configure_default
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-06-30 22:38:01 +02:00
|
|
|
# Perform the next build
|
|
|
|
|
2023-07-13 10:32:56 +02:00
|
|
|
function build_default {
|
2022-09-14 11:59:17 +02:00
|
|
|
if [ "${CODECHECKER}" -eq 1 ]; then
|
|
|
|
checkfunc
|
|
|
|
else
|
|
|
|
makefunc
|
|
|
|
fi
|
|
|
|
|
2020-10-26 05:18:43 +01:00
|
|
|
if [ ${SAVEARTIFACTS} -eq 1 ]; then
|
|
|
|
artifactconfigdir=$ARTIFACTDIR/$(echo $config | sed "s/:/\//")/
|
|
|
|
mkdir -p $artifactconfigdir
|
2020-10-29 04:06:40 +01:00
|
|
|
xargs -I "{}" cp "{}" $artifactconfigdir < $nuttx/nuttx.manifest
|
2020-10-26 05:18:43 +01:00
|
|
|
fi
|
2020-04-19 11:25:27 +02:00
|
|
|
|
2022-04-29 16:34:10 +02:00
|
|
|
return $fail
|
|
|
|
}
|
|
|
|
|
2023-07-13 10:32:56 +02:00
|
|
|
function build_cmake {
|
|
|
|
if ! cmake --build build 1>/dev/null; then
|
|
|
|
cmake --build build
|
|
|
|
fail=1
|
|
|
|
fi
|
|
|
|
|
2024-07-30 12:09:23 +02:00
|
|
|
if [ ${SAVEARTIFACTS} -eq 1 ]; then
|
|
|
|
artifactconfigdir=$ARTIFACTDIR/$(echo $config | sed "s/:/\//")/
|
|
|
|
mkdir -p $artifactconfigdir
|
|
|
|
cd $nuttx/build
|
|
|
|
xargs -I "{}" cp "{}" $artifactconfigdir < $nuttx/build/nuttx.manifest
|
|
|
|
cd $nuttx
|
|
|
|
fi
|
|
|
|
|
2023-07-13 10:32:56 +02:00
|
|
|
return $fail
|
|
|
|
}
|
|
|
|
|
|
|
|
function build {
|
|
|
|
echo " Building NuttX..."
|
|
|
|
if [ ! -z ${cmake} ]; then
|
|
|
|
build_cmake
|
|
|
|
else
|
|
|
|
build_default
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function refresh_default {
|
2020-04-19 11:25:27 +02:00
|
|
|
# Ensure defconfig in the canonical form
|
|
|
|
|
|
|
|
if ! ./tools/refresh.sh --silent $config; then
|
|
|
|
fail=1
|
|
|
|
fi
|
2020-04-19 11:51:59 +02:00
|
|
|
|
|
|
|
# Ensure nuttx and apps directory in clean state
|
|
|
|
|
2020-11-10 15:15:22 +01:00
|
|
|
if [ ${CHECKCLEAN} -ne 0 ]; then
|
|
|
|
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
|
2020-04-19 11:51:59 +02:00
|
|
|
fi
|
|
|
|
fi
|
2020-09-12 21:18:19 +02:00
|
|
|
|
|
|
|
return $fail
|
2015-06-30 22:38:01 +02:00
|
|
|
}
|
|
|
|
|
2023-07-13 10:32:56 +02:00
|
|
|
function refresh_cmake {
|
|
|
|
# Ensure defconfig in the canonical form
|
|
|
|
|
2023-07-20 04:41:42 +02:00
|
|
|
if [ "X$toolchain" != "X" ]; then
|
|
|
|
if [ ! -z "$original_toolchain" ]; then
|
|
|
|
kconfig-tweak --file $nuttx/build/.config -e $original_toolchain
|
|
|
|
fi
|
|
|
|
|
|
|
|
kconfig-tweak --file $nuttx/build/.config -d $toolchain
|
|
|
|
fi
|
|
|
|
|
2023-07-13 10:32:56 +02:00
|
|
|
if ! cmake --build build -t savedefconfig 1>/dev/null; then
|
|
|
|
cmake --build build -t savedefconfig
|
|
|
|
fail=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf build
|
|
|
|
|
|
|
|
# Ensure nuttx and apps directory in clean state
|
|
|
|
|
|
|
|
if [ ${CHECKCLEAN} -ne 0 ]; then
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Use -f option twice to remove git sub-repository
|
|
|
|
|
|
|
|
git -C $nuttx clean -f -xfdq
|
|
|
|
git -C $APPSDIR clean -f -xfdq
|
|
|
|
|
|
|
|
return $fail
|
|
|
|
}
|
|
|
|
|
|
|
|
function refresh {
|
|
|
|
# Ensure defconfig in the canonical form
|
|
|
|
|
|
|
|
if [ ! -z ${cmake} ]; then
|
|
|
|
refresh_cmake
|
|
|
|
else
|
|
|
|
refresh_default
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-01-31 03:12:10 +01:00
|
|
|
function run {
|
2023-07-13 10:32:56 +02:00
|
|
|
if [ ${RUN} -ne 0 ] && [ -z ${cmake} ]; then
|
2022-01-31 03:12:10 +01:00
|
|
|
run_script="$path/run"
|
|
|
|
if [ -x $run_script ]; then
|
|
|
|
echo " Running NuttX..."
|
|
|
|
if ! $run_script; then
|
|
|
|
fail=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
return $fail
|
|
|
|
}
|
2015-06-30 22:38:01 +02:00
|
|
|
# Coordinate the steps for the next build test
|
|
|
|
|
|
|
|
function dotest {
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "===================================================================================="
|
2020-01-20 17:51:26 +01:00
|
|
|
config=`echo $1 | cut -d',' -f1`
|
2020-10-26 18:44:23 +01:00
|
|
|
check=${HOST},${config/\//:}
|
|
|
|
|
2022-04-29 16:34:10 +02:00
|
|
|
skip=0
|
2020-10-26 18:44:23 +01:00
|
|
|
for re in $blacklist; do
|
|
|
|
if [[ "${check}" =~ ${re:1}$ ]]; then
|
|
|
|
echo "Skipping: $1"
|
2022-04-29 16:34:10 +02:00
|
|
|
skip=1
|
2020-04-01 06:19:07 +02:00
|
|
|
fi
|
2020-10-26 18:44:23 +01:00
|
|
|
done
|
2020-01-05 17:29:59 +01:00
|
|
|
|
2023-07-13 10:32:56 +02:00
|
|
|
unset cmake
|
2024-07-16 18:07:08 +02:00
|
|
|
if [ ${NINJACMAKE} -eq 1 ]; then
|
|
|
|
for l in $cmakelist; do
|
|
|
|
if [[ "${config/\//:}" == "${l}" ]]; then
|
|
|
|
echo "Cmake in present: $1"
|
|
|
|
cmake=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2023-07-13 10:32:56 +02:00
|
|
|
|
2020-10-26 18:44:23 +01:00
|
|
|
echo "Configuration/Tool: $1"
|
|
|
|
if [ ${PRINTLISTONLY} -eq 1 ]; then
|
|
|
|
return
|
|
|
|
fi
|
2020-01-05 17:29:59 +01:00
|
|
|
|
2020-10-26 18:44:23 +01:00
|
|
|
# Parse the next line
|
|
|
|
|
|
|
|
configdir=`echo $config | cut -s -d':' -f2`
|
|
|
|
if [ -z "${configdir}" ]; then
|
|
|
|
configdir=`echo $config | cut -s -d'/' -f2`
|
2020-01-05 17:29:59 +01:00
|
|
|
if [ -z "${configdir}" ]; then
|
2020-10-26 18:44:23 +01:00
|
|
|
echo "ERROR: Malformed configuration: ${config}"
|
|
|
|
showusage
|
2020-01-05 17:29:59 +01:00
|
|
|
else
|
2020-10-26 18:44:23 +01:00
|
|
|
boarddir=`echo $config | cut -d'/' -f1`
|
2020-01-05 17:29:59 +01:00
|
|
|
fi
|
2020-10-26 18:44:23 +01:00
|
|
|
else
|
|
|
|
boarddir=`echo $config | cut -d':' -f1`
|
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2020-10-26 18:44:23 +01:00
|
|
|
path=$nuttx/boards/*/*/$boarddir/configs/$configdir
|
|
|
|
if [ ! -r $path/defconfig ]; then
|
|
|
|
echo "ERROR: no configuration found at $path"
|
|
|
|
showusage
|
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2020-10-26 18:44:23 +01:00
|
|
|
unset toolchain
|
2023-07-20 04:41:42 +02:00
|
|
|
unset original_toolchain
|
2020-10-26 18:44:23 +01:00
|
|
|
if [ "X$config" != "X$1" ]; then
|
|
|
|
toolchain=`echo $1 | cut -d',' -f2`
|
|
|
|
if [ -z "$toolchain" ]; then
|
|
|
|
echo " Warning: no tool configuration"
|
2020-01-05 17:29:59 +01:00
|
|
|
fi
|
2020-10-26 18:44:23 +01:00
|
|
|
fi
|
2015-06-30 22:38:01 +02:00
|
|
|
|
2020-10-26 18:44:23 +01:00
|
|
|
# Perform the build test
|
2024-07-16 18:07:08 +02:00
|
|
|
echo $(date '+%Y-%m-%d %H:%M:%S')
|
2020-10-26 18:44:23 +01:00
|
|
|
echo "------------------------------------------------------------------------------------"
|
|
|
|
distclean
|
|
|
|
configure
|
2022-04-29 16:34:10 +02:00
|
|
|
if [ ${skip} -ne 1 ]; then
|
|
|
|
build
|
|
|
|
run
|
|
|
|
fi
|
|
|
|
refresh
|
2020-01-20 17:51:26 +01: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
|
2021-04-03 23:35:47 +02:00
|
|
|
dotest $i${line/"$dir"/}
|
2020-01-20 17:51:26 +01:00
|
|
|
done
|
2020-03-28 13:25:27 +01:00
|
|
|
else
|
2020-01-20 17:51:26 +01:00
|
|
|
dotest $line
|
|
|
|
fi
|
|
|
|
done
|
2015-06-30 22:38:01 +02:00
|
|
|
|
|
|
|
echo "===================================================================================="
|
2020-01-21 10:53:06 +01:00
|
|
|
|
|
|
|
exit $fail
|