From 1c42eb92bc1f07baecbb8752e532608426621c05 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 20 Aug 2013 18:18:47 +0300 Subject: [PATCH] Fix some problems with side effect dependencies 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/target.cpp b/source/target.cpp index dd75e9a..72a369a 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -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; -- 2.45.2