Skip to content

Commit dc6f140

Browse files
anchaoxiaoxiang781216
authored andcommitted
tools/ci: migrate some ci build configurations to CMake
Signed-off-by: chao an <[email protected]>
1 parent f10b54a commit dc6f140

File tree

7 files changed

+173
-16
lines changed

7 files changed

+173
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ uImage
6060
.vscode
6161
.DS_Store
6262
tools/gdb/__pycache__
63+
/build

CMakeLists.txt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/.config OR NOT "${NUTTX_DEFCONFIG}" STREQUAL
321321
# Do olddefconfig step to expand the abbreviated defconfig into normal config
322322
execute_process(
323323
COMMAND olddefconfig
324+
ERROR_VARIABLE KCONFIG_ERROR
324325
OUTPUT_VARIABLE KCONFIG_OUTPUT
325326
RESULT_VARIABLE KCONFIG_STATUS
326327
WORKING_DIRECTORY ${NUTTX_DIR})
@@ -333,6 +334,15 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/.config OR NOT "${NUTTX_DEFCONFIG}" STREQUAL
333334
configure_file(${CMAKE_BINARY_DIR}/.config ${CMAKE_BINARY_DIR}/.config.orig
334335
COPYONLY)
335336

337+
string(REPLACE "\n" ";" KCONFIG_ESTRING ${KCONFIG_ERROR})
338+
foreach(estring ${KCONFIG_ESTRING})
339+
string(REGEX MATCH "the 'modules' option is not supported" result
340+
${estring})
341+
if(NOT result)
342+
message(WARNING "Kconfig Configuration Error: ${estring}")
343+
endif()
344+
endforeach()
345+
336346
if(KCONFIG_STATUS AND NOT KCONFIG_STATUS EQUAL 0)
337347
message(
338348
FATAL_ERROR
@@ -544,13 +554,9 @@ if(DEFINED PREPROCES)
544554
add_custom_command(
545555
OUTPUT ${LD_SCRIPT_TMP}
546556
DEPENDS ${ldscript}
547-
COMMAND
548-
${PREPROCES}
549-
-I${CMAKE_BINARY_DIR}/include
550-
-I${NUTTX_CHIP_ABS_DIR}
551-
${ldscript} > ${LD_SCRIPT_TMP}
552-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
553-
)
557+
COMMAND ${PREPROCES} -I${CMAKE_BINARY_DIR}/include -I${NUTTX_CHIP_ABS_DIR}
558+
${ldscript} > ${LD_SCRIPT_TMP}
559+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
554560

555561
add_custom_target(ldscript_tmp DEPENDS ${LD_SCRIPT_TMP})
556562
add_dependencies(nuttx ldscript_tmp)

cmake/nuttx_mkversion.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ endif()
2626
execute_process(
2727
COMMAND git -C ${NUTTX_DIR} describe --match "nuttx-*"
2828
WORKING_DIRECTORY ${NUTTX_DIR}
29+
ERROR_VARIABLE NUTTX_ERROR
2930
OUTPUT_VARIABLE NUTTX_VERSION
3031
RESULT_VARIABLE VERSION_STATUS)
3132

tools/ci/testlist/arm-02.dat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
/arm/[i-k]*,CONFIG_ARM_TOOLCHAIN_GNU_EABI
2+
3+
# Boards build by CMake
4+
CMake,sabre-6quad:smp
5+
CMake,sabre-6quad:coredump
6+
CMake,sabre-6quad:nsh

tools/ci/testlist/sim-01.dat

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,22 @@
3232

3333
# Skip WebAssembly Micro Runtime
3434
-Darwin,sim:wamr
35+
36+
# Boards build by CMake
37+
CMake,sim:alsa
38+
CMake,sim:bluetooth
39+
CMake,sim:bthcisock
40+
CMake,sim:dynconns
41+
CMake,sim:fb
42+
CMake,sim:foc
43+
CMake,sim:ipforward
44+
CMake,sim:linuxi2c
45+
CMake,sim:linuxspi
46+
CMake,sim:minibasic
47+
CMake,sim:mount
48+
CMake,sim:mtdpart
49+
CMake,sim:mtdrwb
50+
CMake,sim:nettest
51+
CMake,sim:note
52+
CMake,sim:nsh
53+
CMake,sim:nxffs

tools/ci/testlist/sim-02.dat

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,27 @@
2323
# macOS doesn't support simusb simhost
2424
-Darwin,sim:usbdev
2525
-Darwin,sim:usbhost
26+
27+
# Boards build by CMake
28+
CMake,sim:ostest
29+
CMake,sim:ostest_oneholder
30+
CMake,sim:pf_ieee802154
31+
CMake,sim:pktradio
32+
CMake,sim:rc
33+
CMake,sim:romfs
34+
CMake,sim:rtptools
35+
CMake,sim:sensor
36+
CMake,sim:sixlowpan
37+
CMake,sim:smartfs
38+
CMake,sim:smp
39+
CMake,sim:spiffs
40+
CMake,sim:tcpblaster
41+
CMake,sim:tcploop
42+
CMake,sim:udgram
43+
CMake,sim:unionfs
44+
CMake,sim:usbdev
45+
CMake,sim:usbhost
46+
CMake,sim:userfs
47+
CMake,sim:usrsocktest
48+
CMake,sim:ustream
49+
CMake,sim:vncserver

tools/testbuild.sh

Lines changed: 110 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,13 @@ fi
177177

178178
export APPSDIR
179179

180-
testlist=`grep -v -E "^(-|#)" $testfile || true`
180+
testlist=`grep -v -E "^(-|#)|^[C|c][M|m][A|a][K|k][E|e]" $testfile || true`
181181
blacklist=`grep "^-" $testfile || true`
182182

183+
if [ "X$HOST" == "XLinux" ]; then
184+
cmakelist=`grep "^[C|c][M|m][A|a][K|k][E|e]" $testfile | cut -d',' -f2 || true`
185+
fi
186+
183187
cd $nuttx || { echo "ERROR: failed to CD to $nuttx"; exit 1; }
184188

185189
function exportandimport {
@@ -265,8 +269,8 @@ function checkfunc {
265269

266270
function distclean {
267271
echo " Cleaning..."
268-
if [ -f .config ]; then
269-
if [ ${GITCLEAN} -eq 1 ]; then
272+
if [ -f .config ] || [ -f build/.config ]; then
273+
if [ ${GITCLEAN} -eq 1 ] || [ ! -z ${cmake} ]; then
270274
git -C $nuttx clean -xfdq
271275
git -C $APPSDIR clean -xfdq
272276
else
@@ -299,8 +303,7 @@ function distclean {
299303

300304
# Configure for the next build
301305

302-
function configure {
303-
echo " Configuring..."
306+
function configure_default {
304307
if ! ./tools/configure.sh ${HOPTION} $config ${JOPTION} 1>/dev/null; then
305308
fail=1
306309
fi
@@ -322,10 +325,39 @@ function configure {
322325
return $fail
323326
}
324327

328+
function configure_cmake {
329+
if ! cmake -B build -DBOARD_CONFIG=$config -GNinja 1>/dev/null; then
330+
cmake -B build -DBOARD_CONFIG=$config -GNinja
331+
fail=1
332+
fi
333+
334+
if [ "X$toolchain" != "X" ]; then
335+
setting=`grep _TOOLCHAIN_ $nuttx/build/.config | grep -v CONFIG_ARCH_TOOLCHAIN_* | grep =y`
336+
varname=`echo $setting | cut -d'=' -f1`
337+
if [ ! -z "$varname" ]; then
338+
echo " Disabling $varname"
339+
kconfig-tweak --file $nuttx/build/.config -d $varname
340+
fi
341+
342+
echo " Enabling $toolchain"
343+
kconfig-tweak --file $nuttx/build/.config -e $toolchain
344+
fi
345+
346+
return $fail
347+
}
348+
349+
function configure {
350+
echo " Configuring..."
351+
if [ ! -z ${cmake} ]; then
352+
configure_cmake
353+
else
354+
configure_default
355+
fi
356+
}
357+
325358
# Perform the next build
326359

327-
function build {
328-
echo " Building NuttX..."
360+
function build_default {
329361
if [ "${CODECHECKER}" -eq 1 ]; then
330362
checkfunc
331363
else
@@ -341,7 +373,25 @@ function build {
341373
return $fail
342374
}
343375

344-
function refresh {
376+
function build_cmake {
377+
if ! cmake --build build 1>/dev/null; then
378+
cmake --build build
379+
fail=1
380+
fi
381+
382+
return $fail
383+
}
384+
385+
function build {
386+
echo " Building NuttX..."
387+
if [ ! -z ${cmake} ]; then
388+
build_cmake
389+
else
390+
build_default
391+
fi
392+
}
393+
394+
function refresh_default {
345395
# Ensure defconfig in the canonical form
346396

347397
if ! ./tools/refresh.sh --silent $config; then
@@ -366,8 +416,51 @@ function refresh {
366416
return $fail
367417
}
368418

419+
function refresh_cmake {
420+
# Ensure defconfig in the canonical form
421+
422+
if ! cmake --build build -t savedefconfig 1>/dev/null; then
423+
cmake --build build -t savedefconfig
424+
fail=1
425+
fi
426+
427+
rm -rf build
428+
429+
# Ensure nuttx and apps directory in clean state
430+
431+
if [ ${CHECKCLEAN} -ne 0 ]; then
432+
if [ -d $nuttx/.git ] || [ -d $APPSDIR/.git ]; then
433+
if [[ -n $(git -C $nuttx status -s) ]]; then
434+
git -C $nuttx status
435+
fail=1
436+
fi
437+
if [[ -n $(git -C $APPSDIR status -s) ]]; then
438+
git -C $APPSDIR status
439+
fail=1
440+
fi
441+
fi
442+
fi
443+
444+
# Use -f option twice to remove git sub-repository
445+
446+
git -C $nuttx clean -f -xfdq
447+
git -C $APPSDIR clean -f -xfdq
448+
449+
return $fail
450+
}
451+
452+
function refresh {
453+
# Ensure defconfig in the canonical form
454+
455+
if [ ! -z ${cmake} ]; then
456+
refresh_cmake
457+
else
458+
refresh_default
459+
fi
460+
}
461+
369462
function run {
370-
if [ ${RUN} -ne 0 ]; then
463+
if [ ${RUN} -ne 0 ] && [ -z ${cmake} ]; then
371464
run_script="$path/run"
372465
if [ -x $run_script ]; then
373466
echo " Running NuttX..."
@@ -393,6 +486,14 @@ function dotest {
393486
fi
394487
done
395488

489+
unset cmake
490+
for l in $cmakelist; do
491+
if [[ "${config/\//:}" == "${l}" ]]; then
492+
echo "Cmake in present: $1"
493+
cmake=1
494+
fi
495+
done
496+
396497
echo "Configuration/Tool: $1"
397498
if [ ${PRINTLISTONLY} -eq 1 ]; then
398499
return

0 commit comments

Comments
 (0)