New task to export project as Arduino sketch?

Sometimes I need to send my code to others who don’t know or use PlatformIO and I ended up changing the suffixes and moving files and all sort of things. I think it may be useful to add a task that exports current PIO project as Arduino sketch, so you don’t have to do it yourself every time there is a need.

Or is there a way to add custom task globally? I see that you can customize task but just for workspace.

Some things that can be done in PlatformIO cannot be done in the Arduino IDE (easly) – for example, multiple environments, injection of custom build_flags, using different versions of compilers or frameworks with platform_packages, the entire Python extra_scripts, automatically using the correct library versions as declared via lib_deps, etc. etc…

If none of these options are used, it get’s a bit easier. Then one just has to copy all code files (*.cpp, *.h) [that are not libraries] in a folder, and rename one cpp file (prefably the main.cpp file) to an .ino extension. Then an Arduino IDE user can just open the INO file and still all the other cpp and h files in the same folder will be used and compiled in the Arduino IDE.

An example where that is e.g. visible is the Arduino-ESP32 CameraWebServer example.

So, if the goal is to be easily Arduino IDE compatible, the manual reworking / exporting can be held to a minimum by developing the PlatformIO project enterily in the src/ folder, then one can duplicate that folder and rename the main.cpp file to main.ino and all should be well (if the constraints about not using custom stuff are met, and the same library versiosn are installed in the Arduino IDE etc).

Does that answer it / make it easier for you? Or which exact behavior / feature would you like to see in PlatformIO?