Reusing a component as a library when linking to reduce build times.

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Reusing a component as a library when linking to reduce build times.

Postby permal » Sun Sep 29, 2019 6:02 pm

Current situation:

- A C++ library which sits between the application and IDF.
- 19 (test) projects using the library.

Due to how the ESP-IDF build system has been implemented, it cannot build more than a single executable target which forces me to recompile IDF and the library for each of those 19 projects. Currently, this takes ~70 minutes, which is unacceptable.

Had this been a regular CMake system, I'd simply tell CMake to reuse the library for each project (via target_link_library), but its not so I can't.

There is however a library.a file being created and directly linking to that in the 19 projects does appear to work, but are there any pitfalls in doing so, except breaking the dependency chain?

I'd rather not break the dependency chain as that likely means I have to handle menuconfig etc manually. Is there a better way?

~Rant mode on~
The more I work with ESP-IDF's implementation of components etc, the more I which it followed standard modern CMake instead of the component-based abomination we now have. Why was regular CMake not enough? Imho, the component idea was a mistake, it makes things way harder than they need to be.
~End rant~

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: Reusing a component as a library when linking to reduce build times.

Postby permal » Thu Oct 03, 2019 6:49 pm

FWIW, I ended up scripting the builds so that it adjusts the CMakeLists.txt file to change the target project which resulted in a 50 minute run time reductions.

Who is online

Users browsing this forum: Abisha and 139 guests