PlatformIO Community

Build tasks for more then one project within a Multi Project Workspace


I have several ESP projects which share more and more code. Actually I build the shared code wthin it´s own project and copy it over to the library folder using a python script. Not nice but works.
Now I have read about Multi Project Workspaces, and it would be nice to have one Workspace with multiple build tasks. I have read in the PlatformIO documentation about tasks and Multi Project Workspaces, which just referred to the VS Code documentation. Creating a workspace is not a big deal, but the PlatformIO tasks do not change. I have my Default and Env-tree, and building there builds the first project, while the Output shows:

Error: The PlatformIO task detection didn’t contribute a task for the following configuration:
“type”: “PlatformIO”,
“task”: “Build”,
“problemMatcher”: [
“group”: “build”,
“presentation”: {
“panel”: “new”
The task will be ignored.

and so on for my whole configuration. I have searched the forum with no luck (some hints but without a context I could understand / use).
Maybe someone could point me to where changes are necessary, maybe has a Multi Folder Workspace Task I could see what I have to change?

Noone using a Workspace here?

I’ve never seen a build task that affects multiple workspaces, only one. (Or I haven’t yet seen enough).

Out of my head I can’t think of a solution but writing a script that invokes pio run in all sub-projects to build them. (Or pio ci commands in a CI environment)

However I would go the other way though: If you have projects that are so tightly intertwined with each other that they rely on the same shared library and you always want to build them together, you might want to create a project that has multiple environments, has that shared library but builds different source files resulting in different firmwares. Environments in the platformio.ini in general is explained in the docs and the built source files can be affected using the src_filter directive.

Interesting view. Ok, an example, maybe there is a better way: I have multiple WS2812b-Stripes in multiple rooms, controlled by multiple ESPs. These ESPs share my own light library with more programs as the usual Fastled-library. I also have all the Network stuff in another project, including MQTT handling, OTA and so on. It is also shared. Some have serial communication to an Arduino - shared. Some read multiple sensors: shared.
I also have some 3,5" touch displays using an ESP, which share the network stuff, but nothing else. So I need all these libs separated.

Atm, every shared part is a project, which I copy over to the library folder as soon as there was a change made, so I can include it in multiple ESP projects. But:
the network library f.e. needs defines from the configuration of the controller, to call the appropriate functions. So one .h and .cpp is always copied from the library to the ESP task, handling the calls only for this ESP.
The LedLib cannot include another library for sending out, so I pass a void function pointer.
And so on.
If I could place it alltogether within one project, including the ESP tasks, I could include from other folders and many workarounds are not needed anymore. That was the idea with the Multi Workspace: hoping to be able to build each folder separately, while sharing the library code directly. I know it partially from VS2017: there it is no problem to have several build tasks f.e. for several wrapper, sharing one code base.

Maybe it is not the best approach here: how do you handle it with multiple code includes on several projects?