Hello,
trying to do
[env:brain_node]
build_flags = -I src/$PIOENV
in platformio.ini for some reason produces strange path
-I/Users/xxx/.platformio/platforms/ststm32/builder/src/brain_node
Im expecting:
-I src/brain_node
Thanks!
With regards,
Ivan
Ok, again found a solution myself 
It seems that relative path’s in build_flags with some environment variable always resolves wrong. Solution was to set an absolute path from an extra_script.
Import("env")
PIOENV = env.subst("$PIOENV")
PROJECT_SRC_DIR = env.subst("$PROJECT_SRC_DIR")
env.Append(
CPPPATH=[PROJECT_SRC_DIR + "/" + PIOENV + "/inc"]
)
You should do from os import path
and then
CPPPATH=[path.join(PROJECT_SRC_DIR, PIOENV, "inc")]
there to be safe