[Scons-users] Custom Builders / Command / Execute

William Blevins wblevins001 at gmail.com
Mon Oct 31 22:42:10 EDT 2016


Pierre-Luc,

SCons Command/Execute merely invoke the action specified in a shell, so for
your purposes, you do not need (nor shouldn't) execute this in a subprocess
because now you have the process that SCons created plus the extra one that
you have created (potentially).

Execute always does said thing (even if it the targets are up-to-date which
is obviously inefficient) immediately which means it happens during the
SConstruct parsing step and cannot be done in parallel with other SCons
processes. I imagine this is undesired even if acceptable.

Command will not execute if there are no targets (IE. all targets
up-to-date by default, right?). Also, Command will do nothing if all
targets are up-to-date which is desired I imagine?

Questions 1/2: No, I would not recommend using Command/Execute inside a
custom builder. The point of making a custom builder to do something that a
basic Command cannot do. Also, I am pretty sure this breaks the
multi-threading requirements of the system with regards to scanners. You
can look at SCons tools under src/engine/SCons/Tool for more examples (but
those may be complex).

Question 3: Yes, since SCons will already execute your command in a shell.
With -j2+ this implies SCons will already be creating a subprocess for the
action.

V/R,
William

On Mon, Oct 31, 2016 at 9:43 PM, Pierre-Luc Boily <pierreluc.boily at gmail.com
> wrote:

> Hello,
>
> I am playing with a custom builder (Builders That Execute Python Functions)
> that I want to make better.
>
> Our first iteration was using subprocess /call /to execute a batch file (a
> batch file that was compiling grammars).  I realized that using python
> subprocess /call /is kind of evil because it is not using scons
> environment.
>
> Then, I decided to change my python function to use scons /Command /instead
> (Still inside the custom builder).  Then again, I got plenty of problems
> and
> I was quite confused between target/source given to my actual custom
> builder
> and target/source given to scons /Command/.  It was not working at all.
> /Command /was not even called or I got errors with target
>
> Finally, after all this, I found scons /Execute/.  I decided to give a try
> so now, my custom builder uses /Execute /to actually execute external call.
> It worked pretty well.
>
> Questions
> 1 - Does that make sense to use Command inside a custom builder?
> 2 - Is it appropriate to use Execute inside my custom builder?
> 3 - Do you agree that using python subprocess call might be bad?
>
>
>
> --
> View this message in context: http://scons.1086193.n5.
> nabble.com/Custom-Builders-Command-Execute-tp40687.html
> Sent from the Users mailing list archive at Nabble.com.
> _______________________________________________
> 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/20161031/a995ce22/attachment.html>


More information about the Scons-users mailing list