PlatformIO Community

How to concat variables in platformio.ini file?

I’m trying to make the following ini work

[common]
rev_var = !echo "-DPIO_SRC_REV="$(git rev-parse HEAD)

[env]
build_flags = -Wl,-Map=$BUILD_DIR/artifact.map

[env:nodemcuv2_linux]
build_flags = ${env.build_flags} ${common.rev_var}
    
[env:nodemcuv2_cross]
build_flags = ${env.build_flags}
    -DSERVICE_SSID=\"SOME_SSID\"

But rev_var is not resolved during concat phase in nodemcuv2_linux and is placed as plain text !echo "-DPIO_SRC_REV="$(git rev-parse HEAD)
Also -D options doesn’t concat to env.build_flags in nodemcuv2_cross

The goal of the config is to let the project build on Windows and Linux machines and have an option to run git command or not, depending on environment. Can you tell me if this possible to implement with platformio.ini config and how?

Place them in different lines:

build_flags = 
   -D ...
   !echo...