]> git.tdb.fi Git - builder.git/commitdiff
Improvements for handling side effects
authorMikko Rasa <tdb@tdb.fi>
Thu, 9 May 2013 07:12:52 +0000 (10:12 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 9 May 2013 07:12:52 +0000 (10:12 +0300)
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.

source/filetarget.cpp
source/target.cpp

index b42580a099a0a95eb411bc34fa65345cd72a2b03..6ce5cfdb3bcee336d5b601608c23c8b50b8e2edf 100644 (file)
@@ -70,7 +70,7 @@ void FileTarget::touch()
 
 void FileTarget::check_rebuild()
 {
-       if(!tool)
+       if(!tool || needs_rebuild())
                return;
 
        if(!mtime)
@@ -89,12 +89,10 @@ void FileTarget::check_rebuild()
 
        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)
index 7f031ec2dd384a1b86e0e4f61f7797d4f0803798..f5b93a0b3ad74b51aeab675e763f82b14bd85f9f 100644 (file)
@@ -39,6 +39,9 @@ void Target::add_side_effect(Target &se)
        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()
@@ -139,6 +142,9 @@ void Target::prepare()
 
 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;