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:
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:
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."""
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
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',
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)
""",
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()
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()