For [env:debug], append the "build_flags" of [env] not override it

In platformio.ini like the following, if I build it for “debug”, I thought that the “-I” additional path would be appended but it seems that it is overridden. How can I append it? My intention is that the additional header directories should be applied whether it is “debug” mode or “release” mode, so I put it in the [env].

[env]
build_flags = -I<path>

[env:debug]
build_flags = -D <symbol for debug>

[env:release]
build_flags = -D <symbol for release>
1 Like

You need to refactor it in a separate environment and include that data in the sub-environment, as shown in the documentation. They are not additive.

[common_env_data]
build_flags = -I<path>

[env:debug]
build_flags = ${common_env_data.build_flags} -D <symbol for debug>

[env:release]
build_flags = ${common_env_data.build_flags} -D <symbol for release>