pavel
July 5, 2021, 12:37pm
1
I’m using extraScript to generate some sources before build.
All works fine if I’m putting all generated sources inside src/
dir.
Actually, it is better to place for generated sources is inside build dir:
build_path = env.GetBuildPath("$BUILD_DIR")
generated_src_dir = os.path.join(build_path, 'mylib', 'generated')
env.Append(CPPPATH=[generated_src_dir])
All include headers, located in generated
from this example can be seen by the project. Main problem is that .c/.cpp
files not compiled in this case.
I tried to add them with SRC_FILTER
but failed (seems because it accepts only relative paths):
env.Append(SRC_FILTER=[f"+<{generated_src_dir}/*>"])
So, how to add generated sources located inside build directory to the project?
pavel
July 7, 2021, 8:27pm
2
So, can somebody tell me, is it possible to place generated sources outside src folder?
Exactly, the path here is relative the src_dir
.
I’m not sure if it’s possible what you want to do, adding source files from the build output directory in the build system. You can also open issue at Issues · platformio/platformio-core · GitHub for clarification.
pavel
July 7, 2021, 9:19pm
4
I found another solution to add custom sources dir:
build_path = env.subst("$BUILD_DIR")
generated_src_dir = os.path.join(build_path, 'mylib', 'generated')
generated_build_dir = os.path.join(build_path, 'mylib', 'generated', 'build')
env.Append(CPPPATH=[generated_src_dir])
env.BuildSources(generated_build_dir, generated_src_dir)
This works.
2 Likes