Compiling library examples without recompiling unchanged files

While writing a library, is pio ci --lib . --board whatever examples/whatever really the best way to compile an example?

The issue I have is that pio ci compiles all the files every time, which takes a while, and there is no good reason for it to be necessary for me to wait half a minute every time I compile a one line change.

I tried setting a build-dir and keep-build-dir, but it still compiled everything.

The full command I’m testing with is:

pio ci examples/mqtt_pub/ -l . --board d1_mini --build-dir /tmp/piobuild --keep-build-dir

I also tried a platformio.ini with

src_dir = examples/mqtt_pub
lib_dir = ./

but that has weird dependency issues, and I can’t find any examples of people doing that so I don’t think it’s the suggested way to do it?

What is the way people normally compile library examples for testing during development?

You do everything right. PIO Core checks last modified time of project configuration file platformio.ini. In you case, this file will be generated each time. Could you try to create platformio.ini with the next contents:

platform = espressif8266
framework = arduino
board = d1_mini

And run this

pio ci examples/mqtt_pub/ -l . -C platformio.ini --build-dir /tmp/piobuild --keep-build-dir

I have same concern. Looking at the terminal windows, it seems like everything is rebuild when I “build” the application using “ctrl + alt + b”

I don’t quite understand how to change that behavior ??
Another thing. Every build starts with a “dependency scan” … this is also very slow…

Running that twice, it still recompiles everything.
Checking the modified times, /tmp/piobuild/platformio.ini, is updated every time the pio ci command is run.

I just updated to pio 3.6.2, no change.
I even deleted the build dir to be sure.

What else should I try?

My only other idea is to organize the repo with the example as the main project, and have the library in lib, but that’s a kinda confusing layout for a project.
I could do that with a bunch of symlinks, but it would still be confusing to someone cloning it down for the first time.

Fixed in