Include search path order

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.

So the fix to my problem was to write a script:

import os
Import("env")
if os.path.isdir(env['PIOENV']):
    incdir = env['PIOENV']
else:
    incdir = "."
env['_CPPINCFLAGS'] = "-I%s $( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)" % (incdir)

in platformio.ini we will specify that the script should be run before compiling

[env]
extra_scripts = pre:prepend_cpppath.py

If you should be interested in further details I have shared my notes on my blog:

http://peter.lorenzen.us/3d-printer/platformio-and-marlin-and-how-to-have-separate-config-files-for-different-3dprinter-while-sharing-the-same-code