From d1b81f58263a824ca39ecc179f61ad541c5a0f7a Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Tue, 11 Jun 2002 22:19:47 +0000 Subject: Remove white-space split of file name lists. --- src/CHANGES.txt | 3 +++ src/engine/SCons/Builder.py | 8 +++--- src/engine/SCons/BuilderTests.py | 50 +++++++++++++---------------------- src/engine/SCons/EnvironmentTests.py | 4 ++- src/engine/SCons/Node/NodeTests.py | 12 +++------ src/engine/SCons/Node/__init__.py | 30 +++++++++------------ src/engine/SCons/Scanner/ProgTests.py | 13 ++++----- test/CPPFLAGS.py | 2 +- test/CPPPATH.py | 2 +- test/Default.py | 2 +- test/LIBPATH.py | 2 +- test/LIBS.py | 2 +- test/Library.py | 2 +- test/Object.py | 2 +- test/Program.py | 2 +- test/SharedLibrary.py | 2 +- test/option--debug.py | 2 +- test/option--implicit-cache.py | 2 +- 18 files changed, 63 insertions(+), 79 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index d590318..9d76afe 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -38,6 +38,9 @@ RELEASE 0.08 - - Add descriptions to the -H help text for -D, -u and -U so people can tell them apart. + - Remove the old feature of automatically splitting strings + of file names on white space. + From Jeff Petkau: - Fix --implicit-cache if the scanner returns an empty list. diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index d3feb26..aa71214 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -256,11 +256,11 @@ class BuilderBase: """Create and return lists of target and source nodes. """ def adjustixes(files, pre, suf): + if not files: + return [] ret = [] - # FOR RELEASE 0.08: - #if not SCons.Util.is_List(files): - # files = [files] - files = SCons.Util.argmunge(files) + if not SCons.Util.is_List(files): + files = [files] for f in files: if SCons.Util.is_String(f): diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index c69aaa6..4651688 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -129,34 +129,28 @@ class BuilderTestCase(unittest.TestCase): 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 = 'n4 n5', source = ['n6 n7']) + assert target.name == 'n4 n5' + assert target.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' + assert target.sources[0].name == 'n10 n11' if not hasattr(types, 'UnicodeType'): uni = str else: uni = unicode - targets = builder(env, target = uni('n12 n13'), + target = builder(env, target = uni('n12 n13'), source = [uni('n14 n15')]) - assert targets[0].name == uni('n12') - assert targets[0].sources[0].name == uni('n14 n15') - assert targets[1].name == uni('n13') - assert targets[1].sources[0].name == uni('n14 n15') + assert target.name == uni('n12 n13') + assert target.sources[0].name == uni('n14 n15') target = builder(env, target = [uni('n16 n17')], source = uni('n18 n19')) assert target.name == uni('n16 n17') - assert target.sources[0].name == uni('n18') - assert target.sources[1].name == uni('n19') + assert target.sources[0].name == uni('n18 n19') def test_noname(self): """Test deprecated warning for Builder name. @@ -458,11 +452,9 @@ 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 + tgt = builder(env, target = 'tgt2a tgt2b', source = 'src2') + assert tgt.path == 'libtgt2a tgt2b', \ + "Target has unexpected name: %s" % tgt.path def test_src_suffix(self): """Test Builder creation with a specified source file suffix @@ -480,10 +472,9 @@ class BuilderTestCase(unittest.TestCase): "Source has unexpected name: %s" % tgt.sources[0].path tgt = b1(env, target = 'tgt3', source = 'src3a src3b') - assert tgt.sources[0].path == 'src3a.c', \ + assert len(tgt.sources) == 1 + assert tgt.sources[0].path == 'src3a src3b.c', \ "Unexpected tgt.sources[0] name: %s" % tgt.sources[0].path - assert tgt.sources[1].path == 'src3b.c', \ - "Unexpected tgt.sources[1] name: %s" % tgt.sources[1].path b2 = SCons.Builder.Builder(name = "b2", src_suffix = '.2', @@ -514,13 +505,10 @@ class BuilderTestCase(unittest.TestCase): assert builder.get_suffix(env,{}) == '.o', builder.get_suffix(env,{}) 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 + "Target has unexpected name: %s" % tgt.path + tgt = builder(env, target = 'tgt4a tgt4b', source = 'src4') + assert tgt.path == 'tgt4a tgt4b.o', \ + "Target has unexpected name: %s" % tgt.path def test_ListBuilder(self): """Testing ListBuilder class.""" @@ -588,7 +576,7 @@ class BuilderTestCase(unittest.TestCase): action='bar', src_builder = builder1, src_suffix = '.foo') - tgt = builder2(env, target='baz', source='test.bar test2.foo test3.txt') + tgt = builder2(env, target='baz', source=['test.bar', 'test2.foo', 'test3.txt']) assert str(tgt.sources[0]) == 'test.foo', str(tgt.sources[0]) assert str(tgt.sources[0].sources[0]) == 'test.bar', \ str(tgt.sources[0].sources[0]) @@ -610,7 +598,7 @@ class BuilderTestCase(unittest.TestCase): assert isinstance(tgt.builder, SCons.Builder.BuilderBase) assert isinstance(tgt.builder.action.generator, SCons.Builder.DictCmdGenerator) flag = 0 - tgt = builder(env, target='test2', source='test2.bar test1.foo') + tgt = builder(env, target='test2', source=['test2.bar', 'test1.foo']) try: tgt.build() except SCons.Errors.BuildError, e: diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 6859ee3..25712b2 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -23,6 +23,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import string import sys import unittest @@ -273,7 +274,8 @@ class EnvironmentTestCase(unittest.TestCase): for tnode in tgt: assert tnode.builder == InstallBuilder - tgt = env.InstallAs(target='foo1 foo2', source='bar1 bar2') + tgt = env.InstallAs(target=string.split('foo1 foo2'), + source=string.split('bar1 bar2')) assert len(tgt) == 2, len(tgt) paths = map(lambda x: str(x.sources[0]), tgt) paths.sort() diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 6f1d53d..03b06bd 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -567,20 +567,16 @@ class NodeTestCase(unittest.TestCase): return dict[name] nodes = SCons.Node.arg2nodes("Util.py UtilTests.py", Factory) - assert len(nodes) == 2, nodes + assert len(nodes) == 1, nodes assert isinstance(nodes[0], X) - assert isinstance(nodes[1], X) - assert nodes[0].name == "Util.py" - assert nodes[1].name == "UtilTests.py" + assert nodes[0].name == "Util.py UtilTests.py" if hasattr(types, 'UnicodeType'): code = """if 1: nodes = SCons.Node.arg2nodes(u"Util.py UtilTests.py", Factory) - assert len(nodes) == 2, nodes + assert len(nodes) == 1, nodes assert isinstance(nodes[0], X) - assert isinstance(nodes[1], X) - assert nodes[0].name == u"Util.py" - assert nodes[1].name == u"UtilTests.py" + assert nodes[0].name == u"Util.py UtilTests.py" \n""" exec code in globals(), locals() diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index cf9474d..483de10 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -409,28 +409,22 @@ class Walker: arg2nodes_lookups = [] - -def arg2nodes(arg, node_factory=None): - # FOR RELEASE 0.08: - #"""This function converts a string or list into a list of Node - #instances.""" - """This function converts a string or list into a list of Node instances. - It follows the rules outlined in the SCons design document by accepting - any of the following inputs: - - A single string containing names separated by spaces. These will be - split apart at the spaces. +def arg2nodes(args, node_factory=None): + """This function converts a string or list into a list of Node + instances. It accepts the following inputs: + - A single string, - A single Node instance, - - A list containingg either strings or Node instances. Any strings - in the list are not split at spaces. - In all cases, the function returns a list of Node instances.""" + - A list containing either strings or Node instances. + In all cases, strings are converted to Node instances, and the + function returns a list of Node instances.""" - # FOR RELEASE 0.08: - #if not SCons.Util.is_List(arg): - # arg = [arg] - narg = SCons.Util.argmunge(arg) + if not args: + return [] + if not SCons.Util.is_List(args): + args = [args] nodes = [] - for v in narg: + for v in args: if SCons.Util.is_String(v): n = None for l in arg2nodes_lookups: diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index 75ce697..4e60ccf 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path +import string import sys import types import unittest @@ -99,9 +100,9 @@ class ProgScanTestCase2(unittest.TestCase): class ProgScanTestCase3(unittest.TestCase): def runTest(self): - env = DummyEnvironment(LIBPATH=test.workpath("d1/d2") + ' ' +\ - test.workpath("d1"), - LIBS='l2 l3') + env = DummyEnvironment(LIBPATH=[test.workpath("d1/d2"), + test.workpath("d1")], + LIBS=string.split('l2 l3')) s = SCons.Scanner.Prog.ProgScan() deps = s.scan('dummy', env, DummyTarget()) assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps) @@ -115,9 +116,9 @@ def suite(): code = """if 1: class ProgScanTestCase4(unittest.TestCase): def runTest(self): - env = DummyEnvironment(LIBPATH=test.workpath("d1/d2") + ' ' +\ - test.workpath("d1"), - LIBS=u'l2 l3') + env = DummyEnvironment(LIBPATH=[test.workpath("d1/d2"), + test.workpath("d1")], + LIBS=string.split(u'l2 l3')) s = SCons.Scanner.Prog.ProgScan() deps = s.scan('dummy', env, DummyTarget()) assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps) diff --git a/test/CPPFLAGS.py b/test/CPPFLAGS.py index 977d9ff..9c0295c 100644 --- a/test/CPPFLAGS.py +++ b/test/CPPFLAGS.py @@ -110,7 +110,7 @@ env = Environment(CPPFLAGS = '-x', CC = r'%s mygcc.py cc', CXX = r'%s mygcc.py c++', F77 = r'%s mygcc.py g77') -env.Program(target = 'foo', source = 'test1.c test2.cpp test3.F') +env.Program(target = 'foo', source = Split('test1.c test2.cpp test3.F')) """ % (python, python, python, python)) test.write('test1.c', r"""test1.c diff --git a/test/CPPPATH.py b/test/CPPPATH.py index d09ecb8..a2cae10 100644 --- a/test/CPPPATH.py +++ b/test/CPPPATH.py @@ -163,7 +163,7 @@ test.up_to_date(arguments = args) # Change CPPPATH and make sure we don't rebuild because of it. test.write('SConstruct', """ -env = Environment(CPPPATH = 'inc2 include') +env = Environment(CPPPATH = Split('inc2 include')) obj = env.Object(target='foobar/prog', source='subdir/prog.c') env.Program(target='prog', source=obj) SConscript('subdir/SConscript', "env") diff --git a/test/Default.py b/test/Default.py index 96d786a..5f8aff8 100644 --- a/test/Default.py +++ b/test/Default.py @@ -63,7 +63,7 @@ B = Builder(action = r'%s ../build.py $TARGET $SOURCES') env = Environment(BUILDERS = { 'B' : B }) env.B(target = 'foo.out', source = 'foo.in') env.B(target = 'bar.out', source = 'bar.in') -Default('foo.out bar.out') +Default(Split('foo.out bar.out')) """ % python) test.write(['four', 'SConstruct'], """ diff --git a/test/LIBPATH.py b/test/LIBPATH.py index 871437c..d0bb065 100644 --- a/test/LIBPATH.py +++ b/test/LIBPATH.py @@ -118,7 +118,7 @@ env1.Program(target = 'prog', source = prog) env1.Library(target = './lib1/foo1', source = f1) env2 = Environment(LIBS = 'foo2', - LIBPATH = '. ./lib2') + LIBPATH = Split('. ./lib2')) env2.Program(target = 'prog2', source = prog) env2.Library(target = 'foo2', source = f1) """) diff --git a/test/LIBS.py b/test/LIBS.py index 6fb678a..0933d6f 100644 --- a/test/LIBS.py +++ b/test/LIBS.py @@ -47,7 +47,7 @@ SConscript('sub2/SConscript', 'env') test.write(['sub1', 'SConscript'], r""" Import('env') -lib = env.Library(target='bar', source='bar.c baz.c') +lib = env.Library(target='bar', source=Split('bar.c baz.c')) env.Install('..', lib) """) diff --git a/test/Library.py b/test/Library.py index f13dad3..adbb334 100644 --- a/test/Library.py +++ b/test/Library.py @@ -32,7 +32,7 @@ test.write('SConstruct', """ env = Environment(LIBS = [ 'foo1', 'foo2' ], LIBPATH = [ '.' ]) env.Library(target = 'foo1', source = 'f1.c') -env.Library(target = 'foo2', source = 'f2a.c f2b.c f2c.c') +env.Library(target = 'foo2', source = Split('f2a.c f2b.c f2c.c')) libtgt=env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c']) env.Program(target = 'prog', source = [ 'prog.c', libtgt ]) """) diff --git a/test/Object.py b/test/Object.py index c936be6..b5ebcf7 100644 --- a/test/Object.py +++ b/test/Object.py @@ -39,7 +39,7 @@ env = Environment() f1 = env.Object(target = 'f1', source = 'f1.c') f2 = env.Object(target = 'f2', source = 'f2.cpp') f3 = env.Object(target = 'f3', source = 'f3.c') -env.Program(target = 'prog1', source = 'f1%s f2%s f3%s prog.cpp') +env.Program(target = 'prog1', source = Split('f1%s f2%s f3%s prog.cpp')) env.Program(target = 'prog2', source = [f1, f2, f3, 'prog.cpp']) env.Program(target = 'prog3', source = ['f1%s', f2, 'f3%s', 'prog.cpp']) """ % (_obj, _obj, _obj, _obj, _obj)) diff --git a/test/Program.py b/test/Program.py index 197f21c..5e1f259 100644 --- a/test/Program.py +++ b/test/Program.py @@ -44,7 +44,7 @@ foo_args = 'foo1%s foo2%s foo3%s' % (_exe, _exe, _exe) test.write('SConstruct', """ env = Environment() env.Program(target = 'foo1', source = 'f1.c') -env.Program(target = 'foo2', source = 'f2a.c f2b.c f2c.c') +env.Program(target = 'foo2', source = Split('f2a.c f2b.c f2c.c')) env.Program(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c']) """) diff --git a/test/SharedLibrary.py b/test/SharedLibrary.py index 6e96fd3..dfe05af 100644 --- a/test/SharedLibrary.py +++ b/test/SharedLibrary.py @@ -35,7 +35,7 @@ env=Environment(WIN32_INSERT_DEF=1) env2 = Environment(LIBS = [ 'foo1', 'foo2', 'foo3' ], LIBPATH = [ '.' ]) env.Library(target = 'foo1', source = 'f1.c', shared=1) -env.Library(target = 'foo2', source = 'f2a.c f2b.c f2c.c', shared=1) +env.Library(target = 'foo2', source = Split('f2a.c f2b.c f2c.c'), shared=1) env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'], shared=1) env2.Program(target = 'prog', source = 'prog.c') """) diff --git a/test/option--debug.py b/test/option--debug.py index 95a3a9c..6561a05 100644 --- a/test/option--debug.py +++ b/test/option--debug.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(OBJSUFFIX = '.ooo', PROGSUFFIX = '.xxx') -env.Program('foo', 'foo.c bar.c') +env.Program('foo', Split('foo.c bar.c')) """) test.write('foo.c', r""" diff --git a/test/option--implicit-cache.py b/test/option--implicit-cache.py index 6ebff3a..3460b2f 100644 --- a/test/option--implicit-cache.py +++ b/test/option--implicit-cache.py @@ -46,7 +46,7 @@ test = TestSCons.TestSCons() test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2') test.write('SConstruct', """ -env = Environment(CPPPATH = 'inc2 include') +env = Environment(CPPPATH = Split('inc2 include')) obj = env.Object(target='prog', source='subdir/prog.c') env.Program(target='prog', source=obj) SConscript('subdir/SConscript', "env") -- cgit v0.12