X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flib%2Ftarget.cpp;h=558b3b2c107485594cb8831c40d5cdffb2c238fb;hb=f4de41c810319d3ecc8bb5084de06a953037b7b7;hp=f13afb8d07bb68c8da074a217dbd6c6bbd5ee293;hpb=2c42374a95a76dcb28eaf3e5d85d321fafe62b38;p=builder.git diff --git a/source/lib/target.cpp b/source/lib/target.cpp index f13afb8..558b3b2 100644 --- a/source/lib/target.cpp +++ b/source/lib/target.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "builder.h" #include "filetarget.h" #include "sourcepackage.h" @@ -11,6 +12,8 @@ using namespace std; using namespace Msp; +vector Target::prepare_stack; + Target::Target(Builder &b, const string &n): builder(b), name(n) @@ -111,16 +114,33 @@ void Target::mark_rebuild(const string &reason) void Target::prepare() { + if(primary_target && primary_target->stateprepare(); + if(state>PREPARING) return; if(state==PREPARING) { - builder.get_logger().log("problems", "Dependency cycle detected at %s", name); - problems.push_back("Dependency cycle detected"); + auto i = find(prepare_stack, this); + if(i!=prepare_stack.end()) + { + string cycle; + for(; i!=prepare_stack.end(); ++i) + append(cycle, " -> ", (*i)->name); + append(cycle, " -> ", name); + builder.get_logger().log("problems", "Dependency cycle detected: %s", cycle); + problems.push_back(format("Dependency cycle detected: %s", cycle)); + } + else + { + builder.get_logger().log("problems", "Dependency cycle detected at %s", name); + problems.push_back("Dependency cycle detected"); + } state = BROKEN; return; } + PushPrepare _push(this); state = PREPARING; /* Prepare existing dependencies early, because their information may be needed to find other dependencies. */