aboutsummaryrefslogtreecommitdiffstats
path: root/utils/countloc.sh
diff options
context:
space:
mode:
authorShih-wei Liao <sliao@google.com>2010-02-10 11:10:31 -0800
committerShih-wei Liao <sliao@google.com>2010-02-10 11:10:31 -0800
commite264f62ca09a8f65c87a46d562a4d0f9ec5d457e (patch)
tree59e3d57ef656cef79afa708ae0a3daf25cd91fcf /utils/countloc.sh
downloadexternal_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.zip
external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.tar.gz
external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.tar.bz2
Check in LLVM r95781.
Diffstat (limited to 'utils/countloc.sh')
-rwxr-xr-xutils/countloc.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/utils/countloc.sh b/utils/countloc.sh
new file mode 100755
index 0000000..4d1b775
--- /dev/null
+++ b/utils/countloc.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+##===- utils/countloc.sh - Counts Lines Of Code --------------*- Script -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+#
+# This script finds all the source code files in the source code directories
+# (excluding certain things), runs "wc -l" on them to get the number of lines in
+# each file and then sums up and prints the total with awk.
+#
+# The script takes one optional option, -topdir, which specifies the top llvm
+# source directory. If it is not specified then the llvm-config tool is
+# consulted to find top source dir.
+#
+# Note that the implementation is based on llvmdo. See that script for more
+# details.
+##===----------------------------------------------------------------------===##
+
+if test $# -gt 1 ; then
+ if test "$1" = "-topdir" ; then
+ TOPDIR="$2"
+ shift; shift;
+ else
+ TOPDIR=`llvm-config --src-root`
+ fi
+fi
+
+if test -d "$TOPDIR" ; then
+ cd $TOPDIR
+ ./utils/llvmdo -topdir "$TOPDIR" -dirs "include lib tools test utils examples" -code-only wc -l | awk '\
+ BEGIN { loc=0; } \
+ { loc += $1; } \
+ END { print loc; }'
+else
+ echo "Can't find LLVM top directory"
+fi