Append suffixes to white-space separated source files that don't have suffixes.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 2 Jan 2002 00:01:06 +0000 (00:01 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 2 Jan 2002 00:01:06 +0000 (00:01 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@185 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Builder.py
src/engine/SCons/BuilderTests.py

index a524e5ffb3fd06961e2c989ef61f2b74965999b7..dfcf3958385c23a856a416196c4f5a485b75be42 100644 (file)
@@ -15,6 +15,10 @@ RELEASE 0.03 -
   - Search both /usr/lib and /usr/local/lib for scons directories by
     adding them both to sys.path, with whichever is in sys.prefix first.
 
+  - Fix interpreting strings of multiple white-space separated file names
+    as separate file names, allowing prefixes and suffixes to be appended
+    to each individually.
+
   From Anthony Roach:
 
   - Add a "duplicate" keyword argument to BuildDir() that can be set
index 2f937232a03dbbb96cd97120cf8fe81adc55d614..eceb66a1da00ec3a48a1da0dd033f447051bbe31 100644 (file)
@@ -172,6 +172,8 @@ class BuilderBase:
     def __call__(self, env, target = None, source = None):
        def adjustixes(files, pre, suf):
            ret = []
+            if type(files) is types.StringType or isinstance(files, UserString):
+                files = string.split(files)
            if not type(files) is type([]):
                files = [files]
            for f in files:
index ad13dd76fef862a124d5c66eebcce8df8efec1c5..9f2183fd64780bda3b457bb93b26cc55562b1869 100644 (file)
@@ -91,7 +91,8 @@ class BuilderTestCase(unittest.TestCase):
                self.env = env
            def add_source(self, source):
                self.sources.extend(source)
-       builder = SCons.Builder.Builder(action = "foo")
+        builder = SCons.Builder.Builder(action = "foo", node_factory = Node)
+
        n1 = Node("n1");
        n2 = Node("n2");
        builder(env, target = n1, source = n2)
@@ -100,6 +101,21 @@ class BuilderTestCase(unittest.TestCase):
        assert n1.sources == [n2]
         assert n2.env == env
 
+        target = builder(env, target = 'n3', source = 'n4')
+        assert target.name == 'n3'
+        assert target.sources[0].name == 'n4'
+
+        targets = builder(env, target = 'n4 n5', source = ['n6 n7'])
+        assert targets[0].name == 'n4'
+        assert targets[0].sources[0].name == 'n6 n7'
+        assert targets[1].name == 'n5'
+        assert targets[1].sources[0].name == 'n6 n7'
+
+        target = builder(env, target = ['n8 n9'], source = 'n10 n11')
+        assert target.name == 'n8 n9'
+        assert target.sources[0].name == 'n10'
+        assert target.sources[1].name == 'n11'
+
     def test_action(self):
        """Test Builder creation
 
@@ -360,6 +376,11 @@ class BuilderTestCase(unittest.TestCase):
        tgt = builder(env, target = 'tgt1', source = 'src1')
        assert tgt.path == 'libtgt1', \
                "Target has unexpected name: %s" % tgt.path
+        tgts = builder(env, target = 'tgt2a tgt2b', source = 'src2')
+        assert tgts[0].path == 'libtgt2a', \
+                "Target has unexpected name: %s" % tgts[0].path
+        assert tgts[1].path == 'libtgt2b', \
+                "Target has unexpected name: %s" % tgts[1].path
 
     def test_src_suffix(self):
        """Test Builder creation with a specified source file suffix
@@ -374,6 +395,11 @@ class BuilderTestCase(unittest.TestCase):
        tgt = builder(env, target = 'tgt2', source = 'src2')
        assert tgt.sources[0].path == 'src2.c', \
                "Source has unexpected name: %s" % tgt.sources[0].path
+        tgt = builder(env, target = 'tgt3', source = 'src3a src3b')
+        assert tgt.sources[0].path == 'src3a.c', \
+                "Sources[0] has unexpected name: %s" % tgt.sources[0].path
+        assert tgt.sources[1].path == 'src3b.c', \
+                "Sources[1] has unexpected name: %s" % tgt.sources[1].path
 
     def test_suffix(self):
        """Test Builder creation with a specified target suffix
@@ -388,6 +414,12 @@ class BuilderTestCase(unittest.TestCase):
        tgt = builder(env, target = 'tgt3', source = 'src3')
        assert tgt.path == 'tgt3.o', \
                "Target has unexpected name: %s" % tgt[0].path
+        tgts = builder(env, target = 'tgt4a tgt4b', source = 'src4')
+        assert tgts[0].path == 'tgt4a.o', \
+                "Target has unexpected name: %s" % tgts[0].path
+        tgts = builder(env, target = 'tgt4a tgt4b', source = 'src4')
+        assert tgts[1].path == 'tgt4b.o', \
+                "Target has unexpected name: %s" % tgts[1].path
 
     def test_MultiStepBuilder(self):
         """Testing MultiStepBuilder class."""