2 ##===- utils/llvmdo - Counts Lines Of Code -------------------*- Script -*-===##
4 # The LLVM Compiler Infrastructure
6 # This file was developed by Reid Spencer and is distributed under the
7 # University of Illinois Open Source License. See LICENSE.TXT for details.
9 ##===----------------------------------------------------------------------===##
11 # This script is a general purpose "apply" function for the source files in LLVM
12 # It uses "find" to locate all the source files and then applies the user's
13 # command to them. As such, this command is often not used by itself much but
14 # the other find related tools (countloc.sh,llvmgrep,getsrcs.sh) are all based
15 # on the implementation. This script defines "what is a source file" in LLVM and
16 # so should be maintained if new directories, new file extensions, etc. are
17 # used in LLVM as it progresses.
20 # llvmdo [-dirs "DIRNAMES..."] PROGRAM ARGS...
22 # The -dirs argument allows you to specify the set of directories that are
23 # searched. By default, everything is searched. Note that you must use quotes
24 # around the list of directory names. After that you simply specify whatever
25 # program you want to run against each file and the arguments to give it. The
26 # PROGRAM will be given the file name as its last argument.
27 ##===----------------------------------------------------------------------===##
29 if test $# -lt 1 ; then
30 echo "Usage: llvmdo [-dirs "DIRNAMES..."] [-code-only] PROGRAM ARGS..."
34 if test "$1" = "-dirs" ; then
37 elif test -z "$LLVMDO_DIRS" ; then
38 LLVMDO_DIRS="include lib tools utils runtime autoconf docs test examples projects"
41 if test "$1" = "-code-only" ; then
48 if test "$1" = "" ; then
49 echo "Missing program name to run"
54 if test ! -x "$PROGRAM" ; then
55 echo "Can't execute $1"
60 TOPDIR=`llvm-config --src-root`
62 if test -d "$TOPDIR" ; then
65 SunOS) find_prog=gfind ;;
71 -path docs/doxygen/* -o \
72 -path docs/CommandGuide/html/* -o \
73 -path docs/CommandGuide/man/* -o \
74 -path docs/CommandGuide/ps/* -o \
75 -path docs/CommandGuide/man/* -o \
76 -path docs/HistoricalNotes/* -o \
79 -path lib/Support/bzip2/* -o \
80 -path projects/llvm-test/* \
119 -o -name check-each-file \
120 -o -name codgen-diff \
122 -o -name llvm-native-gcc \
123 -o -name llvm-native-gxx \
125 -o -path include/llvm/ADT/ilist \
126 -o -path test/\*.ll \
127 -o -path test/Scripts/not \
128 -o -path runtime/\*.ll \
130 if test -z "$CODE_ONLY" ; then
131 files_to_match="$files_to_match \
137 -o -name COPYING.LIB \
152 -o -name aclocal.m4 \
153 -o -name acinclude.m4 \
154 -o -name *VerifierIsReallySlow.llx \
155 -o -name *LoopSimplifyCrash.ll \
156 -o -name *AST-Remove.ll \
157 -o -name llvmAsmParser.cpp \
158 -o -name llvmAsmParser.h \
160 -o -name FileLexer.cpp \
161 -o -name FileParser.cpp \
162 -o -name FileParser.h \
163 -o -name StackerParser.h \
164 -o -name StackerParser.cpp \
165 -o -name ConfigLexer.cpp \
166 -o -name PPCPerfectShuffle.h \
169 # Turn off file name generation (globbing) so that substitution of the
170 # variables doesn't cause the shell to create lists of file names
172 $find_prog $LLVMDO_DIRS -type f \
173 \( $paths_to_ignore \) -prune \
174 -o \( \( $files_to_match \) \! \( $files_to_ignore \) \
175 -exec $PROGRAM "$@" {} \; \)
177 echo "Can't find LLVM top directory in $TOPDIR"