Reputation: 339
I've been searching the documentation for a long time and still can't figure this out.
In the SCons documentation, there is discussion about adding a PreAction or PostAction. In the examples, they call an example method:
foo = Program('foo.c')
AddPreAction(foo, 'pre_action')
This calls 'pre_action' before 'foo.c' is compiled and linked. However, there is no explanation about what format 'pre_action' must take.
I have discovered that there are several pre-built actions, such as 'Copy'. However, I cannot find the source of 'Copy' to reverse-engineer it and write my own.
Can anyone point me to a guide as to how to create my own Actions? I either need an interface for calling my own method such as 'pre_action' above, or a guide for writing an Action class.
Really, even just some example code that is actually complete enough to use would be helpful...
Upvotes: 1
Views: 888
Reputation: 909
The manpage section Action Objects lists the types of things that can be passed to the Action
factory function to create an action; that is also what you pass to AddPostAction
and AddPreAction
as the second argument - that is, either an Action already made by a previous call to Action
, or something that can be converted into one like a command string, or a list of such, or a function with appropriate signature. Pre/Post will simply call the Action
function with that argument. So in that section, where there's an example with a call to Action
, you could just plug that argument into AddPreAction
, or you could save the result of calling Action
and give that as the argument to AddPreAction
.
The amount of flexibility here makes it a little tricky to document concisely.
(btw the source to Copy
is a function called copy_func
but you probably don't want to use that form because it's a couple of extra levels of abstraction you won't need)
Upvotes: 1