From 368ed5a1bc151c0dcf44ab5e180fd0cbabd91134 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 31 Jan 2002 04:29:50 +0000 Subject: [PATCH] Allow libraries to specified as source files on the command line. git-svn-id: http://scons.tigris.org/svn/scons/trunk@235 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- etc/TestSCons.py | 2 ++ src/CHANGES.txt | 9 +++++++++ src/engine/SCons/Builder.py | 5 ++++- src/engine/SCons/BuilderTests.py | 18 +++++++++--------- test/Library.py | 6 +++--- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/etc/TestSCons.py b/etc/TestSCons.py index 815466a6..956b4545 100644 --- a/etc/TestSCons.py +++ b/etc/TestSCons.py @@ -113,6 +113,8 @@ class TestSCons(TestCmd.TestCmd): print stderr print "Actual STDERR ============" print self.stderr() + print "STDOUT ===================" + print self.stdout() raise TestFailed def up_to_date(self, arguments = None, **kw): diff --git a/src/CHANGES.txt b/src/CHANGES.txt index c448ce07..d18c55dd 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -8,6 +8,15 @@ +RELEASE 0.05 - + + From Charles Crain: + + - Allow a library to specified as a command-line source file, not just + in the LIBS construction variable. + + + RELEASE 0.04 - Wed, 30 Jan 2002 11:09:42 -0600 From Charles Crain: diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 27e7559f..130a9e2c 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -235,6 +235,9 @@ class MultiStepBuilder(BuilderBase): BuilderBase.__init__(self, name, action, prefix, suffix, src_suffix, node_factory, scanner) self.src_builder = src_builder + self.dictSrcSuffix = {} + for suff in self.src_builder.src_suffixes(): + self.dictSrcSuffix[suff] = None def __call__(self, env, target = None, source = None): slist = SCons.Util.scons_str2nodes(source, self.node_factory) @@ -242,7 +245,7 @@ class MultiStepBuilder(BuilderBase): src_suffix = env.subst(self.src_suffix) for snode in slist: path, ext = os.path.splitext(snode.abspath) - if not src_suffix or ext != src_suffix: + if self.dictSrcSuffix.has_key(ext): tgt = self.src_builder(env, target = [ path ], source=snode) if not SCons.Util.is_List(tgt): diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index c5e87c4d..5fb273b8 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -490,16 +490,16 @@ class BuilderTestCase(unittest.TestCase): src_suffix='.bar', suffix='.foo') builder2 = SCons.Builder.MultiStepBuilder(name = "builder2", - action='foo', - src_builder = builder1) + action='bar', + src_builder = builder1, + src_suffix = '.foo') tgt = builder2(env, target='baz', source='test.bar test2.foo test3.txt') - flag = 0 - for snode in tgt.sources: - if snode.path == 'test.foo': - flag = 1 - assert snode.sources[0].path == 'test.bar' - assert flag - + 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]) + assert str(tgt.sources[1]) == 'test2.foo', str(tgt.sources[1]) + assert str(tgt.sources[2]) == 'test3.txt', str(tgt.sources[2]) + def test_CompositeBuilder(self): """Testing CompositeBuilder class.""" builder = SCons.Builder.Builder(name = "builder", diff --git a/test/Library.py b/test/Library.py index fb2c1ca4..f13dad32 100644 --- a/test/Library.py +++ b/test/Library.py @@ -29,12 +29,12 @@ import TestSCons test = TestSCons.TestSCons() test.write('SConstruct', """ -env = Environment(LIBS = [ 'foo1', 'foo2', 'foo3' ], +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 = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c']) -env.Program(target = 'prog', source = 'prog.c') +libtgt=env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c']) +env.Program(target = 'prog', source = [ 'prog.c', libtgt ]) """) test.write('f1.c', r""" -- 2.26.2