tools/ci: migrate some ci build configurations to CMake

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-07-13 16:32:56 +08:00 committed by Xiang Xiao
parent f10b54a081
commit dc6f1406d1
7 changed files with 173 additions and 16 deletions

1
.gitignore vendored
View File

@ -60,3 +60,4 @@ uImage
.vscode
.DS_Store
tools/gdb/__pycache__
/build

View File

@ -321,6 +321,7 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/.config OR NOT "${NUTTX_DEFCONFIG}" STREQUAL
# Do olddefconfig step to expand the abbreviated defconfig into normal config
execute_process(
COMMAND olddefconfig
ERROR_VARIABLE KCONFIG_ERROR
OUTPUT_VARIABLE KCONFIG_OUTPUT
RESULT_VARIABLE KCONFIG_STATUS
WORKING_DIRECTORY ${NUTTX_DIR})
@ -333,6 +334,15 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/.config OR NOT "${NUTTX_DEFCONFIG}" STREQUAL
configure_file(${CMAKE_BINARY_DIR}/.config ${CMAKE_BINARY_DIR}/.config.orig
COPYONLY)
string(REPLACE "\n" ";" KCONFIG_ESTRING ${KCONFIG_ERROR})
foreach(estring ${KCONFIG_ESTRING})
string(REGEX MATCH "the 'modules' option is not supported" result
${estring})
if(NOT result)
message(WARNING "Kconfig Configuration Error: ${estring}")
endif()
endforeach()
if(KCONFIG_STATUS AND NOT KCONFIG_STATUS EQUAL 0)
message(
FATAL_ERROR
@ -544,13 +554,9 @@ if(DEFINED PREPROCES)
add_custom_command(
OUTPUT ${LD_SCRIPT_TMP}
DEPENDS ${ldscript}
COMMAND
${PREPROCES}
-I${CMAKE_BINARY_DIR}/include
-I${NUTTX_CHIP_ABS_DIR}
${ldscript} > ${LD_SCRIPT_TMP}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
COMMAND ${PREPROCES} -I${CMAKE_BINARY_DIR}/include -I${NUTTX_CHIP_ABS_DIR}
${ldscript} > ${LD_SCRIPT_TMP}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(ldscript_tmp DEPENDS ${LD_SCRIPT_TMP})
add_dependencies(nuttx ldscript_tmp)

View File

@ -26,6 +26,7 @@ endif()
execute_process(
COMMAND git -C ${NUTTX_DIR} describe --match "nuttx-*"
WORKING_DIRECTORY ${NUTTX_DIR}
ERROR_VARIABLE NUTTX_ERROR
OUTPUT_VARIABLE NUTTX_VERSION
RESULT_VARIABLE VERSION_STATUS)

View File

@ -1 +1,6 @@
/arm/[i-k]*,CONFIG_ARM_TOOLCHAIN_GNU_EABI
# Boards build by CMake
CMake,sabre-6quad:smp
CMake,sabre-6quad:coredump
CMake,sabre-6quad:nsh

View File

@ -32,3 +32,22 @@
# Skip WebAssembly Micro Runtime
-Darwin,sim:wamr
# Boards build by CMake
CMake,sim:alsa
CMake,sim:bluetooth
CMake,sim:bthcisock
CMake,sim:dynconns
CMake,sim:fb
CMake,sim:foc
CMake,sim:ipforward
CMake,sim:linuxi2c
CMake,sim:linuxspi
CMake,sim:minibasic
CMake,sim:mount
CMake,sim:mtdpart
CMake,sim:mtdrwb
CMake,sim:nettest
CMake,sim:note
CMake,sim:nsh
CMake,sim:nxffs

View File

@ -23,3 +23,27 @@
# macOS doesn't support simusb simhost
-Darwin,sim:usbdev
-Darwin,sim:usbhost
# Boards build by CMake
CMake,sim:ostest
CMake,sim:ostest_oneholder
CMake,sim:pf_ieee802154
CMake,sim:pktradio
CMake,sim:rc
CMake,sim:romfs
CMake,sim:rtptools
CMake,sim:sensor
CMake,sim:sixlowpan
CMake,sim:smartfs
CMake,sim:smp
CMake,sim:spiffs
CMake,sim:tcpblaster
CMake,sim:tcploop
CMake,sim:udgram
CMake,sim:unionfs
CMake,sim:usbdev
CMake,sim:usbhost
CMake,sim:userfs
CMake,sim:usrsocktest
CMake,sim:ustream
CMake,sim:vncserver

View File

@ -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