Include folders are incorrectly modified

I am trying to get PlatformIO to compile stm32 HAL code generated by CubeMX. The following is my platformio.ini file:


platform = ststm32
board = nucleo_f103rb
build_flags = -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc

However, when running platformio run -v, I see that that these include paths have somehow become modified by platformio to be completely wrong:


I note the following similar issue:

In that case the solution was to avoid multi-line build_flags, but here I still have everything on a single line.

I have tried tracing through the platformIO source code to work out where this change is being made, but I had no luck.

Can you try giving the absolute path of the include folders in the lib_extra_dirs variable in platformio.ini

From what I undertand, the builder script is treating C:\Users\dap124.platformio\platforms\ststm32\builder as the base directory and any subsequent include directories you are adding are appended to this path.

  1. Try with the absolute path
  2. Try adding the absolute path(s) in the lib_extra_dirs. It is where LDF looks for any additional include directories.

@Krishna_Chaitanya, thanks for suggestions. Unfortunately neither of those solutions work.

The absolute paths get completely mutilated, e.g.

The lib_extra_dirs option has no effect.

Note that I include the STM32 HAL code under src, instead of lib. This is because the generated main code files include configuration headers for the HAL, preventing it from being compiled independently of the main code.