[llvm] r210147 - GraphWriter: support the XDG open utility

Alp Toker alp at nuanti.com
Tue Jun 3 20:57:44 PDT 2014


Author: alp
Date: Tue Jun  3 22:57:44 2014
New Revision: 210147

URL: http://llvm.org/viewvc/llvm-project?rev=210147&view=rev
Log:
GraphWriter: support the XDG open utility

This runs a suitable viewer on Unix desktop environments specified by
Freedesktop.org (GNOME, KDE, Linux distributions etc.)

Modified:
    llvm/trunk/lib/Support/GraphWriter.cpp

Modified: llvm/trunk/lib/Support/GraphWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/GraphWriter.cpp?rev=210147&r1=210146&r2=210147&view=diff
==============================================================================
--- llvm/trunk/lib/Support/GraphWriter.cpp (original)
+++ llvm/trunk/lib/Support/GraphWriter.cpp Tue Jun  3 22:57:44 2014
@@ -164,12 +164,14 @@ bool llvm::DisplayGraph(StringRef Filena
     return ExecGraphViewer(ViewerPath, args, Filename, wait, ErrMsg);
   }
 
-  enum PSViewerKind { PSV_None, PSV_OSXOpen, PSV_Ghostview };
+  enum PSViewerKind { PSV_None, PSV_OSXOpen, PSV_XDGOpen, PSV_Ghostview };
   PSViewerKind PSViewer = PSV_None;
 #ifdef __APPLE__
-  if (S.TryFindProgram("open", ViewerPath))
+  if (!PSViewer && S.TryFindProgram("open", ViewerPath))
     PSViewer = PSV_OSXOpen;
 #endif
+  if (!PSViewer && S.TryFindProgram("xdg-open", ViewerPath))
+    PSViewer = PSV_XDGOpen;
   if (!PSViewer && S.TryFindProgram("gv", ViewerPath))
     PSViewer = PSV_Ghostview;
 
@@ -202,6 +204,10 @@ bool llvm::DisplayGraph(StringRef Filena
       args.push_back("-W");
       args.push_back(PSFilename.c_str());
       break;
+    case PSV_XDGOpen:
+      wait = false;
+      args.push_back(PSFilename.c_str());
+      break;
     case PSV_Ghostview:
       args.push_back("--spartan");
       args.push_back(PSFilename.c_str());





More information about the llvm-commits mailing list