Hi!
I’ve search here and didn’t found a working solution. My goal is to set a define from a library extra_script that will be visible from every compiled file.
Looking at the various answers here, I’ve managed to have the following build script in the library that almost work… almost because it work when building the project for the native platform, but fails on esp32 using esp-idf (I’m using pio 6.1.16 with latest espidf builder)
With the code below, I can see the flag in every library except the main app! But why does it work for native and not for espidf? I know that setting the cpp defines in projenv solved the issue with native.
I tried everything, but maybe it’s just not possible and should look for an other solution?
Thanks!
My extra script is here:
Import("projenv")
global_env = DefaultEnvironment()
# propagate too all possible envs... iterate to all libraries + global_env for some libraries + projenv for the app
envs = [ lb.env for lb in env.GetLibBuilders()] + [global_env, projenv]
for e in envs:
e.Append(CPPDEFINES=[
("VERSION_MAJOR", pkg_json["sdk_major"]),
("VERSION_MINOR", pkg_json["sdk_minor"]),
("VERSION_REVISION", pkg_json["sdk_revision"]),
("GIT_REVISION", '\\"%s\\"' %(pkg_json["git_revision"])),
])