mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
cmake: add command to get config value
This commit is contained in:
parent
de9bb5a160
commit
7493bd2e28
@ -980,6 +980,14 @@ The call requires the target chip to be specified with *target* argument. Option
|
||||
Specify the executable *executable* for ESP-IDF build. This attaches additional targets such as dependencies related to
|
||||
flashing, generating additional binary files, etc. Should be called after ``idf_build_process``.
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
idf_build_get_config(var config [GENERATOR_EXPRESSION])
|
||||
|
||||
Get the value of the specified config. Much like build properties, specifying
|
||||
*GENERATOR_EXPRESSION* will retrieve the generator expression string for that config, instead of the actual value, which
|
||||
can be used with CMake commands that support generator expressions. Actual config values are only known after call to `idf_build_process`, however.
|
||||
|
||||
.. _cmake-build-properties:
|
||||
|
||||
idf-build-properties
|
||||
|
@ -297,6 +297,23 @@ macro(__build_set_default var default)
|
||||
unset(_var)
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Import configs as build instance properties so that they are accessible
|
||||
# using idf_build_get_config(). Config has to have been generated before calling
|
||||
# this command.
|
||||
#
|
||||
function(__build_import_configs)
|
||||
# Include the sdkconfig cmake file, since the following operations require
|
||||
# knowledge of config values.
|
||||
idf_build_get_property(sdkconfig_cmake SDKCONFIG_CMAKE)
|
||||
include(${sdkconfig_cmake})
|
||||
|
||||
idf_build_set_property(__CONFIG_VARIABLES "${CONFIGS_LIST}")
|
||||
foreach(config ${CONFIGS_LIST})
|
||||
set_property(TARGET __idf_build_target PROPERTY ${config} "${${config}}")
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# idf_build_process
|
||||
#
|
||||
# @brief Main processing step for ESP-IDF build: config generation, adding components to the build,
|
||||
@ -349,6 +366,7 @@ macro(idf_build_process target)
|
||||
idf_build_get_property(sdkconfig SDKCONFIG)
|
||||
idf_build_get_property(sdkconfig_defaults SDKCONFIG_DEFAULTS)
|
||||
__kconfig_generate_config("${sdkconfig}" "${sdkconfig_defaults}")
|
||||
__build_import_configs()
|
||||
|
||||
# Write the partial build properties to a temporary file.
|
||||
# The path to this generated file is set to a short-lived build
|
||||
@ -468,4 +486,17 @@ function(idf_build_executable elf)
|
||||
|
||||
# Add dependency of the build target to the executable
|
||||
add_dependencies(${elf} __idf_build_target)
|
||||
endfunction()
|
||||
|
||||
# idf_build_get_config
|
||||
#
|
||||
# @brief Get value of specified config variable
|
||||
function(idf_build_get_config var config)
|
||||
cmake_parse_arguments(_ "GENERATOR_EXPRESSION" "" "" ${ARGN})
|
||||
if(__GENERATOR_EXPRESSION)
|
||||
set(val "$<TARGET_PROPERTY:__idf_build_target,${config}>")
|
||||
else()
|
||||
get_property(val TARGET __idf_build_target PROPERTY ${config})
|
||||
endif()
|
||||
set(${var} ${val} PARENT_SCOPE)
|
||||
endfunction()
|
@ -397,4 +397,15 @@ macro(project project_name)
|
||||
idf_build_executable(${project_elf})
|
||||
|
||||
__project_info("${test_components}")
|
||||
|
||||
# Make build variables and config variables available after project call (of course the value
|
||||
# of these variables can be accessed via idf_build_get_property or idf_build_get_config)
|
||||
idf_build_get_property(sdkconfig_cmake SDKCONFIG_CMAKE)
|
||||
include(${sdkconfig_cmake})
|
||||
|
||||
idf_build_get_property(build_properties __BUILD_PROPERTIES)
|
||||
foreach(build_property ${build_properties})
|
||||
idf_build_get_property(val ${build_property})
|
||||
set(${build_property} "${val}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
Loading…
x
Reference in New Issue
Block a user