From 20ef62c2f1a61156eaae46947515d8f2716c30de Mon Sep 17 00:00:00 2001 From: stevenknight Date: Wed, 28 Aug 2002 14:28:02 +0000 Subject: [PATCH] Make sure auto-deducing target names works when a Node is passed in as a source file. git-svn-id: http://scons.tigris.org/svn/scons/trunk@449 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Builder.py | 3 ++- src/engine/SCons/BuilderTests.py | 13 +++++++++++++ test/no-target.py | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 9edd1218..fe6283b7 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -286,7 +286,8 @@ class BuilderBase: source = adjustixes(source, None, src_suf) if target is None: - target = map(lambda x, s=suf: os.path.splitext(x)[0] + s, + target = map(lambda x, s=suf: + os.path.splitext(os.path.split(str(x))[1])[0] + s, source) else: target = adjustixes(target, pre, suf) diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 8451d995..e862b056 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -833,6 +833,19 @@ class BuilderTestCase(unittest.TestCase): assert str(tgt[1].sources[0]) == 'h0.c', map(str, tgt[1].sources) assert str(tgt[1].sources[1]) == 'h1.c', map(str, tgt[1].sources) + w = b(env, target='i0.w', source=['i0.x']) + y = b(env, target='i1.y', source=['i1.z']) + tgt = b(env, source=[w, y]) + assert len(tgt) == 2, map(str, tgt) + assert str(tgt[0]) == 'i0.o' + assert str(tgt[1]) == 'i1.o' + assert len(tgt[0].sources) == 2, map(str, tgt[0].sources) + assert str(tgt[0].sources[0]) == 'i0.w', map(str, tgt[0].sources) + assert str(tgt[0].sources[1]) == 'i1.y', map(str, tgt[0].sources) + assert len(tgt[1].sources) == 2, map(str, tgt[1].sources) + assert str(tgt[1].sources[0]) == 'i0.w', map(str, tgt[1].sources) + assert str(tgt[1].sources[1]) == 'i1.y', map(str, tgt[1].sources) + if __name__ == "__main__": suite = unittest.makeSuite(BuilderTestCase, 'test_') diff --git a/test/no-target.py b/test/no-target.py index 7aa56c4e..dd24a8d7 100644 --- a/test/no-target.py +++ b/test/no-target.py @@ -51,14 +51,18 @@ def cat(env, source, target): b = Builder(action=cat, suffix='.out', src_suffix='.in') env = Environment(BUILDERS={'Build':b}) env.Build('aaa.in') +n = env.Build('bbb.in', 'bbb.input') +env.Build(n) """) test.write(['subdir', 'aaa.in'], "subdir/aaa.in\n") +test.write(['subdir', 'bbb.input'], "subdir/bbb.input\n") # test.run(arguments = '.') test.fail_test(test.read(['subdir', 'aaa.out']) != "subdir/aaa.in\n") +test.fail_test(test.read(['subdir', 'bbb.out']) != "subdir/bbb.input\n") # test.pass_test() -- 2.26.2