- Fix a stack trace when a suffix selection dictionary is passed
an empty source file list.
+ - Allow optional names to be attached to Builders, for default
+ Builders that don't get attached to construction environments.
+
From Christoph Wiedemann:
- Add an Environment.SetDefault() method that only sets values if
multi = 0,
env = None,
single_source = 0,
+ name = None,
**overrides):
if __debug__: logInstanceCreation(self, 'BuilderBase')
self.action = SCons.Action.Action(action)
self.emitter = emitter
+ # Optional Builder name should only be used for Builders
+ # that don't get attached to construction environments.
+ if name:
+ self.name = name
+
def __nonzero__(self):
raise InternalError, "Do not test for the Node.builder attribute directly; use Node.has_builder() instead"
Look at the BUILDERS variable of env, expecting it to be a
dictionary containing this Builder, and return the key of the
- dictionary."""
+ dictionary. If there's no key, then return a directly-configured
+ name (if there is one) or the name of the class (by default)."""
try:
index = env['BUILDERS'].values().index(self)
return env['BUILDERS'].keys()[index]
except (AttributeError, KeyError, ValueError):
- return str(self.__class__)
+ try:
+ return self.name
+ except AttributeError:
+ return str(self.__class__)
def __cmp__(self, other):
return cmp(self.__dict__, other.__dict__)
def test_get_name(self):
"""Test getting name of builder.
- Each type of builder should return it's environment-specific
+ Each type of builder should return its environment-specific
name when queried appropriately. """
b1 = SCons.Builder.Builder(action='foo', suffix='.o')
src_suffix = '.foo',
src_builder = b1)
b4 = SCons.Builder.Builder(action={})
+ b5 = SCons.Builder.Builder(action='foo', name='builder5')
+ b6 = SCons.Builder.Builder(action='foo')
assert isinstance(b4, SCons.Builder.CompositeBuilder)
assert isinstance(b4.action, SCons.Action.CommandGeneratorAction)
'B2': b2,
'B3': b3,
'B4': b4})
- assert b1.get_name(env) == 'bldr1', b1.get_name(env2) == 'B1'
- assert b2.get_name(env) == 'bldr2', b2.get_name(env2) == 'B2'
- assert b3.get_name(env) == 'bldr3', b3.get_name(env2) == 'B3'
- assert b4.get_name(env) == 'bldr4', b4.get_name(env2) == 'B4'
+ assert b1.get_name(env) == 'bldr1', b1.get_name(env)
+ assert b2.get_name(env) == 'bldr2', b2.get_name(env)
+ assert b3.get_name(env) == 'bldr3', b3.get_name(env)
+ assert b4.get_name(env) == 'bldr4', b4.get_name(env)
+ assert b5.get_name(env) == 'builder5', b5.get_name(env)
+ assert b6.get_name(env) == 'SCons.Builder.BuilderBase', b6.get_name(env)
+ assert b1.get_name(env2) == 'B1', b1.get_name(env2)
+ assert b2.get_name(env2) == 'B2', b2.get_name(env2)
+ assert b3.get_name(env2) == 'B3', b3.get_name(env2)
+ assert b4.get_name(env2) == 'B4', b4.get_name(env2)
+ assert b5.get_name(env2) == 'builder5', b5.get_name(env2)
+ assert b6.get_name(env2) == 'SCons.Builder.BuilderBase', b6.get_name(env2)
for B in b3.get_src_builders(env):
assert B.get_name(env) == 'bldr1'
# calling SCons.Defaults.DefaultEnvironment() when necessary.
MkdirBuilder = SCons.Builder.Builder(action = Mkdir,
env = None,
- explain = None)
+ explain = None,
+ name = "MkdirBuilder")
return MkdirBuilder
def CacheRetrieveFunc(target, source, env):
# "env" will get filled in by Executor.get_build_env()
# calling SCons.Defaults.DefaultEnvironment() when necessary.
DefaultSCCSBuilder = SCons.Builder.Builder(action = '$SCCSCOM',
- env = None)
+ env = None,
+ name = "DefaultSCCSBuilder")
return DefaultSCCSBuilder
def get_DefaultRCSBuilder():
# "env" will get filled in by Executor.get_build_env()
# calling SCons.Defaults.DefaultEnvironment() when necessary.
DefaultRCSBuilder = SCons.Builder.Builder(action = '$RCS_COCOM',
- env = None)
+ env = None,
+ name = "DefaultRCSBuilder")
return DefaultRCSBuilder
#