util/release: Don't wildly rename Makefiles

Even with four cloc invocations it's faster than doing the rename
dance and messes up the tree less. It also opens up using cloc's git
mode to work on a git tree instead of a checkout.

Change-Id: I3ad8fc6802ecedb332359d00b28ea61c33ed2ea0
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/37023
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Patrick Georgi 2019-11-20 17:15:13 +01:00
parent 1916d68ee3
commit 436296b9bd
1 changed files with 21 additions and 6 deletions

View File

@ -226,14 +226,29 @@ show_diff () {
get_sloc () {
# Because cloc works on extensions, and .inc identifies as pascal,
# rename Makefile.inc, then remap the other .inc files to c
find 'src' -name 'Makefile.inc' -exec rename 's/Makefile\.inc/gnumakefile/' {} \;
# while we use it both for Makefile.inc and some files that are
# really C, do three passes: everything but .inc files, all .inc files
# that aren't Makefiles, all Makefile.inc, then combine them.
cloc --progress-rate=0 --quiet --script-lang="Bourne Shell",bash \
--force-lang=c,inc --exclude-dir=vendorcode src
local base=`mktemp`
find src -name Makefile.inc > ${base}.mak
# Change all the makefiles back to Makefile.inc
find 'src' -name 'gnumakefile' -exec rename 's/gnumakefile/Makefile\.inc/' {} \;
cloc --progress-rate=0 --quiet \
--script-lang="Bourne Shell",bash --exclude-ext=inc \
--exclude-dir=vendorcode --out=${base} src
cloc --progress-rate=0 --quiet \
--exclude-list-file=${base}.mak --force-lang=c,inc \
--exclude-dir=vendorcode --out=${base}.c src
cloc --progress-rate=0 --quiet \
--list-file=${base}.mak --force-lang=make,inc \
--exclude-dir=vendorcode --out=${base}.m src
cloc --progress-rate=0 --quiet --sum-reports \
${base} ${base}.c ${base}.m --out ${base}.result
echo
cat ${base}.result.lang
rm -f ${base}*
}
# Start collecting data from the old and new revisions.