Compile local non-PlatformIO library on a per-environment basis


I have a project and I want to use a library which is not a PlatformIO library; it has no manifest. The library must only be compiled and linked in some environments, not all.

I tried putting the library outside the project and using lib_dep = symlink://../LIBRARY but I get an error: MissingPackageManifestError: Could not find one of 'library.json,, module.json' manifest files in the package.

I’d like to try putting the library inside the project under lib/ but I can’t find any way to compile and link the library in only some environments. I’ve looked all through the documentation but I can’t find anything analogous to build_src_filter for files under the lib/ subdirectory.

Is there a way to do this? Or should I file a GitHub™ issue?



I think if you do it via lib_extra_dirs = ../, even though it’s outdated, it might work and does not require a library.json.

If there are no other libraries in the lib/ folder of the project, you can also overwrite the PLATFORMIO_LIB_DIR env variable with a script in the environments you want, to the ../LIBRARY folder.

The most straightforward way would of course be creating a library.json in the library folder. Just a really simple one with a name and a version will already suffice. See here

  "name": "My Library",
  "version": "1.0.0",
  "description": "something",
  "keywords": "other"