I’m developing a library for a HAL for several of our boards. It works on STM32(stm32cube) and ESP32 (IDF).
I want some source files to be compiled only for some targets. In the future I may split the library in multiple libraries, but for now I want one library, since there is a lot of common code
In my library.json i’ve set my extraScript to a python script, where I handle advanced platform depended things such as dependencies.
This works well. But there is one thing I cannot move from library.json to extraScript.
I cannot get this include path flag working in my script and I don’t want the include folder for stm32 to be visible for esp32 to avoid possible header-file naming conflicts. I cannot edit some of these files, because I’ve generated them with STM32CubeMX and don’t want to change those too much.
I’m getting this error if I remove the flags and try to add them in my script:
fatal error: usbd_conf.h: No such file or directory
Here is what I’ve tried so far:
How can I add include folder paths in my python script?
Looking at the above example, I think you should rather use CPPPATH (and maybe SRC_FILTER for exclusion) and not build_flags. Also LINKFLAGS should not be needed – the final linker script involves only linking the compiled object files and archive files, no include files are needed there.
It is loosely based on the lib found in HAL-based library. It is a seperate library, not in the lib folder.
All sources build. Only the header files in the src/stm32 folder are not seen by the compiler (the other folders still have their build flags).
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.
Maybe it is better to create our own board definitions and add it there.
And I would like to move custom_freertos_config_location variable from the ini to the library as well. Right now it is located in the user project. I was able to remove the file and change the value with: