mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
cmake: allow multiple sdkconfig defaults to be specified
This commit is contained in:
parent
363b573e60
commit
d43cc4fa4b
@ -904,14 +904,14 @@ Custom sdkconfig defaults
|
||||
|
||||
For example projects or other projects where you don't want to specify a full sdkconfig configuration, but you do want to override some key values from the ESP-IDF defaults, it is possible to create a file ``sdkconfig.defaults`` in the project directory. This file will be used when creating a new config from scratch, or when any new config value hasn't yet been set in the ``sdkconfig`` file.
|
||||
|
||||
To override the name of this file, set the ``SDKCONFIG_DEFAULTS`` environment variable.
|
||||
To override the name of this file or to specify multiple files, set the ``SDKCONFIG_DEFAULTS`` environment variable or set ``SDKCONFIG_DEFAULTS`` in top-level CMakeLists.txt. If specifying multiple files, use semicolon as the list separator. File names not specified as full paths are resolved relative to current project.
|
||||
|
||||
Target-dependent sdkconfig defaults
|
||||
-----------------------------------
|
||||
|
||||
In addition to ``sdkconfig.defaults`` file, build system will also load defaults from ``sdkconfig.defaults.TARGET_NAME`` file, where ``TARGET_NAME`` is the value of ``IDF_TARGET``. For example, for ``esp32`` target, default settings will be taken from ``sdkconfig.defaults`` first, and then from ``sdkconfig.defaults.esp32``.
|
||||
|
||||
If ``SDKCONFIG_DEFAULTS`` is used to override the name of defaults file, the name of target-specific defaults file will be derived from ``SDKCONFIG_DEFAULTS`` value.
|
||||
If ``SDKCONFIG_DEFAULTS`` is used to override the name of defaults file/files, the name of target-specific defaults file will be derived from ``SDKCONFIG_DEFAULTS`` value/values using the rule above.
|
||||
|
||||
|
||||
Flash arguments
|
||||
@ -1099,7 +1099,7 @@ The call requires the target chip to be specified with *target* argument. Option
|
||||
- PROJECT_NAME - name of the project; defaults to CMAKE_PROJECT_NAME
|
||||
- PROJECT_VER - version/revision of the project; defaults to "1"
|
||||
- SDKCONFIG - output path of generated sdkconfig file; defaults to PROJECT_DIR/sdkconfig or CMAKE_SOURCE_DIR/sdkconfig depending if PROJECT_DIR is set
|
||||
- SDKCONFIG_DEFAULTS - defaults file to use for the build; defaults to empty
|
||||
- SDKCONFIG_DEFAULTS - list of files containing default config to use in the build (list must contain full paths); defaults to empty. For each value *filename* in the list, the config from file *filename.target*, if it exists, is also loaded.
|
||||
- BUILD_DIR - directory to place ESP-IDF build-related artifacts, such as generated binaries, text files, components; defaults to CMAKE_BINARY_DIR
|
||||
- COMPONENTS - select components to process among the components known by the build system (added via `idf_build_component`). This argument is used to trim the build.
|
||||
Other components are automatically added if they are required in the dependency chain, i.e.
|
||||
@ -1154,7 +1154,7 @@ For example, to get the Python interpreter used for the build:
|
||||
- PROJECT_VER - version of the project; set from ``idf_build_process`` PROJECT_VER argument
|
||||
- PYTHON - Python interpreter used for the build; set from PYTHON environment variable if available, if not "python" is used
|
||||
- SDKCONFIG - full path to output config file; set from ``idf_build_process`` SDKCONFIG argument
|
||||
- SDKCONFIG_DEFAULTS - full path to config defaults file; set from ``idf_build_process`` SDKCONFIG_DEFAULTS argument
|
||||
- SDKCONFIG_DEFAULTS - list of files containing default config to use in the build; set from ``idf_build_process`` SDKCONFIG_DEFAULTS argument
|
||||
- SDKCONFIG_HEADER - full path to C/C++ header file containing component configuration; set by ``idf_build_process``
|
||||
- SDKCONFIG_CMAKE - full path to CMake file containing component configuration; set by ``idf_build_process``
|
||||
- SDKCONFIG_JSON - full path to JSON file containing component configuration; set by ``idf_build_process``
|
||||
|
@ -367,8 +367,8 @@ endfunction()
|
||||
# are processed.
|
||||
macro(idf_build_process target)
|
||||
set(options)
|
||||
set(single_value PROJECT_DIR PROJECT_VER PROJECT_NAME BUILD_DIR SDKCONFIG SDKCONFIG_DEFAULTS)
|
||||
set(multi_value COMPONENTS)
|
||||
set(single_value PROJECT_DIR PROJECT_VER PROJECT_NAME BUILD_DIR SDKCONFIG)
|
||||
set(multi_value COMPONENTS SDKCONFIG_DEFAULTS)
|
||||
cmake_parse_arguments(_ "${options}" "${single_value}" "${multi_value}" ${ARGN})
|
||||
|
||||
idf_build_set_property(BOOTLOADER_BUILD "${BOOTLOADER_BUILD}")
|
||||
|
@ -158,11 +158,17 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults)
|
||||
idf_build_set_property(CONFIG_ENV_PATH ${config_env_path})
|
||||
|
||||
if(sdkconfig_defaults)
|
||||
set(defaults_arg --defaults "${sdkconfig_defaults}")
|
||||
foreach(sdkconfig_default ${sdkconfig_defaults})
|
||||
list(APPEND defaults_arg --defaults "${sdkconfig_default}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(EXISTS "${sdkconfig_defaults}.${idf_target}")
|
||||
list(APPEND defaults_arg --defaults "${sdkconfig_defaults}.${idf_target}")
|
||||
if(sdkconfig_defaults)
|
||||
foreach(sdkconfig_default ${sdkconfig_defaults})
|
||||
if(EXISTS "${sdkconfig_default}.${idf_target}")
|
||||
list(APPEND defaults_arg --defaults "${sdkconfig_default}.${idf_target}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
idf_build_get_property(root_kconfig __ROOT_KCONFIG)
|
||||
|
@ -314,10 +314,13 @@ macro(project project_name)
|
||||
# PROJECT_DIR is set to the current directory
|
||||
# PROJECT_VER is from the version text or git revision of the current repo
|
||||
if(SDKCONFIG_DEFAULTS)
|
||||
get_filename_component(sdkconfig_defaults "${SDKCONFIG_DEFAULTS}" ABSOLUTE)
|
||||
if(NOT EXISTS "${sdkconfig_defaults}")
|
||||
message(FATAL_ERROR "SDKCONFIG_DEFAULTS '${sdkconfig_defaults}' does not exist.")
|
||||
endif()
|
||||
foreach(sdkconfig_default ${SDKCONFIG_DEFAULTS})
|
||||
get_filename_component(sdkconfig_default "${sdkconfig_default}" ABSOLUTE)
|
||||
if(NOT EXISTS "${sdkconfig_default}")
|
||||
message(FATAL_ERROR "SDKCONFIG_DEFAULTS '${sdkconfig_default}' does not exist.")
|
||||
endif()
|
||||
list(APPEND sdkconfig_defaults ${sdkconfig_default})
|
||||
endforeach()
|
||||
else()
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
|
||||
set(sdkconfig_defaults "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
|
||||
|
@ -71,29 +71,18 @@ def action_extensions(base_actions, project_path=os.getcwd()):
|
||||
|
||||
# Clean up and set idf-target
|
||||
base_actions["actions"]["fullclean"]["callback"]("fullclean", ctx, args)
|
||||
base_actions["actions"]["set-target"]["callback"]("set-target", ctx, args, target)
|
||||
|
||||
new_cache_values["EXCLUDE_COMPONENTS"] = config.get("EXCLUDE_COMPONENTS", "''")
|
||||
new_cache_values["TEST_EXCLUDE_COMPONENTS"] = config.get("TEST_EXCLUDE_COMPONENTS", "''")
|
||||
new_cache_values["TEST_COMPONENTS"] = config.get("TEST_COMPONENTS", "''")
|
||||
new_cache_values["TESTS_ALL"] = int(new_cache_values["TEST_COMPONENTS"] == "''")
|
||||
|
||||
# write a new sdkconfig file from the combined defaults and the config
|
||||
# value folder
|
||||
with open(os.path.join(project_path, "sdkconfig"), "w") as sdkconfig:
|
||||
sdkconfig_default = os.path.join(project_path, "sdkconfig.defaults")
|
||||
|
||||
with open(sdkconfig_default, "rb") as sdkconfig_default_file:
|
||||
sdkconfig.write(sdkconfig_default_file.read())
|
||||
|
||||
sdkconfig_config = os.path.join(project_path, "configs", config_name)
|
||||
with open(sdkconfig_config, "rb") as sdkconfig_config_file:
|
||||
sdkconfig.write(b"\n")
|
||||
sdkconfig.write(sdkconfig_config_file.read())
|
||||
new_cache_values["IDF_TARGET"] = target
|
||||
new_cache_values["SDKCONFIG_DEFAULTS"] = ";".join([os.path.join(project_path, "sdkconfig.defaults"), config_path])
|
||||
|
||||
args.define_cache_entry.extend(["%s=%s" % (k, v) for k, v in new_cache_values.items()])
|
||||
|
||||
base_actions["actions"]["reconfigure"]["callback"](None, ctx, args)
|
||||
reconfigure = base_actions["actions"]["reconfigure"]["callback"]
|
||||
reconfigure(None, ctx, args)
|
||||
|
||||
# This target builds the configuration. It does not currently track dependencies,
|
||||
# but is good enough for CI builds if used together with clean-all-configs.
|
||||
|
Loading…
x
Reference in New Issue
Block a user