diff --git a/Tools/nuttx_defconf_tool.sh b/Tools/nuttx_defconf_tool.sh new file mode 100755 index 0000000000..125299712e --- /dev/null +++ b/Tools/nuttx_defconf_tool.sh @@ -0,0 +1,48 @@ +#! /bin/bash + +if [ $# -eq 0 ] + then + echo "Usage: $0 " + exit 1 +fi +configsdir=nuttx-configs +defconf=$1 +configsrc=$configsdir${defconf##*$configsdir} + +if [ ! -f $defconf ] + then + echo "$defconf does not exist" + exit 2 +fi + + +lastconf=$defconf.last +chunk=$defconf.chunk + +echo $configsrc +git show HEAD:$configsrc > $lastconf + +lead='^# Board Selection$' +tail='^# Common Board Options$' + +cat $lastconf | sed -n "/$lead/,/$tail/p" | sed '1d;$d' > $chunk + +echo "Fix up Board Selection" +sed -i -e "/$lead/,/$tail/{ /$lead/{p; r $chunk + }; /$tail/p; d }" $defconf + + +if grep --quiet CONFIG_START_YEAR $lastconf ; then + lead='^CONFIG_START_YEAR=' + tail='^CONFIG_START_DAY=' + cat $lastconf | sed -n "/$lead/,/$tail/p" > $chunk + lead='^# Clocks and Timers$' + echo "Fix up Clocks and Timers" + sed -i -e "/$lead/{N;{r $chunk + }}" $defconf +else + echo not found +fi + +rm $lastconf +rm $chunk \ No newline at end of file diff --git a/cmake/nuttx/px4_impl_nuttx.cmake b/cmake/nuttx/px4_impl_nuttx.cmake index aafbfc1d23..a41e74095a 100644 --- a/cmake/nuttx/px4_impl_nuttx.cmake +++ b/cmake/nuttx/px4_impl_nuttx.cmake @@ -304,14 +304,23 @@ function(px4_nuttx_add_export) WORKING_DIRECTORY ${PX4_BINARY_DIR} COMMENT "Configuring NuttX for ${CONFIG} with ${config_nuttx_config}") - # manual reconfigure helper - add_custom_target(reconfigure_nuttx_${CONFIG} + # manual reconfigure helpers + add_custom_target(oldconfig_${CONFIG} COMMAND cd ${nuttx_src}/nuttx COMMAND ${MAKE} -C ${nuttx_src}/nuttx CONFIG_ARCH_BOARD=${CONFIG} oldconfig + COMMAND ${CP} ${nuttx_src}/nuttx/.config ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig + COMMAND ${PX4_SOURCE_DIR}/Tools/nuttx_defconf_tool.sh ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig + DEPENDS ${nuttx_src}/nuttx/.config + COMMENT "Running NuttX make oldconfig for ${CONFIG} with ${config_nuttx_config}" + USES_TERMINAL) + + add_custom_target(menuconfig_${CONFIG} + COMMAND cd ${nuttx_src}/nuttx COMMAND ${MAKE} -C ${nuttx_src}/nuttx CONFIG_ARCH_BOARD=${CONFIG} menuconfig COMMAND ${CP} ${nuttx_src}/nuttx/.config ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig + COMMAND ${PX4_SOURCE_DIR}/Tools/nuttx_defconf_tool.sh ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig DEPENDS ${nuttx_src}/nuttx/.config - COMMENT "Reconfiguring NuttX for ${CONFIG} with ${config_nuttx_config}" + COMMENT "Running NuttX make menuconfig for ${CONFIG} with ${config_nuttx_config}" USES_TERMINAL) # build and export