Add generated file to build-source

I was wondering how a (by custom-target) generated headerfile can be added to the build-sources.

I am outputting the headerfile in a custom directory in the $BUILD_DIR, from which I would like it to be included as a dependency/library.
As esp is using cmake, their system doesn’t communicate verry wel with platformio’s SCons implementation. so using filters/includes in the PIO-env will not work.

I hoped the env.BuildSources defenition as described in external resources documentation would help out, but that also doesn’t work unfortunately.

So is there a way to include an external source through an extra-script with esp? Preferably it should be added with intellisense as well.

Thanks in advance!

But… headerfiles aren’t compiled to object files, so env.BuildSources will have 0 effect with regards to adding it to the build system or even include path.

Can you turn it around an generate a .c file that you can add with env.BuildSources that is reffered to by a static header?

It is true it won’t be compiled by itself. But shouldn’t it be implementable by regular .c/.cpp files? Right now I cannot use it (neither in intellisense nor in compilation). So as far as those files goes, they are invisible no matter what.

I tried it with the .c extension real quick, but that gave no different results unfortunately

Can you show a more detailed example of what file you generate? Intellisense might not take you to the .c implementation (because the build directory is not in env["CPPPATH"] but the build should succeed.

Turns out, I am an idiot…

I moved my scripts into a directory in a cleanup, but forgat a minor detail.

extra_scripts =
	.scripts/custom_targets.py
	.scripts/pre:pre_extra_script.py

No wonder nothing worked :smiley: .
Worked like a charm after this fix.

FAI, I simply used the CPPPath attribute as that will be picked up by the esp-idf builder.

(as far as content goes, it was a simpel attribute/config type-a-file. So only #define rules)