Hi yaqwsx,
Thanks for explaining the use cases. I agree that the ability to build multiple binaries in a single project would be useful. Unfortunately we didn't consider this as one of the requirements when ESP-IDF build system was developed, which is the reason why it's not supported.
I looked at this issue about a year ago, and I recall that building multiple .elf files was actually possible. What didn't work was generating multiple binaries, since esptool_py component uses generator expressions to create the binary targets. Here's the basic idea how to build multiple ELF files (note, i took this from the internal bug report i opened a while ago; i haven't verified if this still works with recent IDF versions).
Code: Select all
project(multi_app include($ENV{IDF_PATH}/tools/cmake/idf.cmake)
idf_build_component(main_one)
idf_build_component(main_two)
idf_build_process(esp32
SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig
BUILD_DIR ${CMAKE_BINARY_DIR})
add_executable(one.elf dummy.c)
target_link_libraries(one.elf idf::main_one)
idf_build_executable(one.elf)
add_executable(two.elf dummy.c)
target_link_libraries(two.elf idf::main_two)
idf_build_executable(two.elf)
I didn't understand your point in the "PS" regarding support for multiple sdkconfigs, though. The main issue with supporting multiple sdkconfigs is that each component build depends on sdkconfig. If we need to support multiple sdkconfigs in a single build, that means that for each pair of {sdkconfig, component} we need to create a separate build system target. This is possible, but would require very extensive changes to the build system. For example, currently knowing a component name is assumed to be sufficient to find the library built from this component. If multiple sdkconfigs are supported in a single build, this is no longer the case, and we need to specify sdkconfig as well as the component name to find the correct library. I'm afraid this will require very significant changes to be viable...