idf.py build compiles every esp-idf library component

laczik
Posts: 5
Joined: Thu Aug 25, 2022 3:37 pm

idf.py build compiles every esp-idf library component

Postby laczik » Thu Aug 25, 2022 3:53 pm

After a project config change or clean, 'idf.py build' compiles every esp-idf library component regardless of whether the components are used in the project or not.

Is there any way to avoid compiling 1000+ source files when building even just a simple blank test project?

An example:

. ~/ESP32/esp-idf-v4.4.2/export.sh
idf.py create-project cli_test
cd cli_test/
idf.py set-target esp32
idf.py menuconfig
idf.py build
idf.py clean
idf.py build

[74/1035] Building C object esp-idf/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/home/l.../programming/ESP32/Eclipse_ESP-IDF/esp-idf-v4.4.2/components/mbedtls/port/esp_hardware.c.obj^C
ninja: build stopped: interrupted by user.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: idf.py build compiles every esp-idf library component

Postby ESP_igrr » Fri Aug 26, 2022 5:48 am

Hi laczik,

Yes, it's possible by setting the COMPONENTS variable in your project CMakeLists.txt file to just your 'main' component, and then declaring dependencies of the main component via REQUIRES and PRIV_REQUIRES arguments of idf_component_register.

Please check https://docs.espressif.com/projects/esp ... -variables and https://docs.espressif.com/projects/esp ... quirements.

With this change, in the current master branch the build system should build around 500 files. That's still a fair bit more than we'd like for a minimal build, and we are working on improvements to component dependencies structure to reduce this number.

I would also recommend installing ccache and setting IDF_CCACHE_ENABLE=1 environment variable. This should reduce the time of a "clean" build very significantly.

laczik
Posts: 5
Joined: Thu Aug 25, 2022 3:37 pm

Re: idf.py build compiles every esp-idf library component

Postby laczik » Fri Aug 26, 2022 11:56 am

Thank you!

I am now down to 668 instead of 1000+ for my project proper...

Who is online

Users browsing this forum: No registered users and 357 guests