2004-07-27 00:52:44 +02:00
|
|
|
#!/bin/sh
|
2004-09-20 10:00:09 +02:00
|
|
|
##===- utils/llvmdo - Counts Lines Of Code -------------------*- Script -*-===##
|
|
|
|
#
|
|
|
|
# The LLVM Compiler Infrastructure
|
|
|
|
#
|
|
|
|
# This file was developed by Reid Spencer and is distributed under the
|
|
|
|
# University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
#
|
|
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# Usage:
|
2004-10-08 03:11:15 +02:00
|
|
|
# llvmdo [-dirs "DIRNAMES..."] PROGRAM ARGS...
|
2004-09-20 10:00:09 +02:00
|
|
|
#
|
|
|
|
# The -dirs argument allows you to specify the set of directories that are
|
2004-09-20 10:04:13 +02:00
|
|
|
# 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.
|
|
|
|
##===----------------------------------------------------------------------===##
|
2004-09-20 09:21:19 +02:00
|
|
|
|
|
|
|
if test $# -lt 1 ; then
|
2006-08-13 20:28:27 +02:00
|
|
|
echo "Usage: llvmdo [-dirs "DIRNAMES..."] [-code-only] PROGRAM ARGS..."
|
2006-08-11 23:53:27 +02:00
|
|
|
exit 1
|
2004-09-20 09:21:19 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$1" = "-dirs" ; then
|
|
|
|
LLVMDO_DIRS="$2";
|
|
|
|
shift ; shift
|
|
|
|
elif test -z "$LLVMDO_DIRS" ; then
|
2004-09-20 10:00:09 +02:00
|
|
|
LLVMDO_DIRS="include lib tools utils runtime autoconf docs test examples projects"
|
2004-09-20 09:21:19 +02:00
|
|
|
fi
|
2006-08-13 20:28:27 +02:00
|
|
|
|
|
|
|
if test "$1" = "-code-only" ; then
|
|
|
|
CODE_ONLY="set"
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
CODE_ONLY=""
|
|
|
|
fi
|
|
|
|
|
2006-08-11 23:53:27 +02:00
|
|
|
if test "$1" = "" ; then
|
|
|
|
echo "Missing program name to run"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2004-07-27 00:52:44 +02:00
|
|
|
PROGRAM=`which $1`
|
2004-09-20 09:21:19 +02:00
|
|
|
if test ! -x "$PROGRAM" ; then
|
2004-07-27 00:52:44 +02:00
|
|
|
echo "Can't execute $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
shift;
|
2006-08-11 23:53:27 +02:00
|
|
|
|
|
|
|
TOPDIR=`llvm-config --src-root`
|
|
|
|
|
2004-07-27 00:52:44 +02:00
|
|
|
if test -d "$TOPDIR" ; then
|
|
|
|
cd $TOPDIR
|
2004-10-07 18:03:21 +02:00
|
|
|
case `uname -s` in
|
|
|
|
SunOS) find_prog=gfind ;;
|
|
|
|
*) find_prog=find ;;
|
|
|
|
esac
|
2006-08-13 20:28:27 +02:00
|
|
|
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 \
|
2006-08-13 20:59:40 +02:00
|
|
|
-o -name *.footer \
|
2006-08-13 20:28:27 +02:00
|
|
|
-o -name *.gnuplot' \
|
|
|
|
-o -name *.h \
|
2006-08-13 20:59:40 +02:00
|
|
|
-o -name *.header \
|
|
|
|
-o -name *.html \
|
2006-08-13 20:28:27 +02:00
|
|
|
-o -name *.in \
|
|
|
|
-o -name *.inc \
|
2006-08-13 20:59:40 +02:00
|
|
|
-o -name *.intro \
|
2006-08-13 20:28:27 +02:00
|
|
|
-o -name *.l \
|
|
|
|
-o -name *.ll \
|
|
|
|
-o -name *.llx \
|
|
|
|
-o -name *.lst \
|
|
|
|
-o -name *.m4 \
|
2006-08-13 20:59:40 +02:00
|
|
|
-o -name *.pod \
|
2006-08-13 20:28:27 +02:00
|
|
|
-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
|
2004-10-07 18:03:21 +02:00
|
|
|
$find_prog $LLVMDO_DIRS -type f \
|
2006-08-13 20:28:27 +02:00
|
|
|
\( $paths_to_ignore \) -prune \
|
|
|
|
-o \( \( $files_to_match \) \! \( $files_to_ignore \) \
|
|
|
|
-exec $PROGRAM "$@" {} \; \)
|
2004-07-27 00:52:44 +02:00
|
|
|
else
|
|
|
|
echo "Can't find LLVM top directory in $TOPDIR"
|
|
|
|
fi
|