through "chdir" keyword arguments to Action and Builder creation
and calls.
+ - Fix handling of Action ojects (and other callables that don't match
+ our calling arguments) in construction variable expansions.
+
From Clive Levinson:
- Make ParseConfig() recognize and add -mno-cygwin to $LINKFLAGS and
r.append(self.conv(self.substitute(l, lvars)))
return string.join(r)
elif callable(s):
- s = s(target=self.target,
- source=self.source,
- env=self.env,
- for_signature=(self.mode != SUBST_CMD))
+ try:
+ s = s(target=self.target,
+ source=self.source,
+ env=self.env,
+ for_signature=(self.mode != SUBST_CMD))
+ except TypeError:
+ # This probably indicates that it's a callable
+ # object that doesn't match our calling arguments
+ # (like an Action).
+ s = str(s)
return self.substitute(s, lvars)
elif s is None:
return ''
self.substitute(a, lvars, 1)
self.next_word()
elif callable(s):
- s = s(target=self.target,
- source=self.source,
- env=self.env,
- for_signature=(self.mode != SUBST_CMD))
+ try:
+ s = s(target=self.target,
+ source=self.source,
+ env=self.env,
+ for_signature=(self.mode != SUBST_CMD))
+ except TypeError:
+ # This probably indicates that it's a callable
+ # object that doesn't match our calling arguments
+ # (like an Action).
+ s = str(s)
self.substitute(s, lvars, within_list)
elif s is None:
self.this_word()
def is_literal(self):
return 1
+ class TestCallable:
+ def __init__(self, value):
+ self.value = value
+ def __call__(self):
+ pass
+ def __str__(self):
+ return self.value
+
def function_foo(arg):
pass
'RECURSE' : 'foo $RECURSE bar',
'RRR' : 'foo $SSS bar',
'SSS' : '$RRR',
+
+ # Test callables that don't match the calling arguments.
+ 'CALLABLE' : TestCallable('callable-1'),
}
env = DummyEnv(loc)
# Bug reported by Christoph Wiedemann.
cvt('$xxx/bin'), '/bin',
+
+ # Tests callables that don't match our calling arguments.
+ '$CALLABLE', 'callable-1',
]
kwargs = {'target' : target, 'source' : source}
self.attribute.attr1 = 'attr$1-' + os.path.basename(name)
self.attribute.attr2 = 'attr$2-' + os.path.basename(name)
+ class TestCallable:
+ def __init__(self, value):
+ self.value = value
+ def __call__(self):
+ pass
+ def __str__(self):
+ return self.value
+
target = [ MyNode("./foo/bar.exe"),
MyNode("/bar/baz with spaces.obj"),
MyNode("../foo/baz.obj") ]
'RECURSE' : 'foo $RECURSE bar',
'RRR' : 'foo $SSS bar',
'SSS' : '$RRR',
+
+ # Test callable objects that don't match our calling arguments.
+ 'CALLABLE' : TestCallable('callable-2'),
}
env = DummyEnv(loc)
'<$AAA', [['<', 'a']],
'>$AAA', [['>', 'a']],
'|$AAA', [['|', 'a']],
+
+ # Test callables that don't match our calling arguments.
+ '$CALLABLE', [['callable-2']],
]
kwargs = {'target' : target, 'source' : source}
test.up_to_date(arguments = '.')
+# Make sure we can expand actions in substitutions.
+test.write('SConstruct', """\
+def func(env, target, source):
+ pass
+env = Environment(S = Action('foo'),
+ F = Action(func),
+ L = Action(['arg1', 'arg2']))
+print env.subst('$S')
+print env.subst('$F')
+print env.subst('$L')
+""")
+
+test.run(arguments = '-Q .', stdout = """\
+foo
+func(env, target, source)
+arg1
+arg2
+scons: `.' is up to date.
+""")
+
test.pass_test()