Make llvmdo and llvmgrep invulnerable to where they are run from by getting
authorReid Spencer <rspencer@reidspencer.com>
Fri, 11 Aug 2006 21:53:27 +0000 (21:53 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Fri, 11 Aug 2006 21:53:27 +0000 (21:53 +0000)
the llvm source root from the llvm-config command. The dependency now is
that the correct llvm-config command is in the path. For most developers
this is the case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29630 91177308-0d34-0410-b5e6-96231b3b80d8

utils/llvmdo
utils/llvmgrep

index 9b1179b44e32e4ceba8a5888f1fcb213af882cb5..02013ba8b07c609d6c151c9b88e2546e0b0f4029 100755 (executable)
@@ -27,8 +27,8 @@
 ##===----------------------------------------------------------------------===##
 
 if test $# -lt 1 ; then
-  echo "Usage: llvmdo [-dirs "DIRNAMES..."] PROGRAM ARGS...";
-  exit 1;
+  echo "Usage: llvmdo [-dirs "DIRNAMES..."] PROGRAM ARGS..."
+  exit 1
 fi
 
 if test "$1" = "-dirs" ; then
@@ -37,13 +37,20 @@ if test "$1" = "-dirs" ; then
 elif test -z "$LLVMDO_DIRS" ; then
   LLVMDO_DIRS="include lib tools utils runtime autoconf docs test examples projects"
 fi
+if test "$1" = "" ; then
+  echo "Missing program name to run"
+  exit 1
+fi
+
 PROGRAM=`which $1`
 if test ! -x "$PROGRAM" ; then
   echo "Can't execute $1"
   exit 1
 fi
 shift;
-TOPDIR=`pwd | sed -e 's#\(.*/llvm[0-9]*\).*#\1#'`
+
+TOPDIR=`llvm-config --src-root`
+
 if test -d "$TOPDIR" ; then
   cd $TOPDIR
   case `uname -s` in
index e5a08ad00512a0e1ea9dfbed315668c61725c227..d4369c7d7641fd08ae6abf5cd04806aaa9193cb7 100755 (executable)
@@ -18,8 +18,7 @@
 # details.
 ##===----------------------------------------------------------------------===##
 
-TOPDIR=`pwd | sed -e 's#\(.*/llvm[0-9]*\).*#\1#'`
-echo $TOPDIR
+TOPDIR=`llvm-config --src-root`
 if test -d "$TOPDIR" ; then
   cd $TOPDIR
   case `uname -s` in