From 0eadf598b4e5cd20761642effba0efe39713e3ad Mon Sep 17 00:00:00 2001 From: chao an Date: Thu, 13 Jul 2023 16:32:56 +0800 Subject: [PATCH] tools/ci: migrate some ci build configurations to CMake Signed-off-by: chao an --- .gitignore | 1 + CMakeLists.txt | 20 ++++--- cmake/nuttx_mkversion.cmake | 1 + tools/ci/testlist/arm-02.dat | 5 ++ tools/ci/testlist/arm-13.dat | 3 + tools/ci/testlist/sim-01.dat | 19 ++++++ tools/ci/testlist/sim-02.dat | 24 ++++++++ tools/testbuild.sh | 111 ++++++++++++++++++++++++++++++++--- 8 files changed, 168 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 95dc6e19b522a..7314e2736a4e1 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,4 @@ uImage .vscode .DS_Store tools/gdb/__pycache__ +/build diff --git a/CMakeLists.txt b/CMakeLists.txt index 72a7c2e1528b6..47ddeafb89f55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/nuttx_mkversion.cmake b/cmake/nuttx_mkversion.cmake index 94b1c81b7a417..7185fdc610a87 100644 --- a/cmake/nuttx_mkversion.cmake +++ b/cmake/nuttx_mkversion.cmake @@ -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) diff --git a/tools/ci/testlist/arm-02.dat b/tools/ci/testlist/arm-02.dat index 40f72bb0d3ea8..c3cc6bc9a53aa 100644 --- a/tools/ci/testlist/arm-02.dat +++ b/tools/ci/testlist/arm-02.dat @@ -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 diff --git a/tools/ci/testlist/arm-13.dat b/tools/ci/testlist/arm-13.dat index 08a3bcf246977..aeff062c2f35c 100644 --- a/tools/ci/testlist/arm-13.dat +++ b/tools/ci/testlist/arm-13.dat @@ -11,3 +11,6 @@ -lm3s6965-ek:qemu-nxflat -tms570ls31x-usb-kit:nsh -tlsr8278adk80d:nsh + +# Boards build by CMake +CMake,lm3s6965-ek:nsh diff --git a/tools/ci/testlist/sim-01.dat b/tools/ci/testlist/sim-01.dat index 5e74c1131e326..6a848fbffc716 100644 --- a/tools/ci/testlist/sim-01.dat +++ b/tools/ci/testlist/sim-01.dat @@ -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 diff --git a/tools/ci/testlist/sim-02.dat b/tools/ci/testlist/sim-02.dat index 1e07ebdf40372..2b9327f1b7776 100644 --- a/tools/ci/testlist/sim-02.dat +++ b/tools/ci/testlist/sim-02.dat @@ -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 diff --git a/tools/testbuild.sh b/tools/testbuild.sh index 0133d72f7dda3..5a38f1e687127 100755 --- a/tools/testbuild.sh +++ b/tools/testbuild.sh @@ -177,8 +177,9 @@ 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` +cmakelist=`grep "^[C|c][M|m][A|a][K|k][E|e]" $testfile | cut -d',' -f2 || true` cd $nuttx || { echo "ERROR: failed to CD to $nuttx"; exit 1; } @@ -265,8 +266,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 +300,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 +322,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 +370,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 +413,46 @@ 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 + + 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 +478,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