Extending PlatformIO

Exactly! There scripts are run at the time of installation, which is when I need to install menu items and so forth. If it is run at build time, one has to run build several times and refresh the project.
This is too late, especially if the build depends on defaults from the KConfigs.

Could you simplify the use case so that I can reproduce it on my machine? Or, a simple PlatformIO project as a ZIP archive?

Just add this to your libdeps to a non-esp-idf project:

Run the build.

As youā€™ll see, that will not add the ā€œRun menuconfigā€ target until you reload the project (sometimes it also needs that one edits platformio.ini. Also, it obviously cannot remove the target on uninstall.

Basically, I need to be able run this part:

ā€¦in scripts postinstall, and a corresponding removal of the target it in the preuninstall.
The script I want to run the code is this one, specified in the library.json scripts section:

In there, I want to access all environments and add the targets on all of them.

But I havenā€™t succeeded in getting hold of the build environment.
The post-install-runner.py is a symptom of me desperately trying to run post-install.py in various contexts.

  1. You donā€™t need pre/post install scripts for this case
  2. Add include/robusto.h empty file to your library
  3. Add #include "robusto.h" to any C/C++ file in the project src directory.

In this case, your library(plugin) will be loaded always.

I donā€™t understand, or maybe I am very unclear, but the library itself is not a C library at all.

This is an implementation of KConfig/menuconfig that sort of does what the ESP-IDF platform does, but for any other framework, thus extending PlatformIO.

It creates menuconfig files and adds generation of headers that creates #define:s for all the settings one might have in oneā€™s project.

At install time, I need to add the targets so that the user can click the ā€œRun Menuconfigā€-action.
And if one would uninstall it, it needs to clean those up.

Targets are dynamic. The IDEs use pio run --list-targets to fetch the list of them. When you open project in the VSCode, we load targets one time and use them later.

Ok, however it seems like I can list them in the build stage?
Maybe Iā€™ll have to call that to enumerate them, are there ways to add targets that way too?