idf Component idependent management
Posted: Thu Aug 07, 2025 10:41 am
Cheers.
I have been using espidf for a while, having a relatively big personal component library and several projects running in different custom PCB with ESP32 of families S2, S3, C3, C6 ...
As of lately, i have decided to unify all the components (different names) so that i can reuse and update shared components through all my devices, creating a repo with all of them that I use as submodule for each project. Here, looking for an optimized compile time, I try to optimize CMake so that components are completely skipped if not used.
My approach has been to have at the component KCONFIG a boolean "USE_${COMPONENT_NAME}" variable. At CMake i use a custom functon that is able to read this from the kconfig, store the value and set it if I have modified it using menuconfig. Accessing them in this way:
Many of these components have huge dependencies on public repo components, where i have a idf_component.yml file looking for them.
At compile time (clean project) all of them are downloaded and taken into account. My approach here was to use
but idf component manager does not care about cached values in CMake even if declared at root CMake, so this is not a valid approach.
I can concede to download all of them everytime, but i know that ESPIDF bluetooth component is able to achieve this. Do any of you have any recommendation (for a different approach to take to achieve an unification of components) or how to achieve what i want??
Thank you in advance
I have been using espidf for a while, having a relatively big personal component library and several projects running in different custom PCB with ESP32 of families S2, S3, C3, C6 ...
As of lately, i have decided to unify all the components (different names) so that i can reuse and update shared components through all my devices, creating a repo with all of them that I use as submodule for each project. Here, looking for an optimized compile time, I try to optimize CMake so that components are completely skipped if not used.
My approach has been to have at the component KCONFIG a boolean "USE_${COMPONENT_NAME}" variable. At CMake i use a custom functon that is able to read this from the kconfig, store the value and set it if I have modified it using menuconfig. Accessing them in this way:
Code: Select all
# Load component configuration system for submodules
include("${CMAKE_CURRENT_SOURCE_DIR}/components/component_config_loader.cmake")
if(NOT CONFIG_IDF_TARGET_ESP32)
message(STATUS "device not supported, skipping aloeSECTOR component registration.")
elseif(DEFINED CONFIG_USE_ALOESECTOR AND CONFIG_USE_ALOESECTOR)
idf_component_register(SRCS "aloeSECTOR.c"
INCLUDE_DIRS "." "${PROJECT_DIR}/include"
REQUIRES driver nvs_flash aloeMQTT)
else()
message(STATUS "aloeSECTOR component not enabled, skipping registration.")
endif()
At compile time (clean project) all of them are downloaded and taken into account. My approach here was to use
Code: Select all
dependencies:
espressif/XXXX:
version: "XXX"
rules:
- if: "CONFIG_USE_XXX == y"
I can concede to download all of them everytime, but i know that ESPIDF bluetooth component is able to achieve this. Do any of you have any recommendation (for a different approach to take to achieve an unification of components) or how to achieve what i want??
Thank you in advance