Source

SCons / src / scons / Builder.py

The default branch has multiple heads

"""scons.Builder

XXX

"""

__revision__ = "Builder.py __REVISION__ __DATE__ __DEVELOPER__"



import os
from types import *
from scons.Node.FS import Dir, File, lookup



class Builder:
    """Base class for Builders, objects that create output
    nodes (files) from input nodes (files).
    """

    def __init__(self,	name = None,
			action = None,
			input_suffix = None,
			output_suffix = None,
			node_class = File):
	self.name = name
	self.action = action
	self.insuffix = input_suffix
	self.outsuffix = output_suffix
	self.node_class = node_class
	if not self.insuffix is None and self.insuffix[0] != '.':
	    self.insuffix = '.' + self.insuffix
	if not self.outsuffix is None and self.outsuffix[0] != '.':
	    self.outsuffix = '.' + self.outsuffix

    def __cmp__(self, other):
	return cmp(self.__dict__, other.__dict__)

    def __call__(self, target = None, source = None):
	node = lookup(self.node_class, target)
	node.builder_set(self)
	node.sources = source	# XXX REACHING INTO ANOTHER OBJECT
	return node

    def execute(self, **kw):
	"""Execute a builder's action to create an output object.
	"""
	# XXX THIS SHOULD BE DONE BY TURNING Builder INTO A FACTORY
	# FOR SUBCLASSES FOR StringType AND FunctionType
	t = type(self.action)
	if t == StringType:
	    cmd = self.action % kw
	    print cmd
	    os.system(cmd)
	elif t == FunctionType:
	    # XXX WHAT SHOULD WE PRINT HERE
	    self.action(kw)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.