7 __revision__ = "Builder.py __REVISION__ __DATE__ __DEVELOPER__"
18 """Base class for Builders, objects that create output
19 nodes (files) from input nodes (files).
22 def __init__(self, name = None,
26 node_class = SCons.Node.FS.File):
28 self.action = Action(action)
29 self.insuffix = input_suffix
30 self.outsuffix = output_suffix
31 self.node_class = node_class
32 if not self.insuffix is None and self.insuffix[0] != '.':
33 self.insuffix = '.' + self.insuffix
34 if not self.outsuffix is None and self.outsuffix[0] != '.':
35 self.outsuffix = '.' + self.outsuffix
37 def __cmp__(self, other):
38 return cmp(self.__dict__, other.__dict__)
40 def __call__(self, env, target = None, source = None):
41 node = SCons.Node.FS.lookup(self.node_class, target)
42 node.builder_set(self)
44 node.sources = source # XXX REACHING INTO ANOTHER OBJECT
47 def execute(self, **kw):
48 """Execute a builder's action to create an output object.
50 apply(self.action.execute, (), kw)
60 """A factory for action objects."""
61 if type(act) == types.FunctionType:
62 return FunctionAction(act)
63 elif type(act) == types.StringType:
64 return CommandAction(act)
69 """Base class for actions that create output objects.
71 We currently expect Actions will only be accessible through
72 Builder objects, so they don't yet merit their own module."""
73 def __cmp__(self, other):
74 return cmp(self.__dict__, other.__dict__)
76 def show(self, string):
79 class CommandAction(ActionBase):
80 """Class for command-execution actions."""
81 def __init__(self, string):
84 def execute(self, **kw):
85 cmd = self.command % kw
91 class FunctionAction(ActionBase):
92 """Class for Python function actions."""
93 def __init__(self, function):
94 self.function = function
96 def execute(self, **kw):
98 # XXX: WHAT SHOULD WE PRINT HERE?