Potential bug? Platformio modifying my include paths

I’m wondering if I’ve found a bug or simply some interaction that I haven’t been able to find documentation for. The summary is that if I change the order of -I PATH directives in platformio.ini, the PATHs themselves will change in the generated g++ command.

For instance, in the following environment I specify -I include/robot_config/default/ -I include/robot_config/${env.ROBOT_NAME}/:

[env:main]
platform=atmelsam
framework=arduino
board=samdSerial
src_filter = +<i2c/*> +<main.cpp> +<user_interface/*>
build_flags = -DSERIAL_BUFFER_SIZE=2000 -I include/robot_config/default/
              -I include/robot_config/${env.ROBOT_NAME}/ -I include/
              -DBLIND_SCAN_I2C=1 -DWATCHDOG=1
upload_port = /dev/ttyS0
lib_deps = 883

A pio run -e main -v shows the modified paths that causes compilation to fail because it can’t find the correct file on the search path:

-Iplatformio/platforms/atmelsam/builder/include/robot_config/default/, -Iinclude/robot_config

But I can change the include order in platformio.ini:

[env:main]
platform=atmelsam
framework=arduino
board=samdSerial
src_filter = +<i2c/*> +<main.cpp> +<user_interface/*>
build_flags = -DSERIAL_BUFFER_SIZE=2000 -I include/robot_config/${env.ROBOT_NAME}/
               -I include/robot_config/default/ -I include/
              -DBLIND_SCAN_I2C=1 -DWATCHDOG=1
upload_port = /dev/ttyS0
lib_deps = 883

The code compiles successfully with the following -I directives in the generated g++ command:

-Iplatformio/platforms/atmelsam/builder/include/robot_config/, -Iinclude/robot_config/default

It looks at first like platformio/platforms/atmelsam/builder is added to the first -I directive from platformio.ini, but the odd thing is that adding another -I directive (say, -I include/robot_config/foo/) to the main environment in platformio.ini results in the following g++ -I directives:

-Iplatformio/platforms/atmelsam/builder/include/robot_config/foo, -Iplatformio/platforms/atmelsam/builder/include/robot_config/, -Iinclude/robot_config/default 

So, what’s going on here? Why does a path get appended to my -I directives, and only (seemingly) for the last file?

I’m not sure that multi-line is supported for build_flags. See

Yup, swapping to one-liners fixed this problem. Thanks!