Advice on esp-idf framework re-build

Hi there, is there a way to ignore components from the esp-idf framework which are not needed?

Each time I change some option by running menuconfig or adding some lib the whole SDK gets rebuilt even though 95% of it is either not needed or not changed.
I’m developing under Windows and the whole thing takes like 5min, it’s really painful…

Any configuration one could add to suppress un-needed components? (other than nuking the whole dir…:wink:

Thank in advance!

Best regards
Alex

I case anyone is interested I just hacked a little the CMake rules for the SDK while keeping it maintainable.

Basically edit $ENV{IDF_PATH}/tools/cmake/build.cmake

in function(__build_init idf_path) #around line 125 of build.cmake…

insert the following snippet in the foreach(component_dir…) loop

foreach(component_dir ${component_dirs})

    #### Alex ignore not needed components
    get_filename_component(dirname ${component_dir} NAME)
    if(NOT dirname IN_LIST EXCLUDE_COMPONENTS)


        #original lines now conditionally executed --------------------------
        get_filename_component(component_dir ${component_dir} ABSOLUTE)
        __component_dir_quick_check(is_component ${component_dir})
        if(is_component)
            __component_add(${component_dir} ${prefix})
        endif()

    endif()
    #### end Alex
endforeach()

And in your project’s base dir CMakeLists.txt add

  cmake_minimum_required(VERSION 3.16.0)
  
  list(APPEND EXCLUDE_COMPONENTS "dir_name_of_component_to_exclude...")
  list(APPEND EXCLUDE_COMPONENTS "asio")
  list(APPEND EXCLUDE_COMPONENTS "coap")
  list(APPEND EXCLUDE_COMPONENTS "libsodium")
  list(APPEND EXCLUDE_COMPONENTS "etc, etc")
  
  include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  project(your_project_name)

With that you will be able to exclude some components that you don’t need.
If a dependency shows up that requires an excluded component your build process will fail but you will be given missing component name. You can easily include it again by excluding the list(append sentence.

With this method although you are messing with the SDK you only need to change one cmake file in the SDK which is easily re-done when the SDK framework gets an update.

Furthermore the exclusion of components is project based so you still share the SDK across project but no need to rebuild the whole SDK for each project.

In my current project I was able to shave like 30% of build time with the above. Not perfect but far better than nothing :slight_smile:

Best regards
Alex

Can you get this change in mainline ESP-IDF? Then PlatformIO picks it up when updated to a new release, exposing that functionality to the users.

Hi Max, sorry for the late reply and thanks for the suggestion. I might give it a try.

However, what I really think it’s needed is a whole different approach for the build process. The whole menuconfig paradigm in this SDK implies a complete rebuild even though you might change only one option.

What would be great is to have a the CMAKE process running in background and doing the evaluation while you are editing your source files. When you hit the build button It should only need to update based on what you are actively editing and not taking time evaluating what is 99% static.
I know that would probably require rethinking the whole CMAKE tool but, seriously, when you are in a loop of refining your code taking all that time between each loop is frustrating.

Best regards
Alex