From 1f839d9933b456ba4ebb5098ce1f9ab01f398a94 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Mon, 16 Dec 2002 16:05:47 +0000 Subject: Make the 'Do not know how to build' error message catch more cases. (Anthony Roach) --- src/CHANGES.txt | 7 +++-- src/engine/SCons/Script/__init__.py | 63 ++++++++++++++++++++----------------- test/SideEffect.py | 1 - test/nonexistent.py | 32 ++++++++++++++++++- test/option--U.py | 7 +++-- 5 files changed, 73 insertions(+), 37 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 38fa1a7..6edfe9d 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -22,9 +22,10 @@ RELEASE 0.10 - XXX - Convert the .sconsign file format from ASCII to a pickled Python data structure. - - Made consistent the format of error messages (now all start with - "scons: ***") and warning messages (now all start with "scons: - warning:"). + - Error message cleanups: Made consistent the format of error + messages (now all start with "scons: ***") and warning messages (now + all start with "scons: warning:"). Caught more cases with the "Do + not know how to build" error message. diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index c22cd37..ad1a641 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -73,8 +73,9 @@ from SCons.Optik import OptionParser, SUPPRESS_HELP, OptionValueError class BuildTask(SCons.Taskmaster.Task): """An SCons build task.""" def execute(self): - if self.targets[0].get_state() == SCons.Node.up_to_date: - if self.top: + t = self.targets[0] + if t.get_state() == SCons.Node.up_to_date: + if self.top and t.builder: display('scons: "%s" is up to date.' % str(self.targets[0])) else: if print_time: @@ -86,10 +87,31 @@ class BuildTask(SCons.Taskmaster.Task): command_time = command_time+finish_time-start_time print "Command execution time: %f seconds"%(finish_time-start_time) + def do_failed(self): + if ignore_errors: + SCons.Taskmaster.Task.executed(self) + elif keep_going_on_error: + SCons.Taskmaster.Task.fail_continue(self) + exit_status = 2 + else: + SCons.Taskmaster.Task.fail_stop(self) + exit_status = 2 + def executed(self): - SCons.Taskmaster.Task.executed(self) - if not self.targets[0].builder and self.top: - print "scons: Nothing to be done for `%s'." % str(self.targets[0]) + t = self.targets[0] + if self.top and not t.builder and not t.side_effect: + if not t.exists(): + sys.stderr.write("scons: *** Do not know how to make target `%s'." % t) + if not keep_going_on_error: + sys.stderr.write(" Stop.") + sys.stderr.write("\n") + self.do_failed() + else: + print "scons: Nothing to be done for `%s'." % t + SCons.Taskmaster.Task.executed(self) + else: + SCons.Taskmaster.Task.executed(self) + # print the tree here instead of in execute() because # this method is serialized, but execute isn't: if print_tree and self.top: @@ -119,15 +141,8 @@ class BuildTask(SCons.Taskmaster.Task): sys.stderr.write("scons: *** %s\n" % s) else: sys.stderr.write("scons: *** %s\n" % e) - - if ignore_errors: - SCons.Taskmaster.Task.executed(self) - elif keep_going_on_error: - SCons.Taskmaster.Task.fail_continue(self) - exit_status = 2 - else: - SCons.Taskmaster.Task.fail_stop(self) - exit_status = 2 + + self.do_failed() class CleanTask(SCons.Taskmaster.Task): """An SCons clean task.""" @@ -782,21 +797,11 @@ def _main(): if isinstance(x, SCons.Node.Node): node = x else: - try: - node = SCons.Node.Alias.default_ans.lookup(x) - if node is None: - node = SCons.Node.FS.default_fs.Entry(x, - directory = top, - create = 0) - except UserError: - string = "scons: *** Do not know how to make target `%s'." % x - if not keep_going_on_error: - sys.stderr.write(string + " Stop.\n") - sys.exit(2) - sys.stderr.write(string + "\n") - global exit_status - exit_status = 2 - node = None + node = SCons.Node.Alias.default_ans.lookup(x) + if node is None: + node = SCons.Node.FS.default_fs.Entry(x, + directory = top, + create = 1) if top and not node.is_under(top): if isinstance(node, SCons.Node.FS.Dir) and top.is_under(node): node = top diff --git a/test/SideEffect.py b/test/SideEffect.py index 3f3b75d..29acb83 100644 --- a/test/SideEffect.py +++ b/test/SideEffect.py @@ -70,7 +70,6 @@ test.write('bar.in', 'bar.in 2 \n') test.run(arguments = 'log.txt', stdout=test.wrap_stdout("""\ copy() < bar.in > bar.out copy() < blat.in > blat.out -scons: Nothing to be done for `log.txt'. """)) expect = """\ diff --git a/test/nonexistent.py b/test/nonexistent.py index 6219c1c..57bf5e1 100644 --- a/test/nonexistent.py +++ b/test/nonexistent.py @@ -38,6 +38,8 @@ test.write('SConstruct', """ env = Environment() env.Command("aaa.out", "aaa.in", "should never get executed") env.Command("bbb.out", "bbb.in", "should never get executed") +File('xxx') +Dir('ddd') """) test.run(arguments = 'foo', @@ -46,7 +48,6 @@ test.run(arguments = 'foo', test.run(arguments = '-k foo/bar foo', stderr = """scons: *** Do not know how to make target `foo/bar'. -scons: *** Do not know how to make target `foo'. """, status = 2) @@ -60,4 +61,33 @@ scons: *** No Builder for target `aaa.in', needed by `aaa.out'. """, status = 2) +test.run(arguments = '-k aaa.in bbb.in', + stderr = """scons: *** Do not know how to make target `aaa.in'. +scons: *** Do not know how to make target `bbb.in'. +""", + status = 2) + + +test.run(arguments = 'xxx', + stderr = "scons: *** Do not know how to make target `xxx'. Stop.\n", + status = 2) + +test.run(arguments = 'ddd') + + +# Make sure that SCons doesn't print up-to-date messages for non-derived files that exist: +test.write('SConstruct', """ +File('xxx') +""") + +test.write('xxx', "xxx") + +test.run(arguments='xxx', stdout=test.wrap_stdout("""\ +scons: Nothing to be done for `xxx'. +""")) + +test.run(arguments='xxx', stdout=test.wrap_stdout("""\ +scons: Nothing to be done for `xxx'. +""")) + test.pass_test() diff --git a/test/option--U.py b/test/option--U.py index 4e8b408..d700267 100644 --- a/test/option--U.py +++ b/test/option--U.py @@ -144,10 +144,11 @@ Default('.') test.run(chdir = 'sub4', arguments = '-U') test.write('SConstruct', """ -Default('no_a_target.in') +Default('not_a_target.in') """) -# The following should result in an error, but because of bug 642327, it doesn't: -test.run(arguments = '-U') +test.run(arguments = '-U', status=2, stderr="""\ +scons: *** Do not know how to make target `not_a_target.in'. Stop. +""") test.pass_test() -- cgit v0.12