From: stevenknight Date: Thu, 21 Feb 2002 13:08:18 +0000 (+0000) Subject: Remove all built targets even if some don't exist. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bd10bd4f55c383fd6b1adc66a4629a4531fa8071;p=scons.git Remove all built targets even if some don't exist. git-svn-id: http://scons.tigris.org/svn/scons/trunk@272 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 3b0f2b7d..c30e8712 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -68,6 +68,9 @@ RELEASE 0.05 - - Efficiency: don't scan dependencies more than once during the walk of a tree. + - Fix the -c option so it doesn't stop removing targets if one doesn't + already exist. + From Steve Leblanc: - Add support for the -u option. diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 6e923bc6..aa4ecb4e 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -105,11 +105,18 @@ class CleanTask(SCons.Taskmaster.Task): """An SCons clean task.""" def execute(self): if self.targets[0].builder: - os.unlink(self.targets[0].path) - print "Removed " + self.targets[0].path + try: + os.unlink(self.targets[0].path) + except OSError: + pass + else: + print "Removed " + self.targets[0].path try: for t in self.targets[1:]: - os.unlink(t.path) + try: + os.unlink(t.path) + except OSError: + pass except IndexError: pass diff --git a/test/option-c.py b/test/option-c.py index de78cf34..c93a4d39 100644 --- a/test/option-c.py +++ b/test/option-c.py @@ -44,7 +44,8 @@ test.write('SConstruct', """ B = Builder(name = 'B', action = r'%s build.py $TARGETS $SOURCES') env = Environment(BUILDERS = [B]) env.B(target = 'foo1.out', source = 'foo1.in') -env.B(target = 'foo2.out', source = 'foo2.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') """ % python) @@ -57,30 +58,42 @@ test.write('foo3.in', "foo3.in\n") test.run(arguments = 'foo1.out foo2.out foo3.out') test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") +test.fail_test(test.read(test.workpath('foo2.xxx')) != "foo2.in\n") test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") test.run(arguments = '-c foo1.out', stdout = "Removed foo1.out\n") test.fail_test(os.path.exists(test.workpath('foo1.out'))) +test.fail_test(not os.path.exists(test.workpath('foo2.xxx'))) test.fail_test(not os.path.exists(test.workpath('foo2.out'))) test.fail_test(not os.path.exists(test.workpath('foo3.out'))) -test.run(arguments = '--clean foo2.out', stdout = "Removed foo2.out\n") +test.run(arguments = '--clean foo2.out foo2.xxx', stdout = "Removed foo2.xxx\nRemoved foo2.out\n") test.fail_test(os.path.exists(test.workpath('foo1.out'))) +test.fail_test(os.path.exists(test.workpath('foo2.xxx'))) test.fail_test(os.path.exists(test.workpath('foo2.out'))) test.fail_test(not os.path.exists(test.workpath('foo3.out'))) test.run(arguments = '--remove foo3.out', stdout = "Removed foo3.out\n") test.fail_test(os.path.exists(test.workpath('foo1.out'))) +test.fail_test(os.path.exists(test.workpath('foo2.xxx'))) test.fail_test(os.path.exists(test.workpath('foo2.out'))) test.fail_test(os.path.exists(test.workpath('foo3.out'))) test.run(arguments = '.') test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") +test.fail_test(test.read(test.workpath('foo2.xxx')) != "foo2.in\n") +test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n") +test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n") + +test.run(arguments = '-c foo2.xxx', stdout = "Removed foo2.xxx\n") + +test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n") +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")