MakeDirectoryBuilder = Builder(action=my_mkdir, target_factory=Dir)
env = Environment()
env.Append(BUILDERS = {'MakeDirectory':MakeDirectoryBuilder})
-env.MakeDirectory('new_directory')
+env.MakeDirectory('new_directory', [])
.EE
.IP source_factory
- Packaging build fix: Rebuild the files that are use to report the
--version of SCons whenever the development version number changes.
+ - Fix the ability to specify a target_factory of Dir() to a Builder,
+ which the default create-a-directory Builder was interfering with.
+
From Clive Levinson:
- Make ParseConfig() recognize and add -mno-cygwin to $LINKFLAGS and
for t in tlist:
if t.side_effect:
raise UserError, "Multiple ways to build the same target were specified for: %s" % str(t)
- if t.has_builder():
+ if t.has_explicit_builder():
if not t.env is None and not t.env is env:
t_contents = t.builder.action.get_contents(tlist, slist, t.env)
contents = t.builder.action.get_contents(tlist, slist, env)
single_source = 0,
name = None,
chdir = _null,
+ is_explicit = 1,
**overrides):
if __debug__: logInstanceCreation(self, 'BuilderBase')
self.action = SCons.Action.Action(action)
self.executor_kw = {}
if not chdir is _null:
self.executor_kw['chdir'] = chdir
+ self.is_explicit = is_explicit
def __nonzero__(self):
raise InternalError, "Do not test for the Node.builder attribute directly; use Node.has_builder() instead"
self.builder = builder
def has_builder(self):
return not self.builder is None
+ def has_explicit_builder(self):
+ return not self.builder is None and self.builder.is_explicit
def env_set(self, env, safe=0):
self.env = env
def add_source(self, source):
MkdirBuilder = SCons.Builder.Builder(action = Mkdir,
env = None,
explain = None,
+ is_explicit = None,
name = "MkdirBuilder")
return MkdirBuilder
self._dict.update(dict)
class Builder:
- def __init__(self):
+ def __init__(self, is_explicit=1):
self.env = Environment()
self.overrides = {}
self.action = MyAction()
+ self.is_explicit = is_explicit
def targets(self, t):
return [t]
def get_actions(self):
n1.builder_set(Builder())
assert n1.has_builder() == 1
+ def test_has_explicit_builder(self):
+ """Test the has_explicit_builder() method
+ """
+ n1 = SCons.Node.Node()
+ assert not n1.has_explicit_builder()
+ n1.builder_set(Builder(is_explicit=1))
+ assert n1.has_explicit_builder()
+ n1.builder_set(Builder(is_explicit=None))
+ assert not n1.has_explicit_builder()
+
def test_multiple_side_effect_has_builder(self):
"""Test the multiple_side_effect_has_builder() method
"""
b = self.builder
return not b is None
+ def has_explicit_builder(self):
+ """Return whether this Node has an explicit builder
+
+ This allows an internal Builder created by SCons to be marked
+ non-explicit, so that it can be overridden by an explicit
+ builder that the user supplies (the canonical example being
+ directories)."""
+ return self.has_builder() and self.builder.is_explicit
+
multiple_side_effect_has_builder = has_builder
def is_derived(self):
scons: `.' is up to date.
"""))
+
+
+test.write('SConstruct', """\
+import os
+def my_mkdir(target=None, source=None, env=None):
+ os.mkdir(str(target[0]))
+
+MDBuilder = Builder(action=my_mkdir, target_factory=Dir)
+env = Environment()
+env.Append(BUILDERS = {'MD':MDBuilder})
+env.MD(target='sub1', source=['SConstruct'])
+env.MD(target='sub2', source=['SConstruct'], OVERRIDE='foo')
+""")
+
+test.run()
+
test.pass_test()