How to use the value of the board in platformio.ini in library.json

Hi :slight_smile:
i made a project with platformio and i would like to know if it’s possible to use the value of the board in platformio.ini in library.json in order to select the right boards in my library.

platformio.ini :

[env:eval_f072vb]
platform = ststm32
board = eval_f072vb
framework = stm32cube
build_flags = 
    -D USE_FULL_LL_DRIVER
    -D USE_HAL_DRIVER
    -I Inc
lib_extra_dirs = 
    C:\Users\antoi\OneDrive\Bureau\lib

library.json:

{
    "name": "Lib",
    "keywords": "robus,network",
    "description": "distributing operating system",
    "version": "0.6.0",
    "frameworks": "stm32cube",
    "platforms": "ststm32",
    "authors": {
        "name": "Lib",
        "url": "https://mylib"
    },
    "licence": "MIT",
    "build" : {
        "flags": [
            "-I Inc",
            "-I OD",
            "-I board/**[board select in platformio.ini]**"
        ],
        "srcFilter": [
            "+<../board/**[board select in platformio.ini]**>",
            "+<../src>"
        ]
    },
    "dependencies":
    [
        {
        "name": "Robus"
        }
    ]
}

You can do this with extra script. See example Redirecting...

The board identifier is available via

board = env.BoardConfig()
print(board.id)
1 Like