Picklist to select board beforde build

I maintain a multi hardware platform project and want to implement a picklist to select the target board before build.

I am using a pre script with extra_scripts = pre:build.py

How can i dynamically set the board entry in platformio.ini, before build?

Do you mean build environment?

I just want to dynamically modify the line "board = " in platformio.ini with a pre:script.

pre:script shall display a picklist of supported boards to the user, then create appropriate platformio.ini and start build.

Sorry, it is impossible.PRE/POST scripts are called by pio run command which already initialized with environment. I see a few options:

  1. Wrap pio run into own script where do this manipulation with board.
  2. Declare different build environments and developers will use them via pio run -e or PIO IDE UI.