I have set environment variables within python scripts so that I can use them in my source files. I know how to use a common section and refer to those settings in board-specific settings. What I am looking for is how I might set a platformio.ini
value via the environment set by the python script.
Specifically, I have tried this:
- Within
build_flags
specify a python file with!python script.py
which sets an environment variable withprint("-DPORT={0}".format("COM*))
- Within
platformio.ini
, “read” that value when settingupload_port
andmonitor_port
with something likeupload_port = -DPORT
The end goal here is not having to edit the platformio.ini
port values as we switch between a Mac and a Windows user. It seems to work fine with auto settings on Windows machines, but apparently, the developer on the Mac has to be more explicit.