this doesn’t make it easy to actually build and run the examples
there is too much nesting, folders with a single file are tedious
The first problem is actually the bigger issue. How do you get these examples to compile? Do I need to include a platformio.ini file with each? And then add lib_extra_dirs = ../../.. to find the library? That will cause PIO to scan all sibling directories as well, which would be confusing (and slow).
The second issue appears to be solvable with the following alternative:
The standard Arduino library structure works too: pull out the files from include/ and src/ into the mylib folder.
Have you tried the pio ci commands? They’re meant for continuous integration, e.g. compiling a library example and seeing if compilation goes through. Documentation is available (this page among lots of others). So something in the style of
pio ci path/to/example/file.cpp --lib="path/to/library/folder" --board=uno
(or whatever board.) Then you don’t need the examples to be full PlatformIO project folders.
I solved this by using a single platformio.ini and add new environments for every example I use. See the example below.
This works a bit more like Cargo from the Rust language operates. Also you know that the whole project keeps on working.