[Scons-users] Dividing SConstruct code into set of aliases; no code called by default
Faheem Mitha
faheem at faheem.info
Mon Oct 20 10:34:21 EDT 2014
Hi,
I just posted this to Stack Overflow.
http://stackoverflow.com/q/26467113/
The text of the question follows.
I'd appreciate comments, clarification, explanation.
Please CC me on any reply. Thanks.
Regards, Faheem Mitha
#########################################################################
I'm trying to divide up my SConstruct file into blocks of code, where each
block is controlled by an Alias, and no code is run by default; i.e. just
by runningscons. The Aliases are of course run from the command line e.g.
(in the example below):
scons h
Here is some example code. This appears to work Ok. However, three
questions.
Is there a better way to do this?
More specifically, I don't understand how the target arguments in the
Alias call get passed to the h and h3 action functions. I notice if I
leave them blank the build does not work. However there is no obvious way
for the targets to be passed to these functions, since they do not take
any arguments.
Relatedly, the documentation says that action functions requires target,
source, and env arguments. These action functions don't have these but
work anyway. How come?
Code follows:
#!/usr/bin/python
Default(None)
def h(env):
x = env.Program("hello1", "hello1.c")
y = env.Program("hello2", "hello2.c")
return 0
def h3(env):
y = env.Program("hello3", "hello3.c")
return 0
env = Environment()
env.AddMethod(h, "HELLO")
env.AddMethod(h3, "HELLO3")
env.Alias("h", ["hello1", "hello2"], env.HELLO())
env.Alias("h3", ["hello3"],env.HELLO3())
More information about the Scons-users
mailing list