diff options
author | Thiago Farina <tfarina@chromium.org> | 2011-03-07 22:34:25 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-03-07 22:34:48 (GMT) |
commit | 835983365c3730dbd93baa1b17f42f3cd6579999 (patch) | |
tree | fdab1fd6349251ef4b2418dc2124374acf534935 /src/graphviz.h | |
parent | 58a2b6d560f1749f3c275c7a289ddb2168a045f7 (diff) | |
download | Ninja-835983365c3730dbd93baa1b17f42f3cd6579999.zip Ninja-835983365c3730dbd93baa1b17f42f3cd6579999.tar.gz Ninja-835983365c3730dbd93baa1b17f42f3cd6579999.tar.bz2 |
move the implementation of GraphViz to source file
Diffstat (limited to 'src/graphviz.h')
-rw-r--r-- | src/graphviz.h | 59 |
1 files changed, 5 insertions, 54 deletions
diff --git a/src/graphviz.h b/src/graphviz.h index fd6b58e..f9b19b6 100644 --- a/src/graphviz.h +++ b/src/graphviz.h @@ -12,10 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef NINJA_GRAPHVIZ_H_ +#define NINJA_GRAPHVIZ_H_ + #include <set> +using namespace std; -// XXX deinline all this code so we don't need this include -#include "graph.h" struct Node; struct GraphViz { @@ -26,55 +28,4 @@ struct GraphViz { set<Node*> visited_; }; -void GraphViz::AddTarget(Node* node) { - if (visited_.find(node) != visited_.end()) - return; - printf("\"%p\" [label=\"%s\"]\n", node, node->file_->path_.c_str()); - visited_.insert(node); - - if (!node->in_edge_) { - // Leaf node. - // Draw as a rect? - return; - } - - Edge* edge = node->in_edge_; - - if (edge->inputs_.size() == 1 && edge->outputs_.size() == 1) { - // Can draw simply. - // Note extra space before label text -- this is cosmetic and feels - // like a graphviz bug. - printf("\"%p\" -> \"%p\" [label=\" %s\"]\n", - edge->inputs_[0], edge->outputs_[0], edge->rule_->name_.c_str()); - } else { - printf("\"%p\" [label=\"%s\", shape=ellipse]\n", - edge, edge->rule_->name_.c_str()); - for (vector<Node*>::iterator out = edge->outputs_.begin(); - out != edge->outputs_.end(); ++out) { - printf("\"%p\" -> \"%p\"\n", edge, *out); - } - for (vector<Node*>::iterator in = edge->inputs_.begin(); - in != edge->inputs_.end(); ++in) { - const char* order_only = ""; - if (edge->is_order_only(in - edge->inputs_.begin())) - order_only = " style=dotted"; - printf("\"%p\" -> \"%p\" [arrowhead=none%s]\n", (*in), edge, order_only); - } - } - - for (vector<Node*>::iterator in = edge->inputs_.begin(); - in != edge->inputs_.end(); ++in) { - AddTarget(*in); - } -} - -void GraphViz::Start() { - printf("digraph ninja {\n"); - printf("node [fontsize=10, shape=box, height=0.25]\n"); - printf("edge [fontsize=10]\n"); -} - -void GraphViz::Finish() { - printf("}\n"); -} - +#endif // NINJA_GRAPHVIZ_H_ |