Using SCons Command and Builder from platformio extra_script?

I’m trying to use SCons Command from within an extra_script.

However it appears to have no effort whatsoever on the build process - the build_func is never executed, and the files are not in the tree (as seen by setting SCONSFLAGS=--tree=status).

I also tried changing projenv to env, and switch form post to pre setting to no effect.

Any ideas what am I doing wrong and how to utilize those “advanced” SCons features from extra_scripts?

def build_func(target, source, env):
    print(f">>>> build_func T:{target} S:{source}")

c = projenv.Command('msgs.c', 'msgs.txt', action=build_func)

To answer my own question, the problem was that the file node created was not set as a dependency of the main target.

Here’s a working example:

c = env.Command('msgs.c', 'msgs.txt', action="cp $SOURCE $TARGET")
1 Like