[Scons-users] Tech question

nileiqi at optusnet.com.au nileiqi at optusnet.com.au
Thu Jan 24 18:16:09 EST 2013




Thanks Bill,

1. Scons 1.3.0

2. I will take a good reading of manpage, thanks very much.

Daniel

----- Original Message -----
From: "SCons users mailing list"
To:"SCons users mailing list"
Cc:
Sent:Thu, 24 Jan 2013 15:07:10 -0800
Subject:Re: [Scons-users] Tech question

Daniel,

On Thu, Jan 24, 2013 at 2:14 PM, wrote:

Hi,

I am new to Scons and Python, and currently spend quite amount time to
learn other people's code and Scons user guide. Please allow me ask
some general  and tech quesitons.

Tech question
(1) Whta is the main difference between generator and action ? For
example, I have two pieces of code

****************** piece 1****************************
bld=Builder(action = Action(function_name))
env.Append(Builders= { 'foo':bld})
*********************************************************
****************** piece 2****************************
 bld=Builder(generator = function_name)
env.Append(Builders= { 'foo':bld})
 **********************************************************
when run them, what is the different ?
I'd advise you do a thorough read of the manpage. It delves more into
the depths than the users guide.
http://www.scons.org/doc/production/HTML/scons-man.html [2]

From the manpage:
generator A function that returns a list of actions that will be
executed to build the target(s) from the source(s). The returned
action(s) may be an Action object, or anything that can be converted
into an Action object (see the next section).

The generator function takes four arguments: _source_ - a list of
source nodes, _target_ - a list of target nodes, _env_ - the
construction environment,_for_signature_ - a Boolean value that
specifies whether the generator is being called for generating a build
signature (as opposed to actually executing the command). Example:

def g(source, target, env, for_signature): return [["gcc", "-c",
"-o"] + target + source] b = Builder(generator=g)
The _generator_ and _action_ arguments must not both be used for
the same Builder.

A function that returns a list of actions that will be executed to
build the target(s) from the source(s). The returned action(s) may be
an Action object, or anything that can be converted into an Action
object (see the next section).

The generator function takes four arguments: _source_ - a list of
source nodes, _target_ - a list of target nodes, _env_ - the
construction environment,_for_signature_ - a Boolean value that
specifies whether the generator is being called for generating a build
signature (as opposed to actually executing the command). Example:

def g(source, target, env, for_signature): return [["gcc", "-c",
"-o"] + target + source] b = Builder(generator=g)
The _generator_ and _action_ arguments must not both be used for
the same Builder.
 

(2) For above piece 1 code, I realize it never execute until at the
end of the code, when function Default() is called, why is that ?
SCons builds up information about the dependencies and what to do with
them from the SConstruct/SConscripts (and any other logic you may be
pulling in).
Then it will scan the source tree, figure out the dependencies, and
then execute the builders logic.

Hope that helps!
-Bill

-------------------------
Email sent using Optus Webmail

Links:
------
[1] mailto:nileiqi at optusnet.com.au
[2] http://www.scons.org/doc/production/HTML/scons-man.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20130125/4a3bed13/attachment-0001.htm>


More information about the Scons-users mailing list