1*9880d681SAndroid Build Coastguard Worker#!/bin/sh 2*9880d681SAndroid Build Coastguard Worker##===- utils/llvmgrep - Counts Lines Of Code -----------------*- Script -*-===## 3*9880d681SAndroid Build Coastguard Worker# 4*9880d681SAndroid Build Coastguard Worker# The LLVM Compiler Infrastructure 5*9880d681SAndroid Build Coastguard Worker# 6*9880d681SAndroid Build Coastguard Worker# This file is distributed under the University of Illinois Open Source 7*9880d681SAndroid Build Coastguard Worker# License. See LICENSE.TXT for details. 8*9880d681SAndroid Build Coastguard Worker# 9*9880d681SAndroid Build Coastguard Worker##===----------------------------------------------------------------------===## 10*9880d681SAndroid Build Coastguard Worker# 11*9880d681SAndroid Build Coastguard Worker# This script searches your srcdir for an egrep style pattern. This can quickly 12*9880d681SAndroid Build Coastguard Worker# help you build a list of the places you need to modify when changing a header 13*9880d681SAndroid Build Coastguard Worker# or other "global" name. The only argument is the pattern you want to search 14*9880d681SAndroid Build Coastguard Worker# for. It should be quoted to escape shell interpretation of the pattern's 15*9880d681SAndroid Build Coastguard Worker# special characters. 16*9880d681SAndroid Build Coastguard Worker# 17*9880d681SAndroid Build Coastguard Worker# Note that the implementation is based on llvmdo. See that script for more 18*9880d681SAndroid Build Coastguard Worker# details. 19*9880d681SAndroid Build Coastguard Worker##===----------------------------------------------------------------------===## 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workerif test "$1" = "-topdir" ; then 22*9880d681SAndroid Build Coastguard Worker TOPDIR="$2" 23*9880d681SAndroid Build Coastguard Worker shift; shift; 24*9880d681SAndroid Build Coastguard Workerelse 25*9880d681SAndroid Build Coastguard Worker TOPDIR=`llvm-config --src-root` 26*9880d681SAndroid Build Coastguard Workerfi 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Workerif test -d "$TOPDIR" ; then 29*9880d681SAndroid Build Coastguard Worker cd $TOPDIR 30*9880d681SAndroid Build Coastguard Worker case `uname -s` in 31*9880d681SAndroid Build Coastguard Worker SunOS) grep_cmd="ggrep -H -n" ;; 32*9880d681SAndroid Build Coastguard Worker Linux|Darwin) grep_cmd="egrep -H -n" ;; 33*9880d681SAndroid Build Coastguard Worker *) grep_cmd="egrep -l -n" ;; 34*9880d681SAndroid Build Coastguard Worker esac 35*9880d681SAndroid Build Coastguard Worker ./utils/llvmdo -topdir "$TOPDIR" \ 36*9880d681SAndroid Build Coastguard Worker -dirs "include lib tools utils docs examples test unittests projects cmake" $grep_cmd "$*" 37*9880d681SAndroid Build Coastguard Workerelse 38*9880d681SAndroid Build Coastguard Worker echo "Can't find LLVM top directory" 39*9880d681SAndroid Build Coastguard Workerfi 40