1 //===-- GraphWriter.cpp - Implements GraphWriter support routines ---------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements misc. GraphWriter support routines.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/GraphWriter.h"
15 #include "llvm/System/Path.h"
16 #include "llvm/System/Program.h"
17 #include "llvm/Config/config.h"
21 void llvm::DisplayGraph(const sys::Path
&Filename
) {
23 sys::Path
Graphviz(LLVM_PATH_GRAPHVIZ
);
25 std::vector
<const char*> args
;
26 args
.push_back(Graphviz
.c_str());
27 args
.push_back(Filename
.c_str());
30 std::cerr
<< "Running 'Graphviz' program... " << std::flush
;
31 if (sys::Program::ExecuteAndWait(Graphviz
, &args
[0])) {
32 std::cerr
<< "Error viewing graph: 'Graphviz' not in path?\n";
34 #elif (HAVE_GV && HAVE_DOT)
35 sys::Path PSFilename
= Filename
;
36 PSFilename
.appendSuffix("ps");
38 sys::Path
dot(LLVM_PATH_DOT
);
40 std::vector
<const char*> args
;
41 args
.push_back(dot
.c_str());
42 args
.push_back("-Tps");
43 args
.push_back("-Nfontname=Courier");
44 args
.push_back("-Gsize=7.5,10");
45 args
.push_back(Filename
.c_str());
47 args
.push_back(PSFilename
.c_str());
50 std::cerr
<< "Running 'dot' program... " << std::flush
;
51 if (sys::Program::ExecuteAndWait(dot
, &args
[0])) {
52 std::cerr
<< "Error viewing graph: 'dot' not in path?\n";
54 std::cerr
<< " done. \n";
56 sys::Path
gv(LLVM_PATH_GV
);
58 args
.push_back(gv
.c_str());
59 args
.push_back(PSFilename
.c_str());
62 sys::Program::ExecuteAndWait(gv
, &args
[0]);
64 PSFilename
.eraseFromDisk();
66 sys::Path
dotty(LLVM_PATH_DOTTY
);
68 std::vector
<const char*> args
;
69 args
.push_back(Filename
.c_str());
72 std::cerr
<< "Running 'dotty' program... " << std::flush
;
73 if (sys::Program::ExecuteAndWait(dotty
, &args
[0])) {
74 std::cerr
<< "Error viewing graph: 'dotty' not in path?\n";
76 #ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns.
82 Filename
.eraseFromDisk();