OSDN Git Service

android: update version in {config,llvm-config}.h headers
[android-x86/external-llvm.git] / utils / countloc.sh
1 #!/bin/sh
2 ##===- utils/countloc.sh - Counts Lines Of Code --------------*- Script -*-===##
3
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
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 one optional option, -topdir, which specifies the top llvm
15 # source directory. If it is not specified then the llvm-config tool is 
16 # consulted to find top source dir.  
17 #
18 # Note that the implementation is based on llvmdo. See that script for more
19 # details.
20 ##===----------------------------------------------------------------------===##
21
22 if test $# -gt 1 ; then
23   if test "$1" = "-topdir" ; then
24     TOPDIR="$2"
25     shift; shift;
26   else
27     TOPDIR=`llvm-config --src-root`
28   fi
29 fi
30
31 if test -d "$TOPDIR" ; then
32   cd $TOPDIR
33   ./utils/llvmdo -topdir "$TOPDIR" -dirs "include lib tools test utils examples" -code-only wc -l | awk '\
34       BEGIN { loc=0; } \
35       { loc += $1; } \
36       END { print loc; }'
37 else
38   echo "Can't find LLVM top directory"
39 fi