esp-idf/tools/cmake
Frantisek Hrbata 0d859f2786 tools: move target guessing into cmake
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>
2023-03-08 16:37:58 +01:00
..
scripts build & config: Don't include common components on early expansion 2022-05-30 14:34:30 +02:00
third_party Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
build.cmake component manager: add build property DEPENDENCIES_LOCK 2022-12-13 15:25:19 +08:00
component_deps.dot.in G0: add a build example to check G0 dependencies 2022-06-14 15:00:53 +08:00
component.cmake build system: Add idf_component_add_link_dependency function, use for spi_flash overriding 2022-12-16 16:26:44 +01:00
depgraph.cmake cmake: add component dependency graph generation helpers 2021-12-02 15:29:00 +01:00
dfu.cmake ESP32-H2: Introduce new target for ESP32H2 2022-11-23 14:38:05 +08:00
git_submodules.cmake CI: build system do not check submodule for CI 2019-12-08 20:32:10 +08:00
idf.cmake tools: cmake: check tool supported version with idf_tools.py 2022-10-03 19:01:32 +04:00
kconfig.cmake tools: Move out kconfig_new in favour of using the esp-idf-kconfig package 2022-11-15 21:19:51 +01:00
ldgen.cmake build system: fix quoting of fragments list passed to ldgen 2021-12-14 19:17:53 +01:00
project_description.json.in feature: add build framework support 2023-02-01 17:57:25 +08:00
project.cmake tools: cmake: ignore linker RWX segment warnings 2023-02-22 05:33:03 +00:00
run_dfu_util.cmake tools: Increase the minimal supported CMake version to 3.16 2022-06-01 06:35:02 +00:00
run_size_tool.cmake tools: Add --output-file argument to idf.py size commands 2022-09-27 15:41:36 +02:00
targets.cmake tools: move target guessing into cmake 2023-03-08 16:37:58 +01:00
tool_version_check.cmake tools: cmake: check tool supported version with idf_tools.py 2022-10-03 19:01:32 +04:00
toolchain-clang-esp32.cmake build: Adds support for universal Clang toolchain 2022-11-23 13:25:16 +03:00
toolchain-clang-esp32c2.cmake build: Adds support for universal Clang toolchain 2022-11-23 13:25:16 +03:00
toolchain-clang-esp32c3.cmake build: Adds support for universal Clang toolchain 2022-11-23 13:25:16 +03:00
toolchain-clang-esp32c6.cmake build: Adds support for universal Clang toolchain 2022-11-23 13:25:16 +03:00
toolchain-clang-esp32h2.cmake build: Adds support for universal Clang toolchain 2022-11-23 13:25:16 +03:00
toolchain-clang-esp32s2.cmake build: Adds support for universal Clang toolchain 2022-11-23 13:25:16 +03:00
toolchain-clang-esp32s3.cmake build: Adds support for universal Clang toolchain 2022-11-23 13:25:16 +03:00
toolchain-esp32.cmake Build: Xtensa assembly files are now assembled with -mlongcalls option 2022-06-20 13:56:49 +08:00
toolchain-esp32c2.cmake tools: add riscv zicsr/zifencei because they were separated from i 2023-02-22 05:33:03 +00:00
toolchain-esp32c3.cmake tools: add riscv zicsr/zifencei because they were separated from i 2023-02-22 05:33:03 +00:00
toolchain-esp32c6.cmake tools: add riscv zicsr/zifencei because they were separated from i 2023-02-22 05:33:03 +00:00
toolchain-esp32h2.cmake tools: change esp32h2 march to rv32imac_zicsr_zifencei 2023-02-22 05:33:03 +00:00
toolchain-esp32h4.cmake tools: add riscv zicsr/zifencei because they were separated from i 2023-02-22 05:33:03 +00:00
toolchain-esp32s2.cmake Build: Xtensa assembly files are now assembled with -mlongcalls option 2022-06-20 13:56:49 +08:00
toolchain-esp32s3.cmake Build: Xtensa assembly files are now assembled with -mlongcalls option 2022-06-20 13:56:49 +08:00
toolchain-linux.cmake build system: don't add GCC-specific options when building with clang 2021-01-24 12:48:29 +01:00
uf2.cmake esp32h2: renaming esp32h2 to esp32h4 2022-11-08 17:05:33 +08:00
utilities.cmake cmake: use target_link_options and _directories supported since 3.13 2022-09-20 11:08:02 +02:00
version.cmake versions: Update version to 5.1.0 2022-08-04 09:55:43 +02:00