From 21a368c1a8d22330a27381978984f1c7a33f4db6 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 21 Sep 2001 21:04:14 +0000 Subject: Have SCons report when something is up-to-date. --- etc/TestSCons.py | 9 +++++++++ src/script/scons.py | 27 +++++++++++++++++++++++++-- test/Program.py | 2 ++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/etc/TestSCons.py b/etc/TestSCons.py index b6f2c68..3141989 100644 --- a/etc/TestSCons.py +++ b/etc/TestSCons.py @@ -17,6 +17,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import os.path +import string import TestCmd class TestFailed(Exception): @@ -110,3 +111,11 @@ class TestSCons(TestCmd.TestCmd): print "Actual STDERR ============" print self.stderr() raise TestFailed + + def up_to_date(self, arguments = None, **kw): + kw['arguments'] = arguments + s = "" + for arg in string.split(arguments): + s = s + 'scons: "%s" is up to date.\n' % arg + kw['stdout'] = s + apply(self.run, [], kw) diff --git a/src/script/scons.py b/src/script/scons.py index a6a7f81..3b1a533 100644 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -547,9 +547,32 @@ def main(): if not targets: targets = default_targets + # XXX Right now, this next block prints all "up to date" messages + # first, and then goes through and builds the other nodes: + # + # $ scons aaa bbb ccc ddd + # scons: "aaa" is up to date. + # scons: "ccc" is up to date. + # cc -o bbb bbb.c + # cc -o ddd ddd.c + # + # When we get the real Task and Taskmaster classes, this should + # be changed to interact with the engine to deal with targets in + # the same order as specified: + # + # $ scons aaa bbb ccc ddd + # scons: "aaa" is up to date. + # cc -o bbb bbb.c + # scons: "ccc" is up to date. + # cc -o ddd ddd.c + # calc = SCons.Sig.Calculator(SCons.Sig.MD5) - nodes = map(lambda x: SCons.Node.FS.default_fs.File(x), targets) - nodes = filter(lambda x, calc=calc: not calc.current(x), nodes) + nodes = [] + for t in map(lambda x: SCons.Node.FS.default_fs.File(x), targets): + if calc.current(t): + print 'scons: "%s" is up to date.' % t.path + else: + nodes.append(t) taskmaster = Taskmaster(nodes) diff --git a/test/Program.py b/test/Program.py index 4189c46..0d760df 100644 --- a/test/Program.py +++ b/test/Program.py @@ -95,6 +95,7 @@ test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n") #XXXtest.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c\nf3c.c\n") #XXXtest.up_to_date(arguments = '.') +test.up_to_date(arguments = 'foo1 foo2') test.write('f1.c', """ int @@ -122,6 +123,7 @@ test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n") #XXXtest.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c X\nf3c.c\n") #XXXtest.up_to_date(arguments = '.') +test.up_to_date(arguments = 'foo1 foo2') # make sure the programs don't get rebuilt, because nothing changed: oldtime1 = os.path.getmtime(test.workpath('foo1')) -- cgit v0.12