diff options
author | Brad King <brad.king@kitware.com> | 2019-02-12 18:11:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-04-18 12:21:44 (GMT) |
commit | a32e047b4f0e083eb8f9d9cdca9238bb4b006e4a (patch) | |
tree | c1c8daa5a5a5c085fefb2bc65c2376e1c652e0aa | |
parent | a3cbb4d4ddbd3661720603cc26b25cad6177b4c8 (diff) | |
download | Ninja-a32e047b4f0e083eb8f9d9cdca9238bb4b006e4a.zip Ninja-a32e047b4f0e083eb8f9d9cdca9238bb4b006e4a.tar.gz Ninja-a32e047b4f0e083eb8f9d9cdca9238bb4b006e4a.tar.bz2 |
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.cc | 8 | ||||
-rw-r--r-- | src/graphviz.h | 7 | ||||
-rw-r--r-- | src/ninja.cc | 2 |
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); |