How do I add custom content to platform.ini during project build process?

Good morning.

I have been doing some testing with PlatformIO for programming our FPGA-based XLR8 development board. I would like to give our customers a quick tutorial on how to use it, as well. However, I’d like to see one more portion of the process automated for them if possible.

Our XLR8 board needs a specific define passed as a command line argument in order to use our libraries. For example:

; ARDUINO_XLR8 flag is required for the XLR8 libraries
; It is intended to ensure that an XLR8 board is the target
build_flags = -DARDUINO_XLR8

I have been adding it manually to the platform.ini file, but I have to believe that there is a way to automate the process. Since I am new to PlatformIO, I thought I’d ask the community for some assistance.


Hello! Maybe environment variables might be useful?

Yes, I think that would work. I would like it to happen automatically, though, when someone selects our boards and creates a new project. Not sure how to configure the tool so that the environment variables are automatically created.

Does that make sense?

You can also add -DARDUINO_XLR8 define to the extra_flags field in the board manifest

Yes! This is what I was looking for. Excellent.