Goodday,
I am trying to create my own (for now local) library with multiplatform/board support. For that I simply export headers where its implementation are done differently per platform/board. I have a subdirectory per case, so it shouldn’t be too difficult to guide the builder/libraryManager towards the correct source dir right?
I dont want to use the platformio.ini
file since it is a library (unless its possible to use it for libraries as well > i.e. Have one for the project, and one for each used library. I couldn’t find any info on that)
From what I read, its best to use an extra_script
to handle all cases cleanly. But I got a few unknown factors which are hard to find in the documentations:
- It seems like the
extra script
declarations in thelibrary.json
file does not support thepre:
andpost:
prefixes? So it can only be run before the actual buildscript? (not that I need the ‘post’ version, but I was wondering) - Assuming there is only a pre-build phase, only the
env
/Import("env")
is valid I assume? - The main
src_dir
e.s. properties ofenv
are based on the actual project, not the library (eventhough the script is only declared in thelibrary.json
file), meaning I should NOT touch those properties/cannot use those properties to alter the library’s source-dir? - The
env.GetLibraryBuilders()
function always returns an empty array, meaning I cannot easily modify its metadata to pick the correct src-dir based on the build/environment properties? Or is there another trick to this? - I tried adding an action using
env.AddPreAction(...)
. Whether I usebuildprog
,build
, a source-file or a build/output file, it does not seem to fire the action at all, so it might be a ‘project-only’ thing? I was hoping the dependency-graph would be build by than, so I could use the function mentioned in point 4. But maybe I am doing something wrong? - I tried the
env.AddBuildMiddleware(...)
which does work, so that could be an option, but it doesn’t have my preference as it might add a lot of overhead compared to a src-dir altering. - I read about the
env.BuildSources(...)
function, but I assume this is meant for the project only and not for library sources? (based on the explanation here
I would love some input for this concept. If I should approuch this problem a different way I would love to know as well.
Thanks in advance!