From 45d228453c38ffd2d766e7ca501cfc41825e6825 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 16 Jan 2003 10:13:42 +0000 Subject: [PATCH] Fix bug in Clean() functionality. (Steve Leblanc) git-svn-id: http://scons.tigris.org/svn/scons/trunk@551 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Script/SConscript.py | 13 +++++++++---- test/option-c.py | 12 ++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index fcb08cf6..29338a67 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -317,19 +317,24 @@ def SetJobs(num): raise SCons.Errors.UserError, "A positive integer is required: %s"%repr(num) def Clean(target, files): - target = str(target) + if not isinstance(target, SCons.Node.Node): + target = SCons.Node.FS.default_fs.Entry(target, create=1) + if not SCons.Util.is_List(files): files = [files] + nodes = [] for f in files: if isinstance(f, SCons.Node.Node): nodes.append(f) else: nodes.extend(SCons.Node.arg2nodes(f, SCons.Node.FS.default_fs.Entry)) - if clean_targets.has_key(target): - clean_targets[target].extend(nodes) + + s = str(target) + if clean_targets.has_key(s): + clean_targets[s].extend(nodes) else: - clean_targets[target] = nodes + clean_targets[s] = nodes def BuildDefaultGlobals(): """ diff --git a/test/option-c.py b/test/option-c.py index f406574a..15a33f3d 100644 --- a/test/option-c.py +++ b/test/option-c.py @@ -152,6 +152,7 @@ test.writable('.', 1) test.subdir('subd') test.write(['subd', 'foon.in'], "foon.in\n") +test.write(['subd', 'foox.in'], "foox.in\n") test.write('aux1.x', "aux1.x\n") test.write('aux2.x', "aux2.x\n") test.write('SConstruct', """ @@ -161,11 +162,16 @@ env.B(target = 'foo1.out', source = 'foo1.in') env.B(target = 'foo2.out', source = 'foo2.xxx') env.B(target = 'foo2.xxx', source = 'foo2.in') env.B(target = 'foo3.out', source = 'foo3.in') +SConscript('subd/SConscript') Clean('foo2.xxx', ['aux1.x']) Clean('foo2.xxx', ['aux2.x']) Clean('.', ['subd']) """ % python) +test.write(['subd', 'SConscript'], """ +Clean('.', 'foox.in') +""") + expect = test.wrap_stdout("""Removed foo2.xxx Removed aux1.x Removed aux2.x @@ -176,10 +182,16 @@ test.fail_test(os.path.exists(test.workpath('foo2.xxx'))) test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") +expect = test.wrap_stdout("""Removed subd/foox.in +""") +test.run(arguments = '-c subd', stdout=expect) +test.fail_test(os.path.exists(test.workpath('foox.in'))) + expect = test.wrap_stdout("""Removed foo1.out Removed foo2.out Removed foo3.out Removed %s +Removed subd/SConscript Removed directory subd """ % os.path.join('subd','foon.in')) test.run(arguments = '-c .', stdout=expect) -- 2.26.2