Adding code to a "base" library.json

We supply a library which is built and tested on multiple platforms (ESP-IDF, STM32F4, NRF5SDK, NRFConnect/Zephyr and Arduino). We are in the process of adding the ability to build it (for Zephyr, ESP-IDF and Arduino[ESP-IDF]) under Platform IO.

We [will] have a library.json in the root of our repo which runs a pre-build Python script to put all of our files into a form that Platform IO will accept inside Scons. It deliberately leaves out all of our test code, which users would not want and would likely confuse them. This works fine.

I now need to build a library of our test code (the test code is common to all platforms) which I can put together with the above to, internally, run in order to test that everything is good before we release it. I want to do this without duplicating the “base” library.json, i.e. I want to overlay another set of source/include files from the same directory tree onto that base (the test files are in sub-directories spread throughout the same directory tree).

What is the best way to go about this? I’ve tried adding a second library.json deeper in our source tree which I can point a lib_dep at which just pulls in the files relevant to testing, but that doesn’t seem to work (Missing SConscript).

In case it is useful here is a preview branch of what we have at the moment where the pre-build script can be found.

Seems there’s no way to have a second library for a given, umm, library, there can be only one, so instead we have modified our pre-build script to bring in the additional test stuff if an environment variable has been set. Not ideal, since we’re then not testing the exact thing a customer will get, but it’s good enough.