espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.57k stars 7.27k forks source link

How to prevent the entire project from being recompiled due to modifying CMakeLists.txt (IDFGH-13903) #14744

Open UradaSources opened 2 days ago

UradaSources commented 2 days ago

Answers checklist.

General issue report

I want to use a library as an idf component but it doesn't come with its own cmake file for idf. There are some cross board files in the library, which I don't need, but I'm not sure which ones I don't need. I can only keep modifying the idf_component_register.SRCS parameters to test, which is a terrible experience. Every time I add even one file to my SOURCE_FILES, it will cause the entire project of more than 1400 source files to be recompiled. I have never hated c++ so much. Is there any way to solve this problem? I also use arduino-esp32 as my component. Maybe there is a way to pre-compile some things as static libraries to reduce compilation time?

set(SOURCE_FILES
    "src/Arduino_DataBus.cpp"
    ...)

idf_component_register(
    INCLUDE_DIRS "src"
    SRCS ${SOURCE_FILES}
    PRIV_REQUIRES "arduino"
)
dobairoland commented 1 day ago

Hi @UradaSources. If I understood your situation correctly then in this case the best and easiest option would be to make sure that you are bulding with ccache enabled. That means it will re-use the previously built source files from the cache if it hasn't been modified.

Depending on your OS and ESP-IDF version, it might be disabled by default. You can force it with the `--ccache command line argument: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-py.html#global-options