[Scons-users] Controlling display of a builder

Bill Deegan bill at baddogconsulting.com
Sat Oct 17 15:57:40 EDT 2015


Carnë,

No need to do all that coding.  SCons will expand and escape arguments for
you..


env=Environment()


if False:
    scons_subprocess_call = (lambda target, source, env
                             : subprocess.call(env['ARGS'], source[0]))
    data = env.Command(
        source = "foo.pl",
        target = "bar.log",
        action = scons_subprocess_call,
        ARGS   = ['homo sapiens', 'Reference GRCh'])
else:
    data = env.Command(
        source = "./foo.pl",
        target = "bar.log",
        action = "${SOURCE.abspath} $ARGS  > $TARGET",
        ARGS   = ['homo sapiens', 'Reference GRCh'])



Produces:
python ~/devel/scons/hg/scons/bootstrap.py
/usr/bin/python
/Users/bdbaddog/devel/scons/hg/scons/bootstrap/src/script/scons.py
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
/Users/bdbaddog/devel/scons/bugs/10_17_2015/foo.pl "homo sapiens"
"Reference GRCh" > bar.log
scons: done building targets.

(I added the .abspath because for some reason it was saying couldn't find
foo.pl and I didn't feel like fooling around with that).

-Bill

On Sat, Oct 17, 2015 at 11:55 AM, Carnë Draug <carandraug+dev at gmail.com>
wrote:

> Hi
>
> I have been using the possibility to pass extra arguments to Command
> to have them used in a builder.  I am doing something like the following:
>
>     scons_subprocess_call = (lambda target, source, env
>                                     : subprocess.call(env['ARGS'],
> source[0]))
>
>     data = env.Command(
>       source = "foo.pl",
>       target = "bar.log",
>       action = scons_subprocess_call,
>       ARGS   = ['homo sapiens', 'Reference GRCh'])
>
> The problem with this is that the output of SCons won't display anything
> useful:
>
>     $ scons
>     [...]
>     scons: Building targets ...
>     <lambda>(["bar.log"], ["foo.pl"])
>     [...]
>
> The main reason I am doing this is to avoid the shell since some of the
> arguments have whitespace, single and double quotes, and even wildcards.
> This makes generation of a command problematic.  I have tried to write my
> own builder but the problem remains.  I create a Builder either by
> setting a `action`, and continue with the problem of not having the actual
> call made displayed, or by setting a `generator`, and face the problem of
> escaping any weird stuff in the arguments.
>
>
> Short of having the builder print() something, is there any way to create
> a Builder that does not boil down to create a command line for the shell,
> while still controlling what SCons displays?
>
> (I am aware that this means that what gets displayed will not match
> a command line.  However, it would still be more informative)
>
> Thank you,
> Carnë
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20151017/f905059f/attachment-0001.html>


More information about the Scons-users mailing list