aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-04-18 07:32:04 +1000
committerSteve Bennett <steveb@workware.net.au>2020-05-04 20:37:28 +1000
commit5778fa9c36d9dcf851fa268b20eec4358ae1787a (patch)
tree3d3e42193a03b3e236c77dad13ca51ab930bc2c8
parentbda1bd90a560b5dafb39e0823899d157c6d91e0d (diff)
downloadjimtcl-5778fa9c36d9dcf851fa268b20eec4358ae1787a.zip
jimtcl-5778fa9c36d9dcf851fa268b20eec4358ae1787a.tar.gz
jimtcl-5778fa9c36d9dcf851fa268b20eec4358ae1787a.tar.bz2
build: Improve coverage support
Disable optimisation during coverage. Set CCACHE_DISABLE=1 in the environment, just to be sure to disable ccache Also cleanup coverage files in subdirs too Add support for both lcov and gcovr Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--Makefile.in16
-rw-r--r--auto.def13
2 files changed, 22 insertions, 7 deletions
diff --git a/Makefile.in b/Makefile.in
index b299c1a..1207b0f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -19,6 +19,9 @@ CXX = @CCACHE@ @CXX@
RANLIB = @RANLIB@
AR = @AR@
STRIP = @STRIP@
+@if COVERAGE
+export CCACHE_DISABLE := 1
+@endif
# Configuration
@@ -184,9 +187,15 @@ Tcl.html: jim_tcl.txt @srcdir@/make-index
coverage:
@if COVERAGE
-@if GCOVR
+@if COVERAGE_TOOL eq "lcov"
+ @LCOV@ -c --rc genhtml_branch_coverage=1 -d . -o lcov.txt
+ @GENHTML@ --rc genhtml_branch_coverage=1 -o coverage_html lcov.txt > genhtml_output.txt
+ @LCOV@ --summary lcov.txt
+@endif
+@if COVERAGE_TOOL eq "gcovr"
@GCOVR@ -s -e 'conftest*' --html --html-details --output coverage.html
-@else
+@endif
+@if COVERAGE_TOOL eq "gcov"
gcov @srcdir@/*.c
@endif
@else
@@ -196,7 +205,8 @@ coverage:
clean:
rm -f *.o *.so *.dll *.exe lib*.a $(JIMSH) $(LIBJIM) Tcl.html _*.c
@if COVERAGE
- rm -f *.gcno *.gcov *.gcda coverage*.html
+ rm -f *.gcno *.gcov *.gcda */*.gcno */*.gcda */*.gcov coverage*.html
+ rm -rf coverage_html lcov.txt genhtml_output.txt
@endif
distclean: clean
diff --git a/auto.def b/auto.def
index 7693e13..4a891de 100644
--- a/auto.def
+++ b/auto.def
@@ -103,13 +103,18 @@ if {[cctest -cflags -fno-asynchronous-unwind-tables]} {
}
if {[opt-bool coverage]} {
if {[cctest -link 1 -cflags --coverage]} {
- # Disable ccache when using coverage
+ # When using coverage, disable ccache and compiler optimisation
define CCACHE ""
- define-append CCOPTS --coverage
+ define-append CCOPTS --coverage -O0
define-append LDFLAGS --coverage
define COVERAGE 1
- if {![cc-check-progs gcovr]} {
- lappend warnings "Note: gcovr is not available, falling back to gcov"
+ if {[cc-check-progs gcovr]} {
+ define COVERAGE_TOOL gcovr
+ } elseif {[cc-check-progs lcov] && [cc-check-progs genhtml]} {
+ define COVERAGE_TOOL lcov
+ } else {
+ define COVERAGE_TOOL gcov
+ lappend warnings "Note: Neither lcov nor gcovr is available, falling back to gcov"
}
} else {
lappend warnings "Warning: --coverage specified, but compiler does not support --coverage"