[llvm-commits] CVS: llvm/utils/NewNightlyTest.pl countloc.sh getsrcs.sh llvmdo llvmgrep userloc.pl

Reid Spencer reid at x10sys.com
Mon Aug 14 11:49:23 PDT 2006



Changes in directory llvm/utils:

NewNightlyTest.pl updated: 1.50 -> 1.51
countloc.sh updated: 1.6 -> 1.7
getsrcs.sh updated: 1.21 -> 1.22
llvmdo updated: 1.18 -> 1.19
llvmgrep updated: 1.10 -> 1.11
userloc.pl updated: 1.8 -> 1.9
---
Log message:

Make all tools that use llvmdo have a -topdir option that allows the top
source dir for LLVM to be specified explicitly. This removes the dependency
on the llvm-config script. If the option is not given, then the scripts use
llvm-config which should be both built and in the PATH. This arrangement
provides a useful default for most developers but also allows the nightly
tester to execute countloc.sh before llvm-config is built and without 
altering the PATH.


---
Diffs of the changes:  (+186 -127)

 NewNightlyTest.pl |    2 
 countloc.sh       |   19 +++-
 getsrcs.sh        |   18 +++
 llvmdo            |  244 ++++++++++++++++++++++++++++--------------------------
 llvmgrep          |   15 ++-
 userloc.pl        |   15 ++-
 6 files changed, 186 insertions(+), 127 deletions(-)


Index: llvm/utils/NewNightlyTest.pl
diff -u llvm/utils/NewNightlyTest.pl:1.50 llvm/utils/NewNightlyTest.pl:1.51
--- llvm/utils/NewNightlyTest.pl:1.50	Mon Aug 14 11:07:14 2006
+++ llvm/utils/NewNightlyTest.pl	Mon Aug 14 13:49:05 2006
@@ -638,7 +638,7 @@
 
 # Get the number of lines of source code. Must be here after the build is done
 # because countloc.sh uses the llvm-config script which must be built.
-my $LOC = `utils/countloc.sh`;
+my $LOC = `utils/countloc.sh -topdir $BuildDir`;
 
 # Get the time taken by the configure script
 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";


Index: llvm/utils/countloc.sh
diff -u llvm/utils/countloc.sh:1.6 llvm/utils/countloc.sh:1.7
--- llvm/utils/countloc.sh:1.6	Sun Aug 13 13:29:21 2006
+++ llvm/utils/countloc.sh	Mon Aug 14 13:49:05 2006
@@ -12,20 +12,29 @@
 # (excluding certain things), runs "wc -l" on them to get the number of lines in
 # each file and then sums up and prints the total with awk. 
 #
-# The script takes no arguments but does expect to be run from somewhere in
-# the top llvm source directory.
+# The script takes one optional option, -topdir, which specifies the top llvm
+# source directory. If it is not specified then the llvm-config tool is 
+# consulted to find top source dir.  
 #
 # Note that the implementation is based on llvmdo. See that script for more
 # details.
 ##===----------------------------------------------------------------------===##
 
-TOPDIR=`llvm-config --src-root`
+if test $# -gt 1 ; then
+  if test "$1" = "-topdir" ; then
+    TOPDIR="$2"
+    shift; shift;
+  else
+    TOPDIR=`llvm-config --src-root`
+  fi
+fi
+
 if test -d "$TOPDIR" ; then
   cd $TOPDIR
-  ./utils/llvmdo -dirs "include lib tools test utils examples" -code-only wc -l | awk '\
+  ./utils/llvmdo -topdir "$TOPDIR" -dirs "include lib tools test utils examples" -code-only wc -l | awk '\
       BEGIN { loc=0; } \
       { loc += $1; } \
       END { print loc; }'
 else
-  echo "Can't find LLVM top directory in $TOPDIR"
+  echo "Can't find LLVM top directory"
 fi


Index: llvm/utils/getsrcs.sh
diff -u llvm/utils/getsrcs.sh:1.21 llvm/utils/getsrcs.sh:1.22
--- llvm/utils/getsrcs.sh:1.21	Mon Sep 20 03:09:36 2004
+++ llvm/utils/getsrcs.sh	Mon Aug 14 13:49:05 2006
@@ -10,15 +10,27 @@
 ##===----------------------------------------------------------------------===##
 #
 # This script just prints out the path names for all the source files in LLVM.
+# The optional -topdir option can be used to specify the top LLVM source 
+# directory. Without it, the llvm-config command is consulted to find the
+# top source directory.
 #
 # Note that the implementation is based on llvmdo. See that script for more
 # details.
 ##===----------------------------------------------------------------------===##
 
-TOPDIR=`pwd | sed -e 's#\(.*/llvm\).*#\1#'`
+if test $# -gt 1 ; then
+  if test "$1" = "-topdir" ; then
+    TOPDIR="$2"
+    shift; shift;
+  else
+    TOPDIR=`llvm-config --src-root`
+  fi
+fi
+
 if test -d "$TOPDIR" ; then
   cd $TOPDIR
-  ./utils/llvmdo -dirs "include lib tools utils examples projects" echo
+  ./utils/llvmdo -topdir "$TOPDIR" \
+    -dirs "include lib tools utils examples projects" echo
 else
-  echo "Can't find LLVM top directory in $TOPDIR"
+  echo "Can't find LLVM top directory"
 fi


Index: llvm/utils/llvmdo
diff -u llvm/utils/llvmdo:1.18 llvm/utils/llvmdo:1.19
--- llvm/utils/llvmdo:1.18	Sun Aug 13 13:59:40 2006
+++ llvm/utils/llvmdo	Mon Aug 14 13:49:05 2006
@@ -11,28 +11,46 @@
 # This script is a general purpose "apply" function for the source files in LLVM
 # It uses "find" to locate all the source files and then applies the user's 
 # command to them. As such, this command is often not used by itself much but
-# the other find related tools (countloc.sh,llvmgrep,getsrcs.sh) are all based 
-# on the implementation. This script defines "what is a source file" in LLVM and
-# so should be maintained if new directories, new file extensions, etc. are 
-# used in LLVM as it progresses.
+# the other find related tools (countloc.sh,llvmgrep,getsrcs.sh,userloc.sh) are
+# all based on this script.  This script defines "what is a source file" in 
+# LLVM and so should be maintained if new directories, new file extensions, 
+# etc. are used in LLVM as it progresses.
 #
 # Usage:
-#  llvmdo [-dirs "DIRNAMES..."] PROGRAM ARGS...
+#  llvmdo [-topdir DIR] [-dirs "DIRNAMES..."] [-code-only] PROGRAM ARGS...
+#
+# The -topdir option allows you to specify the llvm source root directly. If it
+# is not specified then it will be obtained with llvm-config which must be built
+# and in your path.
 #
 # The -dirs argument allows you to specify the set of directories that are 
-# searched. By default, everything is searched. Note that you must use quotes
-# around the list of directory names. After that you simply specify whatever
-# program you want to run against each file and the arguments to give it. The
-# PROGRAM will be given the file name as its last argument.
+# searched. The default list of directories searched is:
+#   include lib tools utils runtime autoconf docs test examples projects
+# Note that you must use quotes around the list of directory names. 
+#
+# The -code-only option specifies that only those files that are considered 
+# "code" should be visited. HTML documentation is considered code, but things 
+# like README files, etc. are not.
+#
+# Finally, you simply specify whatever program you want to run against each 
+# file and the arguments to give it. The PROGRAM will be given the file name 
+# as its last argument.
 ##===----------------------------------------------------------------------===##
 
 if test $# -lt 1 ; then
-  echo "Usage: llvmdo [-dirs "DIRNAMES..."] [-code-only] PROGRAM ARGS..."
+  echo "Usage: llvmdo [-topdir DIR] [-dirs "DIRNAMES..."] [-code-only] PROGRAM ARGS..."
   exit 1
 fi
 
+if test "$1" = "-topdir" ; then
+  TOPDIR="$2"
+  shift; shift;
+else
+  TOPDIR=`llvm-config --src-root`
+fi
+
 if test "$1" = "-dirs" ; then
-  LLVMDO_DIRS="$2";
+  LLVMDO_DIRS="$2"
   shift ; shift
 elif test -z "$LLVMDO_DIRS" ; then
   LLVMDO_DIRS="include lib tools utils runtime autoconf docs test examples projects"
@@ -57,115 +75,115 @@
 fi
 shift;
 
-TOPDIR=`llvm-config --src-root`
+paths_to_ignore="\
+  -path */CVS -o \
+  -path */CVS/* -o \
+  -path docs/doxygen/* -o \
+  -path docs/CommandGuide/html/* -o \
+  -path docs/CommandGuide/man/* -o \
+  -path docs/CommandGuide/ps/* -o \
+  -path docs/CommandGuide/man/* -o \
+  -path docs/HistoricalNotes/* -o \
+  -path docs/img/* -o \
+  -path */.libs/* -o \
+  -path lib/Support/bzip2/* -o \
+  -path projects/llvm-test/* \
+"
+files_to_match="\
+     -name *.ac \
+  -o -name *.b \
+  -o -name *.c \
+  -o -name *.cc \
+  -o -name *.cfg \
+  -o -name *.cpp \
+  -o -name *.css \
+  -o -name *.def \
+  -o -name *.el \
+  -o -name *.exp \
+  -o -name *.footer \
+  -o -name *.gnuplot' \
+  -o -name *.h \
+  -o -name *.header \
+  -o -name *.html \
+  -o -name *.in \
+  -o -name *.inc \
+  -o -name *.intro \
+  -o -name *.l \
+  -o -name *.ll \
+  -o -name *.llx \
+  -o -name *.lst \
+  -o -name *.m4 \
+  -o -name *.pod \
+  -o -name *.pl \
+  -o -name *.py \
+  -o -name *.sh \
+  -o -name *.schema \
+  -o -name *.st \
+  -o -name *.tcl \
+  -o -name *.td \
+  -o -name *.tr \
+  -o -name *.y \
+  -o -name Make* \
+  -o -name llvmdo \
+  -o -name llvmgrep \
+  -o -name check-each-file \
+  -o -name codgen-diff \
+  -o -name cvsupdate \
+  -o -name llvm-native-gcc \
+  -o -name llvm-native-gxx \
+  -o -name makellvm \
+  -o -path include/llvm/ADT/ilist \
+  -o -path test/\*.ll \
+  -o -path test/Scripts/not \
+  -o -path runtime/\*.ll \
+"
+if test -z "$CODE_ONLY" ; then
+  files_to_match="$files_to_match \
+    -o -name *.txt \
+    -o -name *.TXT \
+    -o -name *.vim \
+    -o -name vimrc \
+    -o -name README \
+    -o -name COPYING.LIB \
+    -o -name LICENSE* "
+fi
+files_to_ignore="\
+     -name \.* \
+  -o -name *~ \
+  -o -name #* \
+  -o -name *.cvs \
+  -o -name configure \
+  -o -name slow.ll \
+  -o -name *libtool* \
+  -o -name ltdl* \
+  -o -name ltdl.m4 \
+  -o -name ltmain.m4 \
+  -o -name ltmain.sh \
+  -o -name aclocal.m4 \
+  -o -name acinclude.m4 \
+  -o -name *VerifierIsReallySlow.llx \
+  -o -name *LoopSimplifyCrash.ll \
+  -o -name *AST-Remove.ll \
+  -o -name llvmAsmParser.cpp \
+  -o -name llvmAsmParser.h \
+  -o -name Lexer.cpp \
+  -o -name FileLexer.cpp \
+  -o -name FileParser.cpp \
+  -o -name FileParser.h \
+  -o -name StackerParser.h \
+  -o -name StackerParser.cpp \
+  -o -name ConfigLexer.cpp \
+  -o -name PPCPerfectShuffle.h \
+"
 
 if test -d "$TOPDIR" ; then
   cd $TOPDIR
+  # Have to use the right "find" on a per-platform basis. Most platforms have
+  # Gnu find as "find", but Solaris does not.
   case `uname -s` in
     SunOS) find_prog=gfind ;;
     *) find_prog=find ;;
   esac
-  paths_to_ignore="\
-    -path */CVS -o \
-    -path */CVS/* -o \
-    -path docs/doxygen/* -o \
-    -path docs/CommandGuide/html/* -o \
-    -path docs/CommandGuide/man/* -o \
-    -path docs/CommandGuide/ps/* -o \
-    -path docs/CommandGuide/man/* -o \
-    -path docs/HistoricalNotes/* -o \
-    -path docs/img/* -o \
-    -path */.libs/* -o \
-    -path lib/Support/bzip2/* -o \
-    -path projects/llvm-test/* \
-  "
-  files_to_match="\
-       -name *.ac \
-    -o -name *.b \
-    -o -name *.c \
-    -o -name *.cc \
-    -o -name *.cfg \
-    -o -name *.cpp \
-    -o -name *.css \
-    -o -name *.def \
-    -o -name *.el \
-    -o -name *.exp \
-    -o -name *.footer \
-    -o -name *.gnuplot' \
-    -o -name *.h \
-    -o -name *.header \
-    -o -name *.html \
-    -o -name *.in \
-    -o -name *.inc \
-    -o -name *.intro \
-    -o -name *.l \
-    -o -name *.ll \
-    -o -name *.llx \
-    -o -name *.lst \
-    -o -name *.m4 \
-    -o -name *.pod \
-    -o -name *.pl \
-    -o -name *.py \
-    -o -name *.sh \
-    -o -name *.schema \
-    -o -name *.st \
-    -o -name *.tcl \
-    -o -name *.td \
-    -o -name *.tr \
-    -o -name *.y \
-    -o -name Make* \
-    -o -name llvmdo \
-    -o -name llvmgrep \
-    -o -name check-each-file \
-    -o -name codgen-diff \
-    -o -name cvsupdate \
-    -o -name llvm-native-gcc \
-    -o -name llvm-native-gxx \
-    -o -name makellvm \
-    -o -path include/llvm/ADT/ilist \
-    -o -path test/\*.ll \
-    -o -path test/Scripts/not \
-    -o -path runtime/\*.ll \
-  "
-  if test -z "$CODE_ONLY" ; then
-    files_to_match="$files_to_match \
-      -o -name *.txt \
-      -o -name *.TXT \
-      -o -name *.vim \
-      -o -name vimrc \
-      -o -name README \
-      -o -name COPYING.LIB \
-      -o -name LICENSE* "
-  fi
-  files_to_ignore="\
-       -name \.* \
-    -o -name *~ \
-    -o -name #* \
-    -o -name *.cvs \
-    -o -name configure \
-    -o -name slow.ll \
-    -o -name *libtool* \
-    -o -name ltdl* \
-    -o -name ltdl.m4 \
-    -o -name ltmain.m4 \
-    -o -name ltmain.sh \
-    -o -name aclocal.m4 \
-    -o -name acinclude.m4 \
-    -o -name *VerifierIsReallySlow.llx \
-    -o -name *LoopSimplifyCrash.ll \
-    -o -name *AST-Remove.ll \
-    -o -name llvmAsmParser.cpp \
-    -o -name llvmAsmParser.h \
-    -o -name Lexer.cpp \
-    -o -name FileLexer.cpp \
-    -o -name FileParser.cpp \
-    -o -name FileParser.h \
-    -o -name StackerParser.h \
-    -o -name StackerParser.cpp \
-    -o -name ConfigLexer.cpp \
-    -o -name PPCPerfectShuffle.h \
-  "
-
   # Turn off file name generation (globbing) so that substitution of the
   # variables doesn't cause the shell to create lists of file names
   set -f


Index: llvm/utils/llvmgrep
diff -u llvm/utils/llvmgrep:1.10 llvm/utils/llvmgrep:1.11
--- llvm/utils/llvmgrep:1.10	Fri Aug 11 16:53:27 2006
+++ llvm/utils/llvmgrep	Mon Aug 14 13:49:05 2006
@@ -18,7 +18,15 @@
 # details.
 ##===----------------------------------------------------------------------===##
 
-TOPDIR=`llvm-config --src-root`
+if test $# -gt 1 ; then
+  if test "$1" = "-topdir" ; then
+    TOPDIR="$2"
+    shift; shift;
+  else
+    TOPDIR=`llvm-config --src-root`
+  fi
+fi
+
 if test -d "$TOPDIR" ; then
   cd $TOPDIR
   case `uname -s` in
@@ -26,7 +34,8 @@
     Linux) grep_cmd="egrep -H -n" ;;
     *) grep_cmd="egrep -l -n" ;;
   esac
-  ./utils/llvmdo -dirs "include lib tools utils docs examples test projects" $grep_cmd "$*"
+  ./utils/llvmdo -topdir "$TOPDIR" \
+    -dirs "include lib tools utils docs examples test projects" $grep_cmd "$*"
 else
-  echo "Can't find LLVM top directory in $TOPDIR"
+  echo "Can't find LLVM top directory"
 fi


Index: llvm/utils/userloc.pl
diff -u llvm/utils/userloc.pl:1.8 llvm/utils/userloc.pl:1.9
--- llvm/utils/userloc.pl:1.8	Sun Aug 13 14:03:06 2006
+++ llvm/utils/userloc.pl	Mon Aug 14 13:49:05 2006
@@ -17,6 +17,9 @@
 #               Report details about lines of code in each file for each user
 #           -html
 #               Generate HTML output instead of text output
+#           -topdir
+#               Specify where the top llvm source directory is. Otherwise the
+#               llvm-config tool is used to find it.
 # Directories:
 #   The directories passed after the options should be relative paths to
 #   directories of interest from the top of the llvm source tree, e.g. "lib"
@@ -29,6 +32,7 @@
 my $html = 0;
 my $debug = 0;
 my $filedetails = "";
+my $srcroot = "";
 while ( defined($ARGV[0]) && substr($ARGV[0],0,1) eq '-' )
 {
   if ($ARGV[0] =~ /-tag=.*/) {
@@ -40,15 +44,22 @@
     $html = 1;
   } elsif ($ARGV[0] eq "-debug") {
     $debug = 1;
+  } elsif ($ARGV[0] eq "-topdir") {
+    shift; $srcroot = $ARGV[0]; shift;
   } else {
     die "Invalid option: $ARGV[0]";
   }
   shift;
 }
 
-chomp(my $srcroot = `llvm-config --src-root`);
+if (length($srcroot) == 0) {
+  chomp($srcroot = `llvm-config --src-root`);
+}
+if (! -d "$srcroot") {
+  die "Invalid source root: $srcroot\n";
+}
 chdir($srcroot);
-my $llvmdo = "$srcroot/utils/llvmdo";
+my $llvmdo = "$srcroot/utils/llvmdo -topdir '$srcroot'";
 my %Stats;
 my %FileStats;
 






More information about the llvm-commits mailing list