From de6157ce1e56db2ef7d35872df758ea40f188adc Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 3 Apr 2015 17:22:36 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234031 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/GraphWriter.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp index c28dd70def6..97aedc88473 100644 --- a/lib/Support/GraphWriter.cpp +++ b/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 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 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 args; -- 2.34.1