summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/GraphWriter.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-04-03 17:22:36 +0000
committerMatthias Braun <matze@braunis.de>2015-04-03 17:22:36 +0000
commite376d16f95cf97a93c96751490d58e72a31297bf (patch)
tree82ce3ecf526f97ee5aaa49d84e33a954141c4828 /llvm/lib/Support/GraphWriter.cpp
parenteaa9266ec516b66c4aba79988c67dad39357b59a (diff)
downloadbcm5719-llvm-e376d16f95cf97a93c96751490d58e72a31297bf.tar.gz
bcm5719-llvm-e376d16f95cf97a93c96751490d58e72a31297bf.zip
[GraphWriter] Attempt to open .dot files with xdg-open/open first
Most desktop environments let the users specify his preferred application per file type. On mac/linux we can use open/xdg-open for that and should try this first before starting a heuristic search for various programs. Differential Revision: http://reviews.llvm.org/D6534 llvm-svn: 234031
Diffstat (limited to 'llvm/lib/Support/GraphWriter.cpp')
-rw-r--r--llvm/lib/Support/GraphWriter.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Support/GraphWriter.cpp b/llvm/lib/Support/GraphWriter.cpp
index c28dd70def6..97aedc88473 100644
--- a/llvm/lib/Support/GraphWriter.cpp
+++ b/llvm/lib/Support/GraphWriter.cpp
@@ -140,6 +140,29 @@ bool llvm::DisplayGraph(StringRef FilenameRef, bool wait,
std::string ViewerPath;
GraphSession S;
+#ifdef __APPLE__
+ if (S.TryFindProgram("open", ViewerPath)) {
+ std::vector<const char *> args;
+ args.push_back(ViewerPath.c_str());
+ if (wait)
+ args.push_back("-W");
+ args.push_back(Filename.c_str());
+ args.push_back(nullptr);
+ errs() << "Trying 'open' program... ";
+ if (!ExecGraphViewer(ViewerPath, args, Filename, wait, ErrMsg))
+ return false;
+ }
+#endif
+ if (S.TryFindProgram("xdg-open", ViewerPath)) {
+ std::vector<const char *> args;
+ args.push_back(ViewerPath.c_str());
+ args.push_back(Filename.c_str());
+ args.push_back(nullptr);
+ errs() << "Trying 'xdg-open' program... ";
+ if (!ExecGraphViewer(ViewerPath, args, Filename, wait, ErrMsg))
+ return false;
+ }
+
// Graphviz
if (S.TryFindProgram("Graphviz", ViewerPath)) {
std::vector<const char *> args;
OpenPOWER on IntegriCloud