7 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
20 """Base class for Builders, objects that create output
21 nodes (files) from input nodes (files).
24 def __init__(self, name = None,
28 node_factory = SCons.Node.FS.default_fs.File):
30 self.action = Action(action)
31 self.insuffix = input_suffix
32 self.outsuffix = output_suffix
33 self.node_factory = node_factory
34 if not self.insuffix is None and self.insuffix[0] != '.':
35 self.insuffix = '.' + self.insuffix
36 if not self.outsuffix is None and self.outsuffix[0] != '.':
37 self.outsuffix = '.' + self.outsuffix
39 def __cmp__(self, other):
40 return cmp(self.__dict__, other.__dict__)
42 def __call__(self, env, target = None, source = None):
43 tlist = SCons.Util.scons_str2nodes(target)
44 slist = SCons.Util.scons_str2nodes(source)
55 def execute(self, **kw):
56 """Execute a builder's action to create an output object.
58 return apply(self.action.execute, (), kw)
68 """A factory for action objects."""
69 if type(act) == types.StringType:
70 l = string.split(act, "\n")
73 if type(act) == types.FunctionType:
74 return FunctionAction(act)
75 elif type(act) == types.StringType:
76 return CommandAction(act)
77 elif type(act) == types.ListType:
78 return ListAction(act)
83 """Base class for actions that create output objects.
85 We currently expect Actions will only be accessible through
86 Builder objects, so they don't yet merit their own module."""
87 def __cmp__(self, other):
88 return cmp(self.__dict__, other.__dict__)
90 def show(self, string):
93 class CommandAction(ActionBase):
94 """Class for command-execution actions."""
95 def __init__(self, string):
98 def execute(self, **kw):
99 cmd = self.command % kw
107 args = string.split(cmd)
111 import SCons.Defaults
112 ENV = SCons.Defaults.ENV
113 os.execvpe(args[0], args, ENV)
116 pid, stat = os.waitpid(pid, 0)
122 class FunctionAction(ActionBase):
123 """Class for Python function actions."""
124 def __init__(self, function):
125 self.function = function
127 def execute(self, **kw):
129 # XXX: WHAT SHOULD WE PRINT HERE?
131 return self.function(kw)
133 class ListAction(ActionBase):
134 """Class for lists of other actions."""
135 def __init__(self, list):
136 self.list = map(lambda x: Action(x), list)
138 def execute(self, **kw):
140 r = apply(l.execute, (), kw)