llvm.org GIT mirror llvm / 65e731d
Added a tool to more accurately count the lines of code. The previous utility, getsrcs.sh suffered from two problems: (1) it generated command lines too long for some platforms and (2) it searched the projects diretory which now contains the llvm-test module (in nightly tester) but we don't want to include the test code in our LOC calculation. This script should be maintained as LLVM adds new top level directories that contain source code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16199 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 15 years ago
1 changed file(s) with 38 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 #!/bin/sh
1 ##===- utils/countloc.sh - Counts Lines Of Code --------------*- Script -*-===##
2 #
3 # The LLVM Compiler Infrastructure
4 #
5 # This file was developed by Reid Spencer and is distributed under the
6 # University of Illinois Open Source License. See LICENSE.TXT for details.
7 #
8 ##===----------------------------------------------------------------------===##
9 #
10 # This script finds all the source code files in the source code directories
11 # (excluding certain things), runs "wc -l" on them to get the number of lines in
12 # each file and then sums up and prints the total with awk.
13 #
14 # The script takes no arguments but does expect to be run from the top llvm
15 # source directory.
16 #
17 TOPDIR=`pwd | sed -e 's#(.*/llvm).*#$1#'`
18 if test -d "$TOPDIR" ; then
19 cd $TOPDIR
20 find include lib tools utils examples -type f -name '*.[cdhyltp]*' \
21 \! -name '*~' \
22 \! -name '#*' \
23 \! -name '*.ll' \
24 \! -name '*.d' \
25 \! -name '*.dir' \
26 \! -name 'Sparc.burm.c' \
27 \! -name 'llvmAsmParser.cpp' \
28 \! -name 'llvmAsmParser.h' \
29 \! -name 'FileParser.cpp' \
30 \! -name 'FileParser.h' \
31 -exec wc -l {} \; | awk '\
32 BEGIN { loc=0; } \
33 { loc += $1; } \
34 END { print loc; }'
35 else
36 echo "Can't find LLVM top directory in $TOPDIR"
37 fi