Merge branch 'bugfix/cmake_sdkconfig_issues' into 'master'
cmake: fix sdkconfig related issues Closes IDF-1086 See merge request espressif/esp-idf!6436
This commit is contained in:
commit
ad79772e7e
6 changed files with 90 additions and 77 deletions
|
@ -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``
|
||||
|
|
|
@ -348,43 +348,43 @@ function run_tests()
|
|||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
||||
|
||||
print_status "sdkconfig should have contents of all files: sdkconfig, sdkconfig.defaults, sdkconfig.defaults.IDF_TARGET"
|
||||
idf.py clean > /dev/null;
|
||||
idf.py fullclean > /dev/null;
|
||||
rm -f sdkconfig.defaults;
|
||||
rm -f sdkconfig;
|
||||
echo "CONFIG_PARTITION_TABLE_OFFSET=0x10000" >> sdkconfig.defaults;
|
||||
echo "CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y" >> sdkconfig.defaults.esp32;
|
||||
echo "CONFIG_PARTITION_TABLE_TWO_OTA=y" >> sdkconfig;
|
||||
idf.py reconfigure > /dev/null;
|
||||
idf.py clean > /dev/null
|
||||
idf.py fullclean > /dev/null
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "CONFIG_PARTITION_TABLE_OFFSET=0x10000" >> sdkconfig.defaults
|
||||
echo "CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y" >> sdkconfig.defaults.esp32
|
||||
echo "CONFIG_PARTITION_TABLE_TWO_OTA=y" >> sdkconfig
|
||||
idf.py reconfigure > /dev/null
|
||||
grep "CONFIG_PARTITION_TABLE_OFFSET=0x10000" sdkconfig || failure "The define from sdkconfig.defaults should be into sdkconfig"
|
||||
grep "CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y" sdkconfig || failure "The define from sdkconfig.defaults.esp32 should be into sdkconfig"
|
||||
grep "CONFIG_PARTITION_TABLE_TWO_OTA=y" sdkconfig || failure "The define from sdkconfig should be into sdkconfig"
|
||||
rm sdkconfig sdkconfig.defaults sdkconfig.defaults.esp32
|
||||
|
||||
print_status "can build with phy_init_data"
|
||||
idf.py clean > /dev/null;
|
||||
idf.py fullclean > /dev/null;
|
||||
rm -f sdkconfig.defaults;
|
||||
rm -f sdkconfig;
|
||||
echo "CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION=y" >> sdkconfig.defaults;
|
||||
idf.py reconfigure > /dev/null;
|
||||
idf.py clean > /dev/null
|
||||
idf.py fullclean > /dev/null
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION=y" >> sdkconfig.defaults
|
||||
idf.py reconfigure > /dev/null
|
||||
idf.py build || failure "Failed to build with PHY_INIT_DATA"
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} ${PHY_INIT_BIN}
|
||||
rm sdkconfig;
|
||||
rm sdkconfig.defaults;
|
||||
rm sdkconfig
|
||||
rm sdkconfig.defaults
|
||||
|
||||
print_status "can build with ethernet component disabled"
|
||||
idf.py clean > /dev/null;
|
||||
idf.py fullclean > /dev/null;
|
||||
rm -f sdkconfig.defaults;
|
||||
rm -f sdkconfig;
|
||||
echo "CONFIG_ETH_USE_SPI_ETHERNET=" >> sdkconfig.defaults;
|
||||
echo "CONFIG_ETH_USE_ESP32_EMAC=" >> sdkconfig.defaults;
|
||||
idf.py reconfigure > /dev/null;
|
||||
idf.py clean > /dev/null
|
||||
idf.py fullclean > /dev/null
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "CONFIG_ETH_USE_SPI_ETHERNET=" >> sdkconfig.defaults
|
||||
echo "CONFIG_ETH_USE_ESP32_EMAC=" >> sdkconfig.defaults
|
||||
idf.py reconfigure > /dev/null
|
||||
idf.py build || failure "Failed to build with ethernet component disabled"
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
||||
rm sdkconfig;
|
||||
rm sdkconfig.defaults;
|
||||
rm sdkconfig
|
||||
rm sdkconfig.defaults
|
||||
|
||||
print_status "Building a project with CMake library imported and PSRAM workaround, all files compile with workaround"
|
||||
# Test for libraries compiled within ESP-IDF
|
||||
|
@ -422,13 +422,13 @@ EOF
|
|||
rm ./python
|
||||
|
||||
print_status "Handling deprecated Kconfig options"
|
||||
idf.py clean > /dev/null;
|
||||
rm -f sdkconfig.defaults;
|
||||
rm -f sdkconfig;
|
||||
echo "" > ${IDF_PATH}/sdkconfig.rename;
|
||||
idf.py build > /dev/null;
|
||||
echo "CONFIG_TEST_OLD_OPTION=y" >> sdkconfig;
|
||||
echo "CONFIG_TEST_OLD_OPTION CONFIG_TEST_NEW_OPTION" >> ${IDF_PATH}/sdkconfig.rename;
|
||||
idf.py clean > /dev/null
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "" > ${IDF_PATH}/sdkconfig.rename
|
||||
idf.py build > /dev/null
|
||||
echo "CONFIG_TEST_OLD_OPTION=y" >> sdkconfig
|
||||
echo "CONFIG_TEST_OLD_OPTION CONFIG_TEST_NEW_OPTION" >> ${IDF_PATH}/sdkconfig.rename
|
||||
echo -e "\n\
|
||||
menu \"test\"\n\
|
||||
config TEST_NEW_OPTION\n\
|
||||
|
@ -436,8 +436,8 @@ menu \"test\"\n\
|
|||
default \"n\"\n\
|
||||
help\n\
|
||||
TEST_NEW_OPTION description\n\
|
||||
endmenu\n" >> ${IDF_PATH}/Kconfig;
|
||||
idf.py build > /dev/null;
|
||||
endmenu\n" >> ${IDF_PATH}/Kconfig
|
||||
idf.py build > /dev/null
|
||||
grep "CONFIG_TEST_OLD_OPTION=y" sdkconfig || failure "CONFIG_TEST_OLD_OPTION should be in sdkconfig for backward compatibility"
|
||||
grep "CONFIG_TEST_NEW_OPTION=y" sdkconfig || failure "CONFIG_TEST_NEW_OPTION should be now in sdkconfig"
|
||||
grep "#define CONFIG_TEST_NEW_OPTION 1" build/config/sdkconfig.h || failure "sdkconfig.h should contain the new macro"
|
||||
|
@ -450,10 +450,10 @@ endmenu\n" >> ${IDF_PATH}/Kconfig;
|
|||
popd
|
||||
|
||||
print_status "Handling deprecated Kconfig options in sdkconfig.defaults"
|
||||
idf.py clean;
|
||||
rm -f sdkconfig;
|
||||
echo "CONFIG_TEST_OLD_OPTION=7" > sdkconfig.defaults;
|
||||
echo "CONFIG_TEST_OLD_OPTION CONFIG_TEST_NEW_OPTION" > ${IDF_PATH}/sdkconfig.rename;
|
||||
idf.py clean
|
||||
rm -f sdkconfig
|
||||
echo "CONFIG_TEST_OLD_OPTION=7" > sdkconfig.defaults
|
||||
echo "CONFIG_TEST_OLD_OPTION CONFIG_TEST_NEW_OPTION" > ${IDF_PATH}/sdkconfig.rename
|
||||
echo -e "\n\
|
||||
menu \"test\"\n\
|
||||
config TEST_NEW_OPTION\n\
|
||||
|
@ -462,11 +462,11 @@ menu \"test\"\n\
|
|||
default 5\n\
|
||||
help\n\
|
||||
TEST_NEW_OPTION description\n\
|
||||
endmenu\n" >> ${IDF_PATH}/Kconfig;
|
||||
idf.py build > /dev/null;
|
||||
endmenu\n" >> ${IDF_PATH}/Kconfig
|
||||
idf.py build > /dev/null
|
||||
grep "CONFIG_TEST_OLD_OPTION=7" sdkconfig || failure "CONFIG_TEST_OLD_OPTION=7 should be in sdkconfig for backward compatibility"
|
||||
grep "CONFIG_TEST_NEW_OPTION=7" sdkconfig || failure "CONFIG_TEST_NEW_OPTION=7 should be in sdkconfig"
|
||||
rm -f sdkconfig.defaults;
|
||||
rm -f sdkconfig.defaults
|
||||
pushd ${IDF_PATH}
|
||||
git checkout -- sdkconfig.rename Kconfig
|
||||
popd
|
||||
|
@ -567,6 +567,19 @@ endmenu\n" >> ${IDF_PATH}/Kconfig;
|
|||
|| failure "Deprecation warnings are not displayed"
|
||||
rm out.txt
|
||||
|
||||
print_status "should be able to specify multiple sdkconfig default files"
|
||||
idf.py clean > /dev/null
|
||||
idf.py fullclean > /dev/null
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "CONFIG_PARTITION_TABLE_OFFSET=0x10000" >> sdkconfig.defaults1
|
||||
echo "CONFIG_PARTITION_TABLE_TWO_OTA=y" >> sdkconfig.defaults2
|
||||
idf.py -DSDKCONFIG_DEFAULTS="sdkconfig.defaults1;sdkconfig.defaults2" reconfigure > /dev/null
|
||||
grep "CONFIG_PARTITION_TABLE_OFFSET=0x10000" sdkconfig || failure "The define from sdkconfig.defaults1 should be in sdkconfig"
|
||||
grep "CONFIG_PARTITION_TABLE_TWO_OTA=y" sdkconfig || failure "The define from sdkconfig.defaults2 should be in sdkconfig"
|
||||
rm sdkconfig.defaults1
|
||||
rm sdkconfig.defaults2
|
||||
|
||||
print_status "All tests completed"
|
||||
if [ -n "${FAILURES}" ]; then
|
||||
echo "Some failures were detected:"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -313,25 +313,30 @@ macro(project project_name)
|
|||
# PROJECT_NAME is taken from the passed name from project() call
|
||||
# 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()
|
||||
else()
|
||||
set(_sdkconfig_defaults "$ENV{SDKCONFIG_DEFAULTS}")
|
||||
|
||||
if(NOT _sdkconfig_defaults)
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
|
||||
set(sdkconfig_defaults "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
|
||||
set(_sdkconfig_defaults "${CMAKE_SOURCE_DIR}/sdkconfig.defaults")
|
||||
else()
|
||||
set(sdkconfig_defaults "")
|
||||
set(_sdkconfig_defaults "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SDKCONFIG_DEFAULTS)
|
||||
set(_sdkconfig_defaults "${SDKCONFIG_DEFAULTS}")
|
||||
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()
|
||||
|
||||
if(SDKCONFIG)
|
||||
get_filename_component(sdkconfig "${SDKCONFIG}" ABSOLUTE)
|
||||
if(NOT EXISTS "${sdkconfig}")
|
||||
message(FATAL_ERROR "SDKCONFIG '${sdkconfig}' does not exist.")
|
||||
endif()
|
||||
set(sdkconfig ${SDKCONFIG})
|
||||
else()
|
||||
set(sdkconfig "${CMAKE_CURRENT_LIST_DIR}/sdkconfig")
|
||||
endif()
|
||||
|
|
|
@ -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…
Reference in a new issue