Why would that be important? If the code is accessing your header file it doesn’t matter if the -I flag to the include directory is the last or the first.
Hmm answering a HOW question with a WHY question !
The search order do matter if there is include files with the same name !
Example 1:
I would like to use the same source-code-tree to compile Marlin for all my 3D printers, the only thing that differ between them is the two headerfiles Configuration.h and Configuration_adv.h, and their env section in platformio.ini so it would be very convenient to have specific dir per 3D printer with these two files,
So after introducing a fix/feature, “pio run” can compile a new firmware for all my 3D printers
Example 2
SoftI2CMaster is an i2c implementation on any iopins, out of the box the header-file does not allow this on cpu that do have dedicaded i2c-hw.
So if you wanted to do i2c on f.ex. Port D bit 6-7 on an atmega168 you need to patch the header file.
Both of the above would be trivial to implement i Makefile based system.
I had hoped that something similar would be possible with platformio,
Yes, since there’s always a possibility of it being an ‘XY Problem’.
Can’t you remove the Configuration*.h files from the main folder so that by default they are not found, and then introduce -I switches to your specific configuration directory in the specific environments?
You can also try to readout env['CPPPATH'], reorder the returned array and use env.Replace(CPPPATH=new_arr), see docs.
I must admit that this is my first encounter with PlatformIO, so I had no idea what is possible out of the box, so I just thought I would ask here before having to look through the doc/code. So to answer my own question:
No I do not think there is way to manipulate the include-search-path-order by setting a parameter in the platformio.ini file.
But you can change the behavior by writing a small python script to do it.