mirror of
https://github.com/apache/nuttx.git
synced 2025-12-08 02:32:54 +08:00
tools/ci: migrate some ci build configurations to CMake
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -177,9 +177,13 @@ fi
|
||||
|
||||
export APPSDIR
|
||||
|
||||
testlist=`grep -v -E "^(-|#)" $testfile || true`
|
||||
testlist=`grep -v -E "^(-|#)|^[C|c][M|m][A|a][K|k][E|e]" $testfile || true`
|
||||
blacklist=`grep "^-" $testfile || true`
|
||||
|
||||
if [ "X$HOST" == "XLinux" ]; then
|
||||
cmakelist=`grep "^[C|c][M|m][A|a][K|k][E|e]" $testfile | cut -d',' -f2 || true`
|
||||
fi
|
||||
|
||||
cd $nuttx || { echo "ERROR: failed to CD to $nuttx"; exit 1; }
|
||||
|
||||
function exportandimport {
|
||||
@@ -265,8 +269,8 @@ function checkfunc {
|
||||
|
||||
function distclean {
|
||||
echo " Cleaning..."
|
||||
if [ -f .config ]; then
|
||||
if [ ${GITCLEAN} -eq 1 ]; then
|
||||
if [ -f .config ] || [ -f build/.config ]; then
|
||||
if [ ${GITCLEAN} -eq 1 ] || [ ! -z ${cmake} ]; then
|
||||
git -C $nuttx clean -xfdq
|
||||
git -C $APPSDIR clean -xfdq
|
||||
else
|
||||
@@ -299,8 +303,7 @@ function distclean {
|
||||
|
||||
# Configure for the next build
|
||||
|
||||
function configure {
|
||||
echo " Configuring..."
|
||||
function configure_default {
|
||||
if ! ./tools/configure.sh ${HOPTION} $config ${JOPTION} 1>/dev/null; then
|
||||
fail=1
|
||||
fi
|
||||
@@ -322,10 +325,39 @@ function configure {
|
||||
return $fail
|
||||
}
|
||||
|
||||
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`
|
||||
varname=`echo $setting | cut -d'=' -f1`
|
||||
if [ ! -z "$varname" ]; then
|
||||
echo " Disabling $varname"
|
||||
kconfig-tweak --file $nuttx/build/.config -d $varname
|
||||
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
|
||||
}
|
||||
|
||||
# Perform the next build
|
||||
|
||||
function build {
|
||||
echo " Building NuttX..."
|
||||
function build_default {
|
||||
if [ "${CODECHECKER}" -eq 1 ]; then
|
||||
checkfunc
|
||||
else
|
||||
@@ -341,7 +373,25 @@ function build {
|
||||
return $fail
|
||||
}
|
||||
|
||||
function refresh {
|
||||
function build_cmake {
|
||||
if ! cmake --build build 1>/dev/null; then
|
||||
cmake --build build
|
||||
fail=1
|
||||
fi
|
||||
|
||||
return $fail
|
||||
}
|
||||
|
||||
function build {
|
||||
echo " Building NuttX..."
|
||||
if [ ! -z ${cmake} ]; then
|
||||
build_cmake
|
||||
else
|
||||
build_default
|
||||
fi
|
||||
}
|
||||
|
||||
function refresh_default {
|
||||
# Ensure defconfig in the canonical form
|
||||
|
||||
if ! ./tools/refresh.sh --silent $config; then
|
||||
@@ -366,8 +416,51 @@ function refresh {
|
||||
return $fail
|
||||
}
|
||||
|
||||
function refresh_cmake {
|
||||
# Ensure defconfig in the canonical form
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
function run {
|
||||
if [ ${RUN} -ne 0 ]; then
|
||||
if [ ${RUN} -ne 0 ] && [ -z ${cmake} ]; then
|
||||
run_script="$path/run"
|
||||
if [ -x $run_script ]; then
|
||||
echo " Running NuttX..."
|
||||
@@ -393,6 +486,14 @@ function dotest {
|
||||
fi
|
||||
done
|
||||
|
||||
unset cmake
|
||||
for l in $cmakelist; do
|
||||
if [[ "${config/\//:}" == "${l}" ]]; then
|
||||
echo "Cmake in present: $1"
|
||||
cmake=1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Configuration/Tool: $1"
|
||||
if [ ${PRINTLISTONLY} -eq 1 ]; then
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user