[PATCH] D11877: [Support] On Windows, generate PDF files for graphs and open with associated viewer,
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 8 12:55:25 PDT 2015
Meinersbur created this revision.
Meinersbur added a reviewer: Bigcheese.
Meinersbur added a subscriber: llvm-commits.
Meinersbur set the repository for this revision to rL LLVM.
Windows system rarely have good PostScript viewers installed, but PDF viewers are common. So for viewing graphs, generate PDF files and open with the associated PDF viewer using cmd.exe's start command.
Repository:
rL LLVM
http://reviews.llvm.org/D11877
Files:
lib/Support/GraphWriter.cpp
Index: lib/Support/GraphWriter.cpp
===================================================================
--- lib/Support/GraphWriter.cpp
+++ lib/Support/GraphWriter.cpp
@@ -189,7 +189,13 @@
return ExecGraphViewer(ViewerPath, args, Filename, wait, ErrMsg);
}
- enum PSViewerKind { PSV_None, PSV_OSXOpen, PSV_XDGOpen, PSV_Ghostview };
+ enum PSViewerKind {
+ PSV_None,
+ PSV_OSXOpen,
+ PSV_XDGOpen,
+ PSV_Ghostview,
+ PDFV_Start
+ };
PSViewerKind PSViewer = PSV_None;
#ifdef __APPLE__
if (!PSViewer && S.TryFindProgram("open", ViewerPath))
@@ -199,17 +205,26 @@
PSViewer = PSV_Ghostview;
if (!PSViewer && S.TryFindProgram("xdg-open", ViewerPath))
PSViewer = PSV_XDGOpen;
+#ifdef LLVM_ON_WIN32
+ if (!PSViewer && S.TryFindProgram("cmd", ViewerPath)) {
+ PSViewer = PDFV_Start;
+ }
+#endif
// PostScript graph generator + PostScript viewer
std::string GeneratorPath;
if (PSViewer &&
(S.TryFindProgram(getProgramName(program), GeneratorPath) ||
S.TryFindProgram("dot|fdp|neato|twopi|circo", GeneratorPath))) {
- std::string PSFilename = Filename + ".ps";
+ std::string PSFilename =
+ Filename + (PSViewer == PDFV_Start ? ".pdf" : ".ps");
std::vector<const char *> args;
args.push_back(GeneratorPath.c_str());
- args.push_back("-Tps");
+ if (PSViewer == PDFV_Start)
+ args.push_back("-Tpdf");
+ else
+ args.push_back("-Tps");
args.push_back("-Nfontname=Courier");
args.push_back("-Gsize=7.5,10");
args.push_back(Filename.c_str());
@@ -222,6 +237,10 @@
if (ExecGraphViewer(GeneratorPath, args, Filename, true, ErrMsg))
return true;
+ std::string StartArg;
+ if (PSViewer == PDFV_Start)
+ StartArg = (StringRef("start ") + PSFilename).str();
+
args.clear();
args.push_back(ViewerPath.c_str());
switch (PSViewer) {
@@ -237,6 +256,11 @@
args.push_back("--spartan");
args.push_back(PSFilename.c_str());
break;
+ case PDFV_Start:
+ args.push_back("/S");
+ args.push_back("/C");
+ args.push_back(StartArg.c_str());
+ break;
case PSV_None:
llvm_unreachable("Invalid viewer");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11877.31598.patch
Type: text/x-patch
Size: 2201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150808/91a46f31/attachment.bin>
More information about the llvm-commits
mailing list