That was apparently because the task was not linked to the main build target. Adding Depends() call fixed it.
extra_script.py
:
Import("env")
c = env.Command('msgs.c', 'msgs.txt', action="cp $SOURCE $TARGET")
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", c)