PIO builds library in .piolibdeps but not in `lib_deps` key

When I build in my native_test environment (device independent unit tests), I use a different list of libraries in lib_deps. (Lots of libs aren’t easy/appropriate to run in the mocked Arduino environment I use for native build.)

Despite not being in lib_deps, PIO attempts to build all the libraries. I noticed because Adafruit Arduino Zero ASF Core Library won’t even build under native, because not SAM.

=========================================================================== [test::*] Building... (1/2) ===========================================================================
Please wait...
In file included from .piolibdeps/Adafruit Arduino Zero ASF Core Library/gclk.c:47:
In file included from .piolibdeps/Adafruit Arduino Zero ASF Core Library/gclk.h:55:
.piolibdeps/Adafruit Arduino Zero ASF Core Library/compiler.h:50:10: fatal error: 'sam.h' file not found
#include <sam.h>
^~~~~~~
1 error generated.
*** [.pioenvs/native_test/lib4fc/Adafruit Arduino Zero ASF Core Library/gclk.o] Error 1
In file included from .piolibdeps/Adafruit Arduino Zero ASF Core Library/i2s.c:47:
In file included from .piolibdeps/Adafruit Arduino Zero ASF Core Library/i2s.h:334:
.piolibdeps/Adafruit Arduino Zero ASF Core Library/compiler.h:50:10: fatal error: 'sam.h' file not found
#include <sam.h>
^~~~~~~
1 error generated.
*** [.pioenvs/native_test/lib4fc/Adafruit Arduino Zero ASF Core Library/i2s.o] Error 1

If I delete the library from .piolibdeps I can build and run my unit tests. Next time I build for the device, PIO seamlessly downloads the library and that works without intervention.

Am I doing something wrong? Can I give PIO more information to do the right thing or is this a bug?

Thanks.

  • Frank

I still have problems with this often. I regularly run rm -rf .pioenvs .piolibdeps when I switch to building a different env with different dependencies (usually building tests - native and embedded).

I just noticed the build_dir configuration parameter. @ivankravets Any chance of specifying that at the env level -

[env:a]
build_dir = .pio_build_a

[env:b]
build_dir = .pio_build_b

or, alternatively, parameterize the name using the env of the current operation

[platformio]
build_dir = .pio_build_${env_name}

Thanks!

We plan to continue a work on PlatformIO Core 4.0 soon. So, this issue should help

1 Like

All fixed in 4.0!

.pio
  build
    env1
    env2
1 Like