summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CHANGES.txt2
-rw-r--r--src/engine/SCons/Util.py10
-rw-r--r--src/engine/SCons/UtilTests.py19
-rw-r--r--test/Value.py17
4 files changed, 38 insertions, 10 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 2159249..326f9cf 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -304,6 +304,8 @@ RELEASE 0.97 - XXX
- Add --debug=objects logging of creation of OverrideWarner,
EnvironmentCopy and EnvironmentOverride objects.
+ - Fix command-line expansion of Python Value Nodes.
+
From Levi Stephen:
- Allow $JARCHDIR to be expanded to other construction variables.
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index ec809b9..896abaf 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -493,7 +493,15 @@ def subst_dict(target, source):
dict['TARGET'] = Target_or_Source(tnl)
if source:
- snl = NLWrapper(source, lambda x: x.rfile().get_subst_proxy())
+ def get_src_subst_proxy(node):
+ try:
+ rfile = node.rfile
+ except AttributeError:
+ pass
+ else:
+ node = rfile()
+ return node.get_subst_proxy()
+ snl = NLWrapper(source, get_src_subst_proxy)
dict['SOURCES'] = Targets_or_Sources(snl)
dict['SOURCE'] = Target_or_Source(snl)
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index 18fd3c2..c5c5297 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -1364,27 +1364,32 @@ class UtilTestCase(unittest.TestCase):
assert SOURCES == ['s1', 's2'], d['SOURCES']
assert str(d['SOURCE']) == 's1', d['SOURCE']
- class N:
+ class V:
+ # Fake Value node with no rfile() method.
def __init__(self, name):
self.name = name
def __str__(self):
- return self.name
- def rfile(self):
- return self.__class__('rstr-' + self.name)
+ return 'v-'+self.name
def get_subst_proxy(self):
return self
+ class N(V):
+ def rfile(self):
+ return self.__class__('rstr-' + self.name)
+
t3 = N('t3')
t4 = DummyNode('t4')
+ t5 = V('t5')
s3 = DummyNode('s3')
s4 = N('s4')
- d = subst_dict(target=[t3, t4], source=[s3, s4])
+ s5 = V('s5')
+ d = subst_dict(target=[t3, t4, t5], source=[s3, s4, s5])
TARGETS = map(lambda x: str(x), d['TARGETS'])
TARGETS.sort()
- assert TARGETS == ['t3', 't4'], d['TARGETS']
+ assert TARGETS == ['t4', 'v-t3', 'v-t5'], TARGETS
SOURCES = map(lambda x: str(x), d['SOURCES'])
SOURCES.sort()
- assert SOURCES == ['rstr-s4', 's3'], d['SOURCES']
+ assert SOURCES == ['s3', 'v-rstr-s4', 'v-s5'], SOURCES
def test_PrependPath(self):
"""Test prepending to a path"""
diff --git a/test/Value.py b/test/Value.py
index e3106b8..46f8232 100644
--- a/test/Value.py
+++ b/test/Value.py
@@ -40,7 +40,7 @@ for source_signature in ['MD5', 'timestamp']:
print "Testing Value node with source signatures:", source_signature
test.write('SConstruct', """
-SourceSignatures(r'%s')
+SourceSignatures(r'%(source_signature)s')
class Custom:
def __init__(self, value): self.value = value
@@ -55,10 +55,20 @@ def create(target, source, env):
env = Environment()
env['BUILDERS']['B'] = Builder(action = create)
+env['BUILDERS']['S'] = Builder(action = "%(python)s put $SOURCES into $TARGET")
env.B('f1.out', Value(P))
env.B('f2.out', env.Value(L))
env.B('f3.out', Value(C))
-""" % source_signature)
+env.S('f4.out', Value(L))
+""" % {'source_signature':source_signature,
+ 'python':TestSCons.python})
+
+ test.write('put', """
+import os
+import string
+import sys
+open(sys.argv[-1],'wb').write(string.join(sys.argv[1:-2]))
+""")
test.run(arguments='-c')
test.run()
@@ -74,6 +84,7 @@ env.B('f3.out', Value(C))
test.must_match('f1.out', "/usr/local")
test.must_match('f2.out', "10")
test.must_match('f3.out', "C=/usr/local")
+ test.must_match('f4.out', '10')
test.up_to_date(arguments='.')
@@ -89,6 +100,7 @@ env.B('f3.out', Value(C))
test.must_match('f1.out', "/usr")
test.must_match('f2.out', "4")
test.must_match('f3.out', "C=/usr")
+ test.must_match('f4.out', '4')
test.up_to_date('prefix=/usr', '.')
@@ -106,5 +118,6 @@ env.B('f3.out', Value(C))
test.must_match('f1.out', "/var")
test.must_match('f2.out', "4")
test.must_match('f3.out', "C=/var")
+ test.must_match('f4.out', "4")
test.pass_test()