Skip to content

Commit

Permalink
tools/ci: migrate some ci build configurations to CMake
Browse files Browse the repository at this point in the history
Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao committed Jul 14, 2023
1 parent ec88317 commit 0eadf59
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ uImage
.vscode
.DS_Store
tools/gdb/__pycache__
/build
20 changes: 13 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cmake/nuttx_mkversion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions tools/ci/testlist/arm-02.dat
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tools/ci/testlist/arm-13.dat
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
-lm3s6965-ek:qemu-nxflat
-tms570ls31x-usb-kit:nsh
-tlsr8278adk80d:nsh

# Boards build by CMake
CMake,lm3s6965-ek:nsh
19 changes: 19 additions & 0 deletions tools/ci/testlist/sim-01.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 24 additions & 0 deletions tools/ci/testlist/sim-02.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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
111 changes: 102 additions & 9 deletions tools/testbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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..."
Expand All @@ -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
Expand Down

0 comments on commit 0eadf59

Please sign in to comment.