From 2fed0d369b9f501de509dea5d25c892b47b4624d Mon Sep 17 00:00:00 2001 From: Marek Chalupa Date: Mon, 23 May 2016 19:50:36 +0200 Subject: [PATCH] ps-show,rd-show,llvmdg-dump: use xdot when available nice viewer Signed-off-by: Marek Chalupa --- tools/llvmdg-show | 20 +++++++++++++++++--- tools/ps-show | 22 +++++++++++++++++++--- tools/rd-show | 20 +++++++++++++++++--- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/tools/llvmdg-show b/tools/llvmdg-show index 013b89160..00634bb1b 100755 --- a/tools/llvmdg-show +++ b/tools/llvmdg-show @@ -4,12 +4,26 @@ DIR=`dirname $0` #defult program GUI=xdg-open +DIRECTDOT=0 -if which okular &>/dev/null; then +set -e + +if which xdot &>/dev/null; then + GUI=xdot + DIRECTDOT=1 +elif which okular &>/dev/null; then GUI=okular elif which evince &>/dev/null; then GUI=evince fi -$DIR/llvm-dg-dump $* > ldg-show-output.dot && dot -Tpdf ldg-show-output.dot -o ldg-show-output.pdf && $GUI ldg-show-output.pdf -rm ldg-show-output* +$DIR/llvm-dg-dump $* > _ldg-show-output.dot + +if [ $DIRECTDOT -eq 1 ]; then + $GUI _ldg-show-output.dot +else + dot -Tpdf _ldg-show-output.dot -o ldg-show-output.pdf + $GUI _ldg-show-output.pdf +fi + +rm _ldg-show-output* diff --git a/tools/ps-show b/tools/ps-show index 8f267b206..594a6ea33 100755 --- a/tools/ps-show +++ b/tools/ps-show @@ -2,12 +2,28 @@ #defult program GUI=xdg-open +DIRECTDOT=0 -if which okular &>/dev/null; then +# exit on any error +set -e + +if which xdot &>/dev/null; then + GUI=xdot + DIRECTDOT=1 +elif which okular &>/dev/null; then GUI=okular elif which evince &>/dev/null; then GUI=evince fi -`dirname $0`/llvm-ps-dump -dot $@ > _ps.dot && dot -Tpdf -o _ps.pdf _ps.dot && $GUI _ps.pdf -rm _ps.pdf _ps.dot +`dirname $0`/llvm-ps-dump -dot $@ > _ps.dot + + +if [ $DIRECTDOT -eq 1 ]; then + $GUI _ps.dot + rm _ps.dot +else + dot -Tpdf -o _ps.pdf _ps.dot + $GUI _ps.pdf + rm _ps.pdf _ps.dot +fi diff --git a/tools/rd-show b/tools/rd-show index c8cf7e18c..3731a0df6 100755 --- a/tools/rd-show +++ b/tools/rd-show @@ -2,12 +2,26 @@ #defult program GUI=xdg-open +DIRECTDOT=0 -if which okular &>/dev/null; then +set -e + +if which xdot &>/dev/null; then + GUI=xdot + DIRECTDOT=1 +elif which okular &>/dev/null; then GUI=okular elif which evince &>/dev/null; then GUI=evince fi -`dirname $0`/llvm-rd-dump -dot $@ > _rd.dot && dot -Tpdf -o _rd.pdf _rd.dot && $GUI _rd.pdf -rm _rd.pdf _rd.dot +`dirname $0`/llvm-rd-dump -dot $@ > _rd.dot + +if [ $DIRECTDOT -eq 1 ]; then + $GUI _rd.dot + rm _rd.dot +else + dot -Tpdf -o _rd.pdf _rd.dot + $GUI _rd.pdf + rm _rd.pdf _rd.dot +fi