Allow hybrid substitutions in PATH-like variables. (Charles Crain)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 2 Apr 2004 05:54:02 +0000 (05:54 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 2 Apr 2004 05:54:02 +0000 (05:54 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@940 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py

index 0e4d4d89c1bb3be3a362e6e436655240c875fc4a..b546b794b2fb1a64ec4590898a553baf97aaf081 100644 (file)
@@ -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.
index e332f66fe2dc9f51fb671070d0c06a8e5c6d7167..e75ac38762a313c58d8efc5ead9cc480a2a059d6 100644 (file)
@@ -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)
index b2b17e146343336cfeb7db6e518a2d0733994631..53a6905c219c0190a217d65943b49d7ccc998c95 100644 (file)
@@ -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
         """