Using env name as board type?

As described here, I often use the following approach in my platformio.ini file, to allow building many different small apps for the same target board:

[env]

src_filter = +<${PIOENV}.cpp>
...

[env:app1]
[env:app2]
[emv:app3]

The other scenario I tend to use is building the same app for different boards, which would benefit from something like this:

[env]
board = $PIOENV
...

[env:disco_f412zg]
[env:nucleo_g431rb]
[env:nucleo_l432kc]

Unfortunately, that does not work. The PIOENV variable does not get expanded for board in the same was as if does for src_filter.

Something related but not quite the same has been discussed here.

Would it be an idea to add support for this? I assume that such a change would not be difficult, but I’m not familiar enough with the PIO code to easily find my way around. I can have a go at extending the Python code if someone helps me out as to which file I’d need to look into …

Another option I guess, would be to use pio ci [OPTIONS] [SRC]... for this, but that’s a command-line chore which you have to remember each time, whereas the PIOENV expansion can be specified once in the ini file and then automatically kicks in.

-jcw

Update: this topic also addresses the board vs app puzzle.

You’ve typed ${PIOENV} in the first snippet, and $PIOENV (no braces) in the second one, I’m not sure but maybe that makes the difference?