Zephyr3 builder contribution


I would like to contribute to platformio by giving an early builder to support zephyr3.
There is a catch: I’m not doing it the zephyr2 builder way, but I’m using zephyr’s build system.
How it works? I was inspired by the zephyr2 builder, but it is too error prone to add the specific zephyr calls…
So I do it the simple way: I generate a cmakefile in the build dir, that includes all the files that are gathered by platformio (libraries and src application files)… And then I call the ninja from zephyr3 to do the build.
It works pretty well, and this method supports all specific feature of zephyr (like security etc) and technically it also support zephyr2.

For now, I generate one big cmake file that includes all the source files because I didn’t succeed to generate multiple libs and the includes/flags they needed yet (but I know that we have all the information to do it properly)
The other limitation is that the upload and debug targets are not using zephyr’s one, but similar upload target rules to zephyr2 builder. This means that all supported zephyr’s target cannot be automagically supported, but specific python builder code need to be created to add the rules to upload (same as zephyr2)
The reason is that I was not able to call west from the builder (I may be missing some variables because it is complaining about missing project configuration…) The build target do not use west but cmake directly (following the official zephyr doc)

I called the platform builder “zephyr3”, even if it can handle zephyr2. I’m not sure yet how an existing env can be configured to use zephyr or my zephyr3 (for now, I explicitely set the platform to zephyr3)
For now it is only for nrf targets…

Of course, the way it works is seamless to platformio users. If they modify, add or remove a file in their projects, the builder will automatically generate a cmakefile, call reconfigure and build if needed. (reconfigure is only called if the cmakefile is different)

Please let me know if this is something you would like? (oh, forgot to say that this builder is part of my work with my company Baracoda that they agreed to donate to the community)