I’ve now changed the library so that the sub folders are no longer included as extra libraries but simply as source files with srcFilter. It still doesn’t work without the global build flags in library.json. I still don’t know how to get it to work with the script.
I really hope there is a solution or else platformio is fundamentally broken, since it doesn’t allow splitting code into different folders and doesn’t allow dynamic building.
"build": { "srcDir":"", "srcFilter":[ "+<src/*.cpp>", "+<include/*.h>", "+<src/stm32/*.c>", "+<src/stm32/*.h>", "+<src/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/*.h>", "+<src/Middlewares/ST/STM32_USB_Device_Library/Core/Src/*.c>", "+<src/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/*.h>", "+<src/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/*.c>" ], "flags": [ "-DSTM32", "-Isrc/stm32", "-Isrc/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc", "-Isrc/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" ], "extraScript": "generate_headers.py", "libArchive": false }
Why doesn’t env.Append(build_flags… append the build_flags to the environment?
Edit: It looks like a known issue:
I hope there is a workaround