Reid Spencer | 2d67208 | 2004-06-19 20:32:55 +0000 | [diff] [blame] | 1 | #!/bin/sh |
Reid Spencer | 181e65d | 2004-09-20 08:09:36 +0000 | [diff] [blame] | 2 | ##===- utils/llvmgrep - Counts Lines Of Code -----------------*- Script -*-===## |
| 3 | # |
| 4 | # The LLVM Compiler Infrastructure |
| 5 | # |
Chris Lattner | 3060910 | 2007-12-29 20:37:13 +0000 | [diff] [blame] | 6 | # This file is distributed under the University of Illinois Open Source |
| 7 | # License. See LICENSE.TXT for details. |
Reid Spencer | 181e65d | 2004-09-20 08:09:36 +0000 | [diff] [blame] | 8 | # |
| 9 | ##===----------------------------------------------------------------------===## |
| 10 | # |
| 11 | # This script searches your srcdir for an egrep style pattern. This can quickly |
| 12 | # help you build a list of the places you need to modify when changing a header |
| 13 | # or other "global" name. The only argument is the pattern you want to search |
| 14 | # for. It should be quoted to escape shell interpretation of the pattern's |
| 15 | # special characters. |
| 16 | # |
| 17 | # Note that the implementation is based on llvmdo. See that script for more |
| 18 | # details. |
| 19 | ##===----------------------------------------------------------------------===## |
| 20 | |
Reid Spencer | 6ae928f | 2006-08-15 03:48:22 +0000 | [diff] [blame] | 21 | if test "$1" = "-topdir" ; then |
| 22 | TOPDIR="$2" |
| 23 | shift; shift; |
| 24 | else |
| 25 | TOPDIR=`llvm-config --src-root` |
Reid Spencer | ca7592a | 2006-08-14 18:49:05 +0000 | [diff] [blame] | 26 | fi |
| 27 | |
Reid Spencer | 2d67208 | 2004-06-19 20:32:55 +0000 | [diff] [blame] | 28 | if test -d "$TOPDIR" ; then |
| 29 | cd $TOPDIR |
Reid Spencer | 054defa | 2004-10-07 16:03:21 +0000 | [diff] [blame] | 30 | case `uname -s` in |
| 31 | SunOS) grep_cmd="ggrep -H -n" ;; |
Eric Christopher | f26475a | 2012-01-26 22:06:23 +0000 | [diff] [blame] | 32 | Linux|Darwin) grep_cmd="egrep -H -n" ;; |
Reid Spencer | 054defa | 2004-10-07 16:03:21 +0000 | [diff] [blame] | 33 | *) grep_cmd="egrep -l -n" ;; |
| 34 | esac |
Reid Spencer | ca7592a | 2006-08-14 18:49:05 +0000 | [diff] [blame] | 35 | ./utils/llvmdo -topdir "$TOPDIR" \ |
Chris Lattner | e8f6e79 | 2009-08-24 03:44:02 +0000 | [diff] [blame] | 36 | -dirs "include lib tools utils docs examples test unittests projects cmake" $grep_cmd "$*" |
Reid Spencer | 23a354d | 2004-07-07 21:19:01 +0000 | [diff] [blame] | 37 | else |
Reid Spencer | ca7592a | 2006-08-14 18:49:05 +0000 | [diff] [blame] | 38 | echo "Can't find LLVM top directory" |
Reid Spencer | 2d67208 | 2004-06-19 20:32:55 +0000 | [diff] [blame] | 39 | fi |