Propagate rebuild from side effects to the primary target. This can
happen if the side effect does not exist for whatever reason. As an
additional safeguard, redirect any build attempts on side effects to
the primary target.
void FileTarget::check_rebuild()
{
- if(!tool)
+ if(!tool || needs_rebuild())
return;
if(!mtime)
if(!needs_rebuild())
{
+ // Some side effects might not exist
for(Dependencies::iterator i=side_effects.begin(); (i!=side_effects.end() && !needs_rebuild()); ++i)
- {
- FileTarget *ft = dynamic_cast<FileTarget *>(*i);
- if(ft && !ft->get_mtime())
- mark_rebuild((*i)->get_name()+" does not exist");
- }
+ if((*i)->needs_rebuild())
+ mark_rebuild((*i)->get_name()+" needs rebuilding");
}
if(!needs_rebuild() && package)
if(tool)
se.set_tool(*tool);
se.primary_target = this;
+ /* Side effects are checked for rebuild after the primary target. Recheck
+ the primary if a side effect is marked for rebuild. */
+ se.signal_bubble_rebuild.connect(sigc::mem_fun(this, &Target::check_rebuild));
}
Target *Target::get_buildable_target()
Task *Target::build()
{
+ if(primary_target)
+ return primary_target->build();
+
Task *task = tool->run(*this);
task->signal_finished.connect(sigc::mem_fun(this, &Target::build_finished));
state = BUILDING;