Reid Spencer | 65e731d | 2004-09-06 19:06:27 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | ##===- utils/countloc.sh - Counts Lines Of Code --------------*- Script -*-===## |
| 3 | # |
| 4 | # The LLVM Compiler Infrastructure |
| 5 | # |
| 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. |
| 8 | # |
| 9 | ##===----------------------------------------------------------------------===## |
| 10 | # |
| 11 | # This script finds all the source code files in the source code directories |
| 12 | # (excluding certain things), runs "wc -l" on them to get the number of lines in |
| 13 | # each file and then sums up and prints the total with awk. |
| 14 | # |
Reid Spencer | 181e65d | 2004-09-20 08:09:36 +0000 | [diff] [blame] | 15 | # The script takes no arguments but does expect to be run from somewhere in |
| 16 | # the top llvm source directory. |
Reid Spencer | 65e731d | 2004-09-06 19:06:27 +0000 | [diff] [blame] | 17 | # |
Reid Spencer | 181e65d | 2004-09-20 08:09:36 +0000 | [diff] [blame] | 18 | # Note that the implementation is based on llvmdo. See that script for more |
| 19 | # details. |
| 20 | ##===----------------------------------------------------------------------===## |
| 21 | |
Reid Spencer | b27b78f | 2004-09-20 07:22:23 +0000 | [diff] [blame] | 22 | TOPDIR=`pwd | sed -e 's#\(.*/llvm\).*#\1#'` |
Reid Spencer | 65e731d | 2004-09-06 19:06:27 +0000 | [diff] [blame] | 23 | if test -d "$TOPDIR" ; then |
| 24 | cd $TOPDIR |
Reid Spencer | b27b78f | 2004-09-20 07:22:23 +0000 | [diff] [blame] | 25 | ./utils/llvmdo -dirs "include lib tools test utils examples" wc -l | awk '\ |
Reid Spencer | 65e731d | 2004-09-06 19:06:27 +0000 | [diff] [blame] | 26 | BEGIN { loc=0; } \ |
| 27 | { loc += $1; } \ |
| 28 | END { print loc; }' |
| 29 | else |
| 30 | echo "Can't find LLVM top directory in $TOPDIR" |
| 31 | fi |