Platformio will rebuild all the library dependency if we just add a new file?

In the project, I have libdeps of lvgl in platformio.ini

 lib_deps =
   lvgl@9.1

Every time I create a new file in src directory, platformio will re-build the whole library of lvgl and it spend a lot of time to build this project. For my old laptop, it takes 3min to build the project…
Is this a normal building process? Add a new file will trigger the library rebuild even it is not modilfied.
Is there a way to avoid the lvgl rebuild if we just create a new file? as the related configuration is fixed.

No that is not a normal behavior.

Usually a full rebuild is triggered when the platformio.ini has been modified / changed.

Disable all other VS Code extensions except C++ and PlatformIO and restart VS Code.

Hi Sivar,

Thanks for your reply. I have disable all unrelated extensions. But it still rebuild all the dependency.

After I have tried a simple esp32 project which created from platformio with no other libdeps, seems it is the normal behavior.

If I just add a simple test.h file in src folder, it will rebuild the whole Arduino framework. The test.h is just a empty file with no content. But it will trigger the whole rebuild of the framework.

Edit the exiting file will not cause the rebuild but adding a file will makes platformio rebuild everything no matter what is the content of the file.

Hm, this must be caused by something in your VS Code setup or on your system, like an antivirus tool.

It is definitely not normal behavior.

Whole platformio.ini?

Do you edit the project in a network drive, or OneDrive?

Hi Sivar,

I have tried on my mac book, same behavior. You can also try with following steps if you have doubt on this behavior.

  1. Create a new project using the platformio GUI in VS code. I am using the board esp32-s3 dev kit as example
  2. Add a library also using the platormio GUI in VS code. For me, I using fastled as example
  3. The platformio.in would be like this:
    [env:esp32-s3-devkitc-1]

platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
lib_deps = fastled/FastLED@3.6.0
  1. Click build. Then it will build all the library:FrameworkArduino and FastLED.
  2. Edit the main.cpp and add some code.
  3. Click build. Then it will just build the main.cpp. And that is normal.
  4. But if you add a file test.h in the src directory. Then it will re-build the all library FrameworkArduino and FastLED.

Hi max
I test it with simple project template using platformio in local drive. Please check about steps.
Do you know how to prevent the re-build if we just add a file?
At least not build the fastled library which we will not modify any code in that library.
Thanks.

Does this only happens if you have a library listed in lib_deps?

By the way: FastLED throws a lot of warnings and errors when compiling. I think i missed some settings?

I just noticed the same behavior. It is irrelevant whether a lib_deps is present or not. As soon as a new file is added to the project, the entire project is compiled. However, this only happens once after a file has been added. If this file is changed, a normal compilation process takes place.

To be honest, I never noticed this before.

1 Like

Thanks for the test. If the library is small, then we don’t notice the build time.
So far, I edit all my code in main.cpp first, then create a new file once it is tested.