diff --git a/platforms/nuttx/NuttX/CMakeLists.txt b/platforms/nuttx/NuttX/CMakeLists.txt index 2d7156968a..87fb9c5620 100644 --- a/platforms/nuttx/NuttX/CMakeLists.txt +++ b/platforms/nuttx/NuttX/CMakeLists.txt @@ -129,7 +129,7 @@ add_custom_command( ${CMAKE_CURRENT_BINARY_DIR}/nuttx_copy.stamp ${CMAKE_CURRENT_BINARY_DIR}/apps_copy.stamp WORKING_DIRECTORY ${NUTTX_DIR} - COMMENT "Copying NuttX config ${NUTTX_CONFIG} and configuring" + COMMENT "Copying NuttX config ${NUTTX_CONFIG}" ) # NuttX defconfig @@ -141,14 +141,13 @@ if (NOT config_expanded) add_custom_command( OUTPUT ${NUTTX_DIR}/.config COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NUTTX_DEFCONFIG} ${NUTTX_DIR}/.config - COMMAND kconfig-tweak --set-str CONFIG_APPS_DIR "../apps" - COMMAND make --no-print-directory --silent -C ${NUTTX_DIR} CONFIG_ARCH_BOARD_CUSTOM=y olddefconfig + COMMAND PATH=${CMAKE_CURRENT_SOURCE_DIR}/tools:$ENV{PATH} make --no-print-directory --silent -C ${NUTTX_DIR} CONFIG_ARCH_BOARD_CUSTOM=y CONFIG_APPS_DIR="../apps" olddefconfig > nuttx_olddefconfig.log DEPENDS ${NUTTX_DEFCONFIG} ${NUTTX_DIR}/configs/dummy/Kconfig ${CMAKE_CURRENT_BINARY_DIR}/nuttx_copy_config_dir.stamp WORKING_DIRECTORY ${NUTTX_DIR} - COMMENT "Copying NuttX config ${NUTTX_CONFIG} and configuring" + COMMENT "Copying NuttX compressed config ${NUTTX_CONFIG} and inflating" ) else() # copy uncompressed PX4 defconfig into nuttx @@ -160,7 +159,7 @@ else() ${NUTTX_DIR}/configs/dummy/Kconfig ${CMAKE_CURRENT_BINARY_DIR}/nuttx_copy_config_dir.stamp WORKING_DIRECTORY ${NUTTX_DIR} - COMMENT "Copying NuttX uncompressed config ${NUTTX_CONFIG} and configuring" + COMMENT "Copying NuttX uncompressed config ${NUTTX_CONFIG}" ) endif() @@ -189,11 +188,8 @@ else() endif() # context -add_custom_command( - OUTPUT - ${NUTTX_DIR}/include/nuttx/version.h - ${NUTTX_DIR}/include/nuttx/config.h - COMMAND make ${nuttx_build_options} --no-print-directory CONFIG_ARCH_BOARD_CUSTOM=y context ${nuttx_build_output} +add_custom_command(OUTPUT ${NUTTX_DIR}/include/nuttx/version.h ${NUTTX_DIR}/include/nuttx/config.h + COMMAND make ${nuttx_build_options} --no-print-directory CONFIG_ARCH_BOARD_CUSTOM=y context > nuttx_context.log DEPENDS ${NUTTX_DIR}/.config WORKING_DIRECTORY ${NUTTX_DIR} ${nuttx_build_uses_terminal} @@ -251,7 +247,7 @@ endif() # libapps.a add_custom_command(OUTPUT ${APPS_DIR}/libapps.a ${APPS_DIR}/platform/.built COMMAND find ${APPS_DIR} -name \*.o -delete - COMMAND make ${nuttx_build_options} --no-print-directory -C ../apps TOPDIR="${NUTTX_DIR}" libapps.a ${nuttx_build_output} + COMMAND make ${nuttx_build_options} --no-print-directory -C ../apps TOPDIR="${NUTTX_DIR}" libapps.a > nuttx_apps.log DEPENDS ${nuttx_builtin_list} ${NUTTX_DIR}/include/nuttx/version.h ${NUTTX_DIR}/include/nuttx/config.h WORKING_DIRECTORY ${NUTTX_DIR} ${nuttx_build_uses_terminal} diff --git a/platforms/nuttx/NuttX/tools/kconfig-conf b/platforms/nuttx/NuttX/tools/kconfig-conf new file mode 100755 index 0000000000..1ec40c570e --- /dev/null +++ b/platforms/nuttx/NuttX/tools/kconfig-conf @@ -0,0 +1,14 @@ +#! /bin/bash + +echo "DEBUG: kconfiglib kconfig-conf wrapper, arguments: ${@}" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +export APPSDIR="`pwd`/../apps" +export CONFIG_ARCH_BOARD_CUSTOM=y + +if [ "${1}" = "--olddefconfig" ]; then + PYTHONPATH=${DIR} python ${DIR}/olddefconfig.py > /dev/null +else + echo "ERROR: ${@} unsupported" + exit 1 +fi diff --git a/platforms/nuttx/NuttX/tools/kconfig-tweak b/platforms/nuttx/NuttX/tools/kconfig-tweak new file mode 100755 index 0000000000..4f950fd38b --- /dev/null +++ b/platforms/nuttx/NuttX/tools/kconfig-tweak @@ -0,0 +1,12 @@ +#! /bin/bash + +echo "DEBUG: kconfiglib kconfig-tweak wrapper, arguments: ${@}" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +export APPSDIR="`pwd`/../apps" + +# Example: +# kconfig-tweak --set-str CONFIG_APPS_DIR ../apps +# becomes +# python setconfig.py CONFIG_APPS_DIR=../apps +PYTHONPATH=${DIR} python ${DIR}/setconfig.py --kconfig=Kconfig ${2}=${3} > /dev/null diff --git a/platforms/nuttx/NuttX/tools/kconfiglib.py b/platforms/nuttx/NuttX/tools/kconfiglib.py new file mode 100644 index 0000000000..14126988e0 --- /dev/null +++ b/platforms/nuttx/NuttX/tools/kconfiglib.py @@ -0,0 +1,6661 @@ +# Copyright (c) 2011-2019, Ulf Magnusson +# SPDX-License-Identifier: ISC + +""" +Overview +======== + +Kconfiglib is a Python 2/3 library for scripting and extracting information +from Kconfig (https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt) +configuration systems. + +See the homepage at https://github.com/ulfalizer/Kconfiglib for a longer +overview. + +Using Kconfiglib on the Linux kernel with the Makefile targets +============================================================== + +For the Linux kernel, a handy interface is provided by the +scripts/kconfig/Makefile patch, which can be applied with either 'git am' or +the 'patch' utility: + + $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | git am + $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | patch -p1 + +Warning: Not passing -p1 to patch will cause the wrong file to be patched. + +Please tell me if the patch does not apply. It should be trivial to apply +manually, as it's just a block of text that needs to be inserted near the other +*conf: targets in scripts/kconfig/Makefile. + +Look further down for a motivation for the Makefile patch and for instructions +on how you can use Kconfiglib without it. + +If you do not wish to install Kconfiglib via pip, the Makefile patch is set up +so that you can also just clone Kconfiglib into the kernel root: + + $ git clone git://github.com/ulfalizer/Kconfiglib.git + $ git am Kconfiglib/makefile.patch (or 'patch -p1 < Kconfiglib/makefile.patch') + +Warning: The directory name Kconfiglib/ is significant in this case, because +it's added to PYTHONPATH by the new targets in makefile.patch. + +The targets added by the Makefile patch are described in the following +sections. + + +make kmenuconfig +---------------- + +This target runs the curses menuconfig interface with Python 3 (Python 2 is +currently not supported for the menuconfig). + + +make [ARCH=] iscriptconfig +-------------------------------- + +This target gives an interactive Python prompt where a Kconfig instance has +been preloaded and is available in 'kconf'. To change the Python interpreter +used, pass PYTHONCMD= to make. The default is "python". + +To get a feel for the API, try evaluating and printing the symbols in +kconf.defined_syms, and explore the MenuNode menu tree starting at +kconf.top_node by following 'next' and 'list' pointers. + +The item contained in a menu node is found in MenuNode.item (note that this can +be one of the constants kconfiglib.MENU and kconfiglib.COMMENT), and all +symbols and choices have a 'nodes' attribute containing their menu nodes +(usually only one). Printing a menu node will print its item, in Kconfig +format. + +If you want to look up a symbol by name, use the kconf.syms dictionary. + + +make scriptconfig SCRIPT=