2004-07-26 22:52:44 +00:00
|
|
|
#!/bin/sh
|
2004-09-20 08:00:09 +00: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 01:11:15 +00:00
|
|
|
# llvmdo [-dirs "DIRNAMES..."] PROGRAM ARGS...
|
2004-09-20 08:00:09 +00:00
|
|
|
#
|
|
|
|
# The -dirs argument allows you to specify the set of directories that are
|
2004-09-20 08:04:13 +00: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 07:21:19 +00:00
|
|
|
|
|
|
|
if test $# -lt 1 ; then
|
2006-08-11 21:53:27 +00:00
|
|
|
echo "Usage: llvmdo [-dirs "DIRNAMES..."] PROGRAM ARGS..."
|
|
|
|
exit 1
|
2004-09-20 07:21:19 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$1" = "-dirs" ; then
|
|
|
|
LLVMDO_DIRS="$2";
|
|
|
|
shift ; shift
|
|
|
|
elif test -z "$LLVMDO_DIRS" ; then
|
2004-09-20 08:00:09 +00:00
|
|
|
LLVMDO_DIRS="include lib tools utils runtime autoconf docs test examples projects"
|
2004-09-20 07:21:19 +00:00
|
|
|
fi
|
2006-08-11 21:53:27 +00:00
|
|
|
if test "$1" = "" ; then
|
|
|
|
echo "Missing program name to run"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2004-07-26 22:52:44 +00:00
|
|
|
PROGRAM=`which $1`
|
2004-09-20 07:21:19 +00:00
|
|
|
if test ! -x "$PROGRAM" ; then
|
2004-07-26 22:52:44 +00:00
|
|
|
echo "Can't execute $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
shift;
|
2006-08-11 21:53:27 +00:00
|
|
|
|
|
|
|
TOPDIR=`llvm-config --src-root`
|
|
|
|
|
2004-07-26 22:52:44 +00:00
|
|
|
if test -d "$TOPDIR" ; then
|
|
|
|
cd $TOPDIR
|
2004-10-07 16:03:21 +00:00
|
|
|
case `uname -s` in
|
|
|
|
SunOS) find_prog=gfind ;;
|
|
|
|
*) find_prog=find ;;
|
|
|
|
esac
|
|
|
|
$find_prog $LLVMDO_DIRS -type f \
|
2004-09-20 07:21:19 +00:00
|
|
|
\( \
|
|
|
|
-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/*' \
|
|
|
|
\) -prune -o \( \
|
2004-09-20 08:00:09 +00:00
|
|
|
\( \
|
2006-08-11 23:51:05 +00:00
|
|
|
-name '*.ac' -o \
|
|
|
|
-name '*.b' -o \
|
|
|
|
-name '*.c' -o \
|
|
|
|
-name '*.cc' -o \
|
|
|
|
-name '*.cfg' -o \
|
2004-09-20 08:00:09 +00:00
|
|
|
-name '*.cpp' -o \
|
2006-08-11 23:51:05 +00:00
|
|
|
-name '*.css' -o \
|
2004-09-20 08:00:09 +00:00
|
|
|
-name '*.def' -o \
|
2006-08-11 23:51:05 +00:00
|
|
|
-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 \
|
2004-09-20 08:00:09 +00:00
|
|
|
-name '*.l' -o \
|
2006-08-11 23:51:05 +00:00
|
|
|
-name '*.ll' -o \
|
|
|
|
-name '*.llx' -o \
|
2004-09-20 08:00:09 +00:00
|
|
|
-name '*.lst' -o \
|
2006-08-11 23:51:05 +00:00
|
|
|
-name '*.m4' -o \
|
|
|
|
-name '*.pl' -o \
|
2004-09-20 08:00:09 +00:00
|
|
|
-name '*.pod' -o \
|
2006-08-11 23:51:05 +00:00
|
|
|
-name '*.py' -o \
|
|
|
|
-name '*.sh' -o \
|
|
|
|
-name '*.schema' -o \
|
|
|
|
-name '*.tcl' -o \
|
|
|
|
-name '*.td' -o \
|
|
|
|
-name '*.tr' -o \
|
2004-09-20 08:00:09 +00:00
|
|
|
-name '*.txt' -o \
|
|
|
|
-name '*.TXT' -o \
|
|
|
|
-name '*.tr' -o \
|
|
|
|
-name '*.vim' -o \
|
2006-08-11 23:51:05 +00:00
|
|
|
-name '*.y' -o \
|
2004-09-20 08:00:09 +00:00
|
|
|
-name 'Make*' -o \
|
|
|
|
-path 'test/*.ll' -o \
|
|
|
|
-path 'runtime/*.ll' \
|
|
|
|
\) \
|
2004-09-20 07:21:19 +00:00
|
|
|
\! -name '.*' \
|
2004-07-26 22:52:44 +00:00
|
|
|
\! -name '*~' \
|
|
|
|
\! -name '#*' \
|
2006-08-11 23:51:05 +00:00
|
|
|
\! -name '*.cvs' \
|
|
|
|
\! -name 'configure' \
|
|
|
|
\! -name 'slow.ll' \
|
|
|
|
\! -name '*libtool*' \
|
|
|
|
\! -name 'ltdl*' \
|
|
|
|
\! -name 'ltdl.m4' \
|
|
|
|
\! -name 'ltmain.m4' \
|
|
|
|
\! -name 'ltmain.sh' \
|
|
|
|
\! -name 'aclocal.m4' \
|
|
|
|
\! -name 'acinclude.m4' \
|
|
|
|
\! -name '*VerifierIsReallySlow.llx' \
|
|
|
|
\! -name '*LoopSimplifyCrash.ll' \
|
|
|
|
\! -name '*AST-Remove.ll' \
|
2004-07-26 22:52:44 +00:00
|
|
|
\! -name 'llvmAsmParser.cpp' \
|
|
|
|
\! -name 'llvmAsmParser.h' \
|
2006-01-19 22:01:51 +00:00
|
|
|
\! -name 'FileLexer.cpp' \
|
2004-07-26 22:52:44 +00:00
|
|
|
\! -name 'FileParser.cpp' \
|
|
|
|
\! -name 'FileParser.h' \
|
2004-09-20 07:21:19 +00:00
|
|
|
\! -name 'StackerParser.h' \
|
|
|
|
\! -name 'StackerParser.cpp' \
|
2006-01-19 22:01:51 +00:00
|
|
|
\! -name 'ConfigLexer.cpp' \
|
2006-04-17 00:46:09 +00:00
|
|
|
\! -name 'PPCPerfectShuffle.h' \
|
2004-10-08 17:59:29 +00:00
|
|
|
-exec $PROGRAM "$@" {} \; \
|
2004-09-20 07:21:19 +00:00
|
|
|
\)
|
2004-07-26 22:52:44 +00:00
|
|
|
else
|
|
|
|
echo "Can't find LLVM top directory in $TOPDIR"
|
|
|
|
fi
|