From 5778fa9c36d9dcf851fa268b20eec4358ae1787a Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sat, 18 Apr 2020 07:32:04 +1000 Subject: 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 --- Makefile.in | 16 +++++++++++++--- auto.def | 13 +++++++++---- 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" -- cgit v1.1