summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-02-12 13:11:36 -0500
committerBrad King <brad.king@kitware.com>2019-04-18 08:21:44 -0400
commita32e047b4f0e083eb8f9d9cdca9238bb4b006e4a (patch)
treec1c8daa5a5a5c085fefb2bc65c2376e1c652e0aa
parenta3cbb4d4ddbd3661720603cc26b25cad6177b4c8 (diff)
downloadninja-a32e047b4f0e083eb8f9d9cdca9238bb4b006e4a.tar.gz
graph: load dyndep files
Teach the `-t graph` tool to load dyndep files because they are part of the build graph. Issue a warning when the dyndep file cannot be loaded cleanly. This will help users visualize the complete build graph.
-rw-r--r--src/graphviz.cc8
-rw-r--r--src/graphviz.h7
-rw-r--r--src/ninja.cc2
3 files changed, 16 insertions, 1 deletions
diff --git a/src/graphviz.cc b/src/graphviz.cc
index dce8b32..0d07251 100644
--- a/src/graphviz.cc
+++ b/src/graphviz.cc
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <algorithm>
+#include "dyndep.h"
#include "graph.h"
void GraphViz::AddTarget(Node* node) {
@@ -40,6 +41,13 @@ void GraphViz::AddTarget(Node* node) {
return;
visited_edges_.insert(edge);
+ if (edge->dyndep_ && edge->dyndep_->dyndep_pending()) {
+ std::string err;
+ if (!dyndep_loader_.LoadDyndeps(edge->dyndep_, &err)) {
+ Warning("%s\n", err.c_str());
+ }
+ }
+
if (edge->inputs_.size() == 1 && edge->outputs_.size() == 1) {
// Can draw simply.
// Note extra space before label text -- this is cosmetic and feels
diff --git a/src/graphviz.h b/src/graphviz.h
index 408496d..601c9b2 100644
--- a/src/graphviz.h
+++ b/src/graphviz.h
@@ -17,15 +17,22 @@
#include <set>
+#include "dyndep.h"
+
+struct DiskInterface;
struct Node;
struct Edge;
+struct State;
/// Runs the process of creating GraphViz .dot file output.
struct GraphViz {
+ GraphViz(State* state, DiskInterface* disk_interface)
+ : dyndep_loader_(state, disk_interface) {}
void Start();
void AddTarget(Node* node);
void Finish();
+ DyndepLoader dyndep_loader_;
std::set<Node*> visited_nodes_;
std::set<Edge*> visited_edges_;
};
diff --git a/src/ninja.cc b/src/ninja.cc
index 8580e4f..4a176c1 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -338,7 +338,7 @@ int NinjaMain::ToolGraph(const Options* options, int argc, char* argv[]) {
return 1;
}
- GraphViz graph;
+ GraphViz graph(&state_, &disk_interface_);
graph.Start();
for (vector<Node*>::const_iterator n = nodes.begin(); n != nodes.end(); ++n)
graph.AddTarget(*n);