2 ##===- utils/countloc.sh - Counts Lines Of Code --------------*- Script -*-===##
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
8 ##===----------------------------------------------------------------------===##
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.
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.
18 # Note that the implementation is based on llvmdo. See that script for more
20 ##===----------------------------------------------------------------------===##
22 if test $# -gt 1 ; then
23 if test "$1" = "-topdir" ; then
27 TOPDIR
=`llvm-config --src-root`
31 if test -d "$TOPDIR" ; then
33 .
/utils
/llvmdo
-topdir "$TOPDIR" -dirs "include lib tools test utils examples" -code-only wc -l |
awk '\
38 echo "Can't find LLVM top directory"