From: stevenknight Date: Wed, 2 Jan 2002 00:01:06 +0000 (+0000) Subject: Append suffixes to white-space separated source files that don't have suffixes. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dd0a17f80e1f1752f0383ea0048b7611f87001c1;p=scons.git Append suffixes to white-space separated source files that don't have suffixes. git-svn-id: http://scons.tigris.org/svn/scons/trunk@185 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a524e5ff..dfcf3958 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 2f937232..eceb66a1 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -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: diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index ad13dd76..9f2183fd 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -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."""