Page 1 of 1

idf Component idependent management

Posted: Thu Aug 07, 2025 10:41 am
by AloePacci
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:

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()
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

Code: Select all

dependencies:
  espressif/XXXX:
    version: "XXX"
    rules:
    - if: "CONFIG_USE_XXX == y"
    
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

Re: idf Component idependent management

Posted: Thu Aug 07, 2025 11:32 am
by AloePacci
As murphy law says, when you ask something you get the answer.

It seems from future ESPIDF>6.0 not available as of 7th august 2025 this will be achievable.

https://docs.espressif.com/projects/idf ... ig-options

So i will keep downloading everything, and going for this solution after it is released