I have an
extra.py script in my library, which generates a board-specific header on-the-fly. It works brilliantly, by saving this file next to some other library headers. But there are some issues with this approach:
- I have to add this file to
.gitgnoreto prevent it from getting checked in
- it breaks when building the library for two different boards at the same time
- I have to check which version is currently present to re-generate only when the board changes
It would be simpler / cleaner / better, IMO, to place such generated files somewhere in the
.pio/build/<envname>/ tree, because that fixes all of the above in one sweep.
I can’t quite decide where to put them, though, as there is no spot inside
.pio/ where an include file will be automatically found, as far as I can tell:
arm-none-eabi-g++ -o .pio/build/l432/lib566/jeeh-dev/jee.o -c -std=c++17 -fno-rtti -fno-exceptions -Wall -Wextra -Wno-format -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -DPLATFORMIO=60000 -DSTM32L432xx -DF_CPU=80000000L -I/Users/jcw/code/jee/jeeh-dev -I/Usersemail@example.com/CMSIS/Include -I/Users/jcw/.platformio/packages/framework-cmsis-stm32l4/Include /Users/jcw/code/jee/jeeh-dev/jee.cpp
-I... settings point into the
~/.platformio/ area, as you can see.
Is there some “natural” spot to put these generated headers? Would I then have to add a somewhat-funky include path to that directory myself? It might be useful to come up with a convention for this, so that custom script-generated files can live near compiler-generated
.o files, etc.
Please note that this is for a library (with its own
library.json file), which gets included into a PIO project. It’s not about the PIO main project but about the library build. The generated header comes from an
extra.py script in the library, not in the main project.
(There’s a working demo in this zip file, which can be run as “
cd examples && pio run -e l432”, the generated file is called
jee-svn.h - if anyone wants to dig into this …)