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.
This commit is contained in:
Brad King 2019-02-12 13:11:36 -05:00
parent a3cbb4d4dd
commit a32e047b4f
3 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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_;
};

View File

@ -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);