Selectively compile multiple main files

Lets say I have “main1.ino” and “main2.ino” in the “src” directory of a single project.
I want to selectively compile and load either main1 or main2.

I’ve tried:

But it still seems to build all *.ino files

This pattern looks weird – first everything is added, then some exclusion happnen, and then some re-adds happen.

Also, you’re putting a / at then of the last two rules. These are for folders, not files. So you shoul firts try and removing the trailing / from the last two rules.

If that does not work, remove the last two rules and replace them a simpler -<main2.ino> rule to disable compiling main2 (so that main1 will still be compiled), and the reverse for the others.

Maybe also .ino files are special since PlatformIO converts them to cpp files. You can then try -<main2.ino.cpp> as a rule.