summaryrefslogtreecommitdiff
path: root/src/lib/buildgraph/cycledetector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/buildgraph/cycledetector.cpp')
-rw-r--r--src/lib/buildgraph/cycledetector.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/lib/buildgraph/cycledetector.cpp b/src/lib/buildgraph/cycledetector.cpp
index bb5d0bf38..57bb36bb6 100644
--- a/src/lib/buildgraph/cycledetector.cpp
+++ b/src/lib/buildgraph/cycledetector.cpp
@@ -30,6 +30,7 @@
#include "artifact.h"
#include "buildgraph.h"
+#include "projectbuilddata.h"
#include <language/language.h>
#include <logging/translator.h>
@@ -39,43 +40,48 @@ namespace qbs {
namespace Internal {
CycleDetector::CycleDetector(const Logger &logger)
- : ArtifactVisitor(0), m_parent(0), m_logger(logger)
+ : m_parent(0), m_logger(logger)
{
}
-void CycleDetector::visitProject(const ResolvedProjectConstPtr &project)
+void CycleDetector::visitProject(const TopLevelProjectConstPtr &project)
{
const QString description = QString::fromLocal8Bit("Cycle detection for project '%1'")
.arg(project->name);
TimedActivityLogger timeLogger(m_logger, description, QLatin1String("[BG] "), LoggerTrace);
- ArtifactVisitor::visitProject(project);
+
+ project->accept(this);
}
-void CycleDetector::visitArtifact(Artifact *artifact)
+void CycleDetector::visitProduct(const ResolvedProductConstPtr &product)
+{
+ product->accept(this);
+}
+
+bool CycleDetector::visit(Artifact *artifact)
{
if (Q_UNLIKELY(m_artifactsInCurrentPath.contains(artifact))) {
ErrorInfo error(Tr::tr("Cycle in build graph detected."));
- foreach (const Artifact * const a, cycle(artifact))
- error.append(a->filePath());
+ foreach (const BuildGraphNode * const node, cycle(artifact))
+ error.append(node->toString());
throw error;
}
if (m_allArtifacts.contains(artifact))
- return;
+ return true;
m_artifactsInCurrentPath += artifact;
m_parent = artifact;
- foreach (Artifact * const child, artifact->children)
- visitArtifact(child);
+ foreach (BuildGraphNode * const child, artifact->children)
+ child->accept(this);
m_artifactsInCurrentPath -= artifact;
m_allArtifacts += artifact;
+ return true;
}
-void CycleDetector::doVisit(Artifact *) { }
-
-QList<Artifact *> CycleDetector::cycle(Artifact *doubleEntry)
+QList<BuildGraphNode *> CycleDetector::cycle(BuildGraphNode *doubleEntry)
{
- QList<Artifact *> path;
+ QList<BuildGraphNode *> path;
findPath(doubleEntry, m_parent, path);
return path << doubleEntry;
}