Add support for viewing graphviz graphs with xdot.py.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114832 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-09-27 16:28:34 +00:00
parent 520163c98b
commit 48fd5a79e0
4 changed files with 105 additions and 5 deletions

View File

@ -979,6 +979,16 @@ if test "$DOTTY" != "echo dotty" ; then
AC_DEFINE_UNQUOTED([LLVM_PATH_DOTTY],"$DOTTY${EXEEXT}",
[Define to path to dotty program if found or 'echo dotty' otherwise])
fi
AC_PATH_PROG(XDOT_PY, [xdot.py], [echo xdot.py])
if test "$XDOT_PY" != "echo xdot.py" ; then
AC_DEFINE([HAVE_XDOT_PY],[1],[Define if the xdot.py program is available])
dnl If we're targeting for mingw we should emit windows paths, not msys
if test "$llvm_cv_os_type" = "MingW" ; then
XDOT_PY=`echo $XDOT_PY | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
fi
AC_DEFINE_UNQUOTED([LLVM_PATH_XDOT_PY],"$XDOT_PY${EXEEXT}",
[Define to path to xdot.py program if found or 'echo xdot.py' otherwise])
fi
dnl Look for a sufficiently recent version of Perl.
LLVM_PROG_PERL([5.006])

62
configure vendored
View File

@ -729,6 +729,7 @@ TWOPI
CIRCO
GV
DOTTY
XDOT_PY
PERL
HAVE_PERL
INSTALL_PROGRAM
@ -7833,6 +7834,62 @@ cat >>confdefs.h <<_ACEOF
#define LLVM_PATH_DOTTY "$DOTTY${EXEEXT}"
_ACEOF
fi
# Extract the first word of "xdot.py", so it can be a program name with args.
set dummy xdot.py; ac_word=$2
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
if test "${ac_cv_path_XDOT_PY+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
case $XDOT_PY in
[\\/]* | ?:[\\/]*)
ac_cv_path_XDOT_PY="$XDOT_PY" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_XDOT_PY="$as_dir/$ac_word$ac_exec_ext"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_XDOT_PY" && ac_cv_path_XDOT_PY="echo xdot.py"
;;
esac
fi
XDOT_PY=$ac_cv_path_XDOT_PY
if test -n "$XDOT_PY"; then
{ echo "$as_me:$LINENO: result: $XDOT_PY" >&5
echo "${ECHO_T}$XDOT_PY" >&6; }
else
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
if test "$XDOT_PY" != "echo xdot.py" ; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_XDOT_PY 1
_ACEOF
if test "$llvm_cv_os_type" = "MingW" ; then
XDOT_PY=`echo $XDOT_PY | sed 's/^\/\([A-Za-z]\)\//\1:\//' `
fi
cat >>confdefs.h <<_ACEOF
#define LLVM_PATH_XDOT_PY "$XDOT_PY${EXEEXT}"
_ACEOF
fi
@ -11394,7 +11451,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 11397 "configure"
#line 11454 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -21640,6 +21697,7 @@ TWOPI!$TWOPI$ac_delim
CIRCO!$CIRCO$ac_delim
GV!$GV$ac_delim
DOTTY!$DOTTY$ac_delim
XDOT_PY!$XDOT_PY$ac_delim
PERL!$PERL$ac_delim
HAVE_PERL!$HAVE_PERL$ac_delim
INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
@ -21705,7 +21763,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 93; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 94; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

View File

@ -118,6 +118,9 @@
/* Define if the neat program is available */
#undef HAVE_FDP
/* Define to 1 if you have the <fenv.h> header file. */
#undef HAVE_FENV_H
/* Define if libffi is available on this platform. */
#undef HAVE_FFI_CALL
@ -455,12 +458,12 @@
/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
#undef HAVE_VALGRIND_VALGRIND_H
/* Define to 1 if you have the <fenv.h> header file. */
#undef HAVE_FENV_H
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
/* Define if the xdot.py program is available */
#undef HAVE_XDOT_PY
/* Define to 1 if you have the `__dso_handle' function. */
#undef HAVE___DSO_HANDLE
@ -542,6 +545,9 @@
/* Define to path to twopi program if found or 'echo twopi' otherwise */
#undef LLVM_PATH_TWOPI
/* Define to path to xdot.py program if found or 'echo xdot.py' otherwise */
#undef LLVM_PATH_XDOT_PY
/* Installation prefix directory */
#undef LLVM_PREFIX

View File

@ -69,6 +69,32 @@ void llvm::DisplayGraph(const sys::Path &Filename, bool wait,
else
Filename.eraseFromDisk();
#elif HAVE_XDOT_PY
sys::Path XDotPy();
std::vector<const char*> args;
args.push_back(LLVM_PATH_XDOT_PY);
args.push_back(Filename.c_str());
switch (program) {
case GraphProgram::DOT: args.push_back("-f"); args.push_back("dot"); break;
case GraphProgram::FDP: args.push_back("-f"); args.push_back("fdp"); break;
case GraphProgram::NEATO: args.push_back("-f"); args.push_back("neato");break;
case GraphProgram::TWOPI: args.push_back("-f"); args.push_back("twopi");break;
case GraphProgram::CIRCO: args.push_back("-f"); args.push_back("circo");break;
default: errs() << "Unknown graph layout name; using default.\n";
}
args.push_back(0);
errs() << "Running 'xdot.py' program... ";
if (sys::Program::ExecuteAndWait(sys::Path(LLVM_PATH_XDOT_PY),
&args[0],0,0,0,0,&ErrMsg))
errs() << "Error viewing graph " << Filename.str() << ": " << ErrMsg
<< "\n";
else
Filename.eraseFromDisk();
#elif (HAVE_GV && (HAVE_DOT || HAVE_FDP || HAVE_NEATO || \
HAVE_TWOPI || HAVE_CIRCO))
sys::Path PSFilename = Filename;