]> git.tdb.fi Git - builder.git/commitdiff
Fix some problems with side effect dependencies
authorMikko Rasa <tdb@tdb.fi>
Tue, 20 Aug 2013 15:18:47 +0000 (18:18 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 20 Aug 2013 15:18:47 +0000 (18:18 +0300)
Side effects can't depend on the primary, since a generated .c or .cpp
file might use a .h file generated as a side effect.

source/target.cpp

index dd75e9a4a98b4d18206a8e7cf7c1512746557902..72a369ad0d4a15332116ee0527e75d88030b4ebf 100644 (file)
@@ -1,3 +1,4 @@
+#include <algorithm>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
 #include <msp/strings/format.h>
@@ -35,7 +36,6 @@ void Target::add_dependency(Target &dep)
 void Target::add_side_effect(Target &se)
 {
        side_effects.push_back(&se);
-       se.add_dependency(*this);
        if(tool)
                se.set_tool(*tool);
        se.primary_target = this;
@@ -54,6 +54,10 @@ Target *Target::get_buildable_target()
        bool self_ok = state!=BUILDING;
        for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
        {
+               // Avoid infinite recursion if a target repends on its own side effect
+               if(find(side_effects.begin(), side_effects.end(), *i)!=side_effects.end())
+                       continue;
+
                Target *tgt = (*i)->get_buildable_target();
                if(tgt)
                        return tgt;