mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
0d859f2786
The _guess_or_check_idf_target() function has sdkconfig and sdkconfig.defaults file names hardcoded. Since config file names may be specified with SDKCONFIG or SDKCONFIG_DEFAULTS cmake vars, directly in CMakeLists.txt or passed in with the -D cmake option, they are not respected. Problem is when SDKCONFIG or SDKCONFIG_DEFAULTS is set in CMakeLists.txt. While idf can detect cmake vars passed through it to cmake via the -D option, detecting SDKCONFIG and SDKCONFIG_DEFAULTS vars settings in CMakeLists.txt would require to parse it. This seems like error prone approach. Also if the vars defined by the -D option are passed directly to cmake, not via idf, they will not be visible to idf. It seems reasonable to move the logic into cmake, where we know the correct SDKCONFIG and SDKCONFIG_DEFAULTS values. So the IDF_TARGET detection/guessing is moved into targets.cmake, where the IDF_TARGET is actually set. The target is guessed based on the following precendence. 1) $ENV{IDF_TARGET} 2) IDF_TARGET 3) SDKCONFIG 4) sdkconfig 5) SDKCONFIG_DEFAULTS if non-empty or $ENV{SDKCONFIG_DEFAULTS} if non-empty or sdkconfig.defaults 6) esp32 All config files referred in $ENV{SDKCONFIG_DEFAULTS} and SDKCONFIG_DEFAULTS are searched, compared to the current behaviour. First target found in the above chain is used. The original _guess_or_check_idf_target() is renamed to _check_idf_target() and used for the target consistency checks only. The get_sdkconfig_filename() helper is now used to get the sdkconfig file for consistency checks. It looks in SDKCONFIG specified with the -D option and project_description.json. With this change config full paths are reported in messages, so it's clear e.g. from which config the target was guessed from or which config has consistency problem. test_non_default_target.py was adjusted to this change and also new test for testing the IDF_TARGET guessing was added. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>