blob: cc67afe0336c685301030d1b82ecf4989b0855e6 [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#
Reid Spencerb27b78f2004-09-20 07:22:23 +000018TOPDIR=`pwd | sed -e 's#\(.*/llvm\).*#\1#'`
Reid Spencer65e731d2004-09-06 19:06:27 +000019if test -d "$TOPDIR" ; then
20 cd $TOPDIR
Reid Spencerb27b78f2004-09-20 07:22:23 +000021 ./utils/llvmdo -dirs "include lib tools test utils examples" wc -l | awk '\
Reid Spencer65e731d2004-09-06 19:06:27 +000022 BEGIN { loc=0; } \
23 { loc += $1; } \
24 END { print loc; }'
25else
26 echo "Can't find LLVM top directory in $TOPDIR"
27fi