X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Flib%2Ftarget.cpp;fp=source%2Flib%2Ftarget.cpp;h=558b3b2c107485594cb8831c40d5cdffb2c238fb;hb=d2c4cd0f5657f26150759fb8ab19dd448646eb06;hp=d1aaf73be578c3836b48cf251536a4a4d446612b;hpb=b0438fd2d85d6937b67db38c6138b0783962d8b2;p=builder.git diff --git a/source/lib/target.cpp b/source/lib/target.cpp index d1aaf73..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) @@ -118,12 +121,26 @@ void Target::prepare() 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. */