[Scons-users] Command vs. Action

Dirk Bächle tshortik at gmx.de
Sun Jun 12 09:07:03 EDT 2016


Hi Stefan,

Am 10.06.2016 um 20:13 schrieb Stefan Seefeld:
> Hello,
>
>
> in my SConscript file I have
>
>
>    def BoostRun(env, prog, target, command = "./$SOURCE > $TARGET"):
>        run = env.Command(target, prog, command)
>        return run
>
> which works reasonably well. I'd now like to fine-tune this to print a
> custom message rather than the actual command being executed. Apparently
> I need to use an 'Action' to do that, so I substitute the above by
>
>
>    def BoostRun(env, prog, target, command = "./$SOURCE > $TARGET"):
>        run = env.Command(target, prog, env.Action(command,
> cmdstr="testing..."))
>        return run
>
> This however yields an error, as the generated command is (almost)
> empty, i.e. $SOURCE and $TARGET are not properly substituted. Can anyone
> tell me what I'm missing ?

I haven't actually tested this, but I think you need to use

   SCons.Action.Action(...)

or the simple

   Action(...)

instead of "env.Action(...)" here. The latter will start to substitute 
environment variables right away, in the parsing phase...but the proper 
SOURCE and TARGET variables in the environment aren't setup yet. You 
actually want to defer the evaluation/substitution of the command 
string's content until the final command string is compiled and executed 
in the build phase.
Please also check out the UserGuide, Appendix D "Functions and 
Environment Methods", where the synopsis of "Action, env.Action" can be 
found.

Best regards,

Dirk

P.S.: You'll find that the description of env.Action yields another 
documentation bug (referring to #3030)...the links to the "Action 
Objects" section don't work in the UserGuide either. ;)



More information about the Scons-users mailing list