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/System/Path.h"
15 #include "llvm/System/Program.h"
16 #include "llvm/Config/config.h"
24 void DisplayGraph(const sys::Path& Filename)
27 sys::Path Graphviz(LLVM_PATH_GRAPHVIZ);
29 std::vector<const char*> args;
30 args.push_back(Graphviz.c_str());
31 args.push_back(Filename.c_str());
34 std::cerr << "Running 'Graphviz' program... " << std::flush;
35 if (sys::Program::ExecuteAndWait(Graphviz, &args[0])) {
36 std::cerr << "Error viewing graph: 'Graphviz' not in path?\n";
38 #elif (HAVE_GV && HAVE_DOT)
39 sys::Path PSFilename = Filename;
40 PSFilename.appendSuffix("ps");
42 sys::Path dot(LLVM_PATH_DOT);
44 std::vector<const char*> args;
45 args.push_back(dot.c_str());
46 args.push_back("-Tps");
47 args.push_back("-Nfontname=Courier");
48 args.push_back("-Gsize=7.5,10");
49 args.push_back(Filename.c_str());
51 args.push_back(PSFilename.c_str());
54 std::cerr << "Running 'dot' program... " << std::flush;
55 if (sys::Program::ExecuteAndWait(dot, &args[0])) {
56 std::cerr << "Error viewing graph: 'dot' not in path?\n";
58 std::cerr << " done. \n";
60 sys::Path gv(LLVM_PATH_GV);
62 args.push_back(gv.c_str());
63 args.push_back(PSFilename.c_str());
66 sys::Program::ExecuteAndWait(gv, &args[0]);
68 PSFilename.eraseFromDisk();
70 sys::Path dotty(LLVM_PATH_DOTTY);
72 std::vector<const char*> args;
73 args.push_back(Filename.c_str());
76 std::cerr << "Running 'dotty' program... " << std::flush;
77 if (sys::Program::ExecuteAndWait(dotty, &args[0])) {
78 std::cerr << "Error viewing graph: 'dotty' not in path?\n";
80 #ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns.
86 Filename.eraseFromDisk();
89 } // End llvm namespace