summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-04-02 05:54:02 (GMT)
committerSteven Knight <knight@baldmt.com>2004-04-02 05:54:02 (GMT)
commit04e6c5e500d27a140a7d1921d06535acc301fe98 (patch)
treed714d166ce7fc4db9500b3bda0a133d74dc502c3
parent9175dc608055e832800472992feec71de3540f1a (diff)
downloadSCons-04e6c5e500d27a140a7d1921d06535acc301fe98.zip
SCons-04e6c5e500d27a140a7d1921d06535acc301fe98.tar.gz
SCons-04e6c5e500d27a140a7d1921d06535acc301fe98.tar.bz2
Allow hybrid substitutions in PATH-like variables. (Charles Crain)
-rw-r--r--src/CHANGES.txt6
-rw-r--r--src/engine/SCons/Environment.py8
-rw-r--r--src/engine/SCons/EnvironmentTests.py18
3 files changed, 31 insertions, 1 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 0e4d4d8..b546b79 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -16,6 +16,12 @@ RELEASE 0.96 - XXX
- Allow construction variable substitutions in $LIBS specifications.
+ From Charles Crain:
+
+ - Restore the ability to do construction variable substitutions in all
+ kinds of *PATH variables, even when the substitution returns a Node
+ or other object.
+
From Tom Epperly:
- Allow the Java() Builder to take more than one source directory.
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index e332f66..e75ac38 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -432,7 +432,13 @@ class Base:
if SCons.Util.is_String(p):
p = self.subst(p, conv=s)
if SCons.Util.is_List(p):
- p = p[0]
+ if len(p) == 1:
+ p = p[0]
+ else:
+ # We have an object plus a string, or multiple
+ # objects that we need to smush together. No choice
+ # but to make them into a string.
+ p = string.join(map(SCons.Util.to_String, p), '')
else:
p = s(p)
r.append(p)
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index b2b17e1..53a6905 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -444,6 +444,24 @@ class EnvironmentTestCase(unittest.TestCase):
r = env.subst_path(['$PROXY', MyProxy('my2'), n])
assert r == ['my1-proxy', 'my2-proxy', n], r
+ class StringableObj:
+ def __init__(self, s):
+ self.s = s
+ def __str__(self):
+ return self.s
+
+ env = Environment(FOO=StringableObj("foo"),
+ BAR=StringableObj("bar"))
+
+ r = env.subst_path([ "${FOO}/bar", "${BAR}/baz" ])
+ assert r == [ "foo/bar", "bar/baz" ]
+
+ r = env.subst_path([ "bar/${FOO}", "baz/${BAR}" ])
+ assert r == [ "bar/foo", "baz/bar" ]
+
+ r = env.subst_path([ "bar/${FOO}/bar", "baz/${BAR}/baz" ])
+ assert r == [ "bar/foo/bar", "baz/bar/baz" ]
+
def test_Builder_calls(self):
"""Test Builder calls through different environments
"""