Add additional EXTERNAL include (file) path via script

I have a prebuild script, that creates an include file “webpage.h”
it gets built in the “.pio/build/www/include” folder

and in code i do:
include “webppage.h”

how can i get the compiler to find it?
(since its not in the src path)

without path details in the actual include statement
i dont want to do include “../.pio/build/www/include/webpage.h”

thanks all

Mitch

It is unusual to place header files in the .pio/build folder, as this is an output folder for the compiled binary files.

However, you can add that directory by using the -I flag:

build_flags = 
  -I.pio/build/www/include

Please note: Any change to the project (or the platformio.ini file) will result in the contents of the directory being (partially) deleted. This should be no problem since your script runs automatically during the build process.

yes, i know… the script takes a bunch of files from my src folders and creates that “webpage.h”
in the script, how do i append to existing build_flags?

like:
env.append(“build_flags”, “-I.pio/build/www/include”)

I don’t know how it can be done with a script (since I’m not familiar with advanced scripting).
Maybe @maxgerhardt knows :slight_smile:

got it!

env.Append(BUILD_FLAGS=[f"-I {cIncludePath}"])

but new problem with this method the path added by the build_flags -I
does not get into the c_cpp_properties.json file
and the editor cant find it and flags it as errors

image

solved that with a rebuild inteillSense index

all good now

TY