From: stevenknight Date: Fri, 2 Apr 2004 05:54:02 +0000 (+0000) Subject: Allow hybrid substitutions in PATH-like variables. (Charles Crain) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2b9fc5e27b7ec259db38ae96d693b48525f39677;p=scons.git Allow hybrid substitutions in PATH-like variables. (Charles Crain) git-svn-id: http://scons.tigris.org/svn/scons/trunk@940 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 0e4d4d89..b546b794 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 e332f66f..e75ac387 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 b2b17e14..53a6905c 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 """