From 9f97793491110e74481e143d534cf8d98313635f Mon Sep 17 00:00:00 2001 From: Peter van der Perk Date: Wed, 2 Feb 2022 13:16:31 +0100 Subject: [PATCH] Generate C/C++ header to expose px4board kconfig symbols to the preprocessor --- cmake/kconfig.cmake | 6 ++++++ platforms/common/include/px4_platform_common/px4_config.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/cmake/kconfig.cmake b/cmake/kconfig.cmake index cb1ec7ac2e..71878e6ba3 100644 --- a/cmake/kconfig.cmake +++ b/cmake/kconfig.cmake @@ -11,6 +11,7 @@ set(MENUCONFIG_PATH ${PYTHON_EXECUTABLE} -m menuconfig CACHE INTERNAL "menuconfi set(GUICONFIG_PATH ${PYTHON_EXECUTABLE} -m guiconfig CACHE INTERNAL "guiconfig program" FORCE) set(DEFCONFIG_PATH ${PYTHON_EXECUTABLE} -m defconfig CACHE INTERNAL "defconfig program" FORCE) set(SAVEDEFCONFIG_PATH ${PYTHON_EXECUTABLE} -m savedefconfig CACHE INTERNAL "savedefconfig program" FORCE) +set(GENCONFIG_PATH ${PYTHON_EXECUTABLE} -m genconfig CACHE INTERNAL "genconfig program" FORCE) set(COMMON_KCONFIG_ENV_SETTINGS PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} @@ -47,6 +48,11 @@ if(EXISTS ${BOARD_DEFCONFIG}) OUTPUT_VARIABLE DUMMY_RESULTS) endif() + # Generate header file for C/C++ preprocessor + execute_process(COMMAND ${CMAKE_COMMAND} -E env ${COMMON_KCONFIG_ENV_SETTINGS} + ${GENCONFIG_PATH} --header-path ${PX4_BINARY_DIR}/px4_boardconfig.h + WORKING_DIRECTORY ${PX4_SOURCE_DIR} + OUTPUT_VARIABLE DUMMY_RESULTS) # parse board config options for cmake file(STRINGS ${BOARD_CONFIG} ConfigContents) diff --git a/platforms/common/include/px4_platform_common/px4_config.h b/platforms/common/include/px4_platform_common/px4_config.h index aac0a9be52..f66304bf78 100644 --- a/platforms/common/include/px4_platform_common/px4_config.h +++ b/platforms/common/include/px4_platform_common/px4_config.h @@ -52,3 +52,6 @@ #include #endif + +/* PX4 board kconfig symbols */ +#include