blob: 75a61549716b26a74b0f15a247f5670f208c4088 [file] [log] [blame]
Reid Spencer65e731d2004-09-06 19:06:27 +00001#!/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#
15# The script takes no arguments but does expect to be run from the top llvm
16# source directory.
17#
18TOPDIR=`pwd | sed -e 's#(.*/llvm).*#$1#'`
19if test -d "$TOPDIR" ; then
20 cd $TOPDIR
21 find include lib tools utils examples -type f -name '*.[cdhyltp]*' \
22 \! -name '*~' \
23 \! -name '#*' \
24 \! -name '*.ll' \
Chris Lattner2ac3f192004-09-20 05:01:04 +000025 \! -name '*.lo' \
Reid Spencer65e731d2004-09-06 19:06:27 +000026 \! -name '*.d' \
27 \! -name '*.dir' \
28 \! -name 'Sparc.burm.c' \
29 \! -name 'llvmAsmParser.cpp' \
30 \! -name 'llvmAsmParser.h' \
31 \! -name 'FileParser.cpp' \
32 \! -name 'FileParser.h' \
33 -exec wc -l {} \; | awk '\
34 BEGIN { loc=0; } \
35 { loc += $1; } \
36 END { print loc; }'
37else
38 echo "Can't find LLVM top directory in $TOPDIR"
39fi