[gjs] build: Use AX_CODE_COVERAGE macro



commit 46686ba2fd9dba71946a35cee1c4de2696670743
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Sep 27 23:17:36 2016 -0700

    build: Use AX_CODE_COVERAGE macro
    
    Instead of the homebrew stuff, use AX_CODE_COVERAGE from the Autoconf
    Archive. We do require a few extra options in order to include the
    coverage data for the JS files.
    
    See: https://wiki.gnome.org/Initiatives/GnomeGoals/ModernAutotools
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772027

 Makefile-test.am |   35 ++++++++---------------------------
 Makefile.am      |    5 +++--
 configure.ac     |   29 +++++++----------------------
 3 files changed, 18 insertions(+), 51 deletions(-)
---
diff --git a/Makefile-test.am b/Makefile-test.am
index ca4d23f..bd6beb4 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -126,35 +126,16 @@ TESTS_ENVIRONMENT =                                                       \
        G_FILENAME_ENCODING=latin1      # ensure filenames are not utf8 \
        DBUS_UUIDGEN="$(DBUS_UUIDGEN)"
 
-if ENABLE_COVERAGE
+if CODE_COVERAGE_ENABLED
 TESTS_ENVIRONMENT += \
        GJS_UNIT_COVERAGE_OUTPUT=lcov \
        GJS_UNIT_COVERAGE_PREFIX=resource:///org/gnome/gjs/
 endif
 
-########################################################################
-if ENABLE_COVERAGE
-lcov:
-       test -d lcov || mkdir lcov
-       $(LCOV) --compat-libtool --directory . --capture -o lcov/lcov_tmp.info
-       $(LCOV) --extract lcov/lcov_tmp.info "$(PWD)/*" -o lcov/lcov.info
-       rm -f lcov/lcov_tmp.info
-       $(GENHTML) --legend -o lcov lcov/lcov.info lcov/coverage.lcov
-
-lcov-clean:
-       find . -name '*.gcda' -delete
-       rm -rf lcov
-
-lcov-realclean: lcov-clean
-       find . -name '*.gcno' -delete
-
-clean-local: lcov-realclean
-
-.PHONY: lcov lcov-clean lcov-realclean
-else
-lcov:
-       @echo >&1 "*** ERROR: 'configure --enable-coverage' required"
-       @exit 1
-
-.PHONY: lcov
-endif
+CODE_COVERAGE_IGNORE_PATTERN = */include/*
+CODE_COVERAGE_GENHTML_OPTIONS =                        \
+       lcov/coverage.lcov                              \
+       --prefix $(abs_top_builddir)/lcov/org/gnome/gjs \
+       --prefix $(abs_top_builddir)                    \
+       $(NULL)
+@CODE_COVERAGE_RULES@
diff --git a/Makefile.am b/Makefile.am
index 86fffe6..68e7e34 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,8 +16,9 @@ check_PROGRAMS = $(TEST_PROGS)
 INTROSPECTION_GIRS =
 ## ACLOCAL_AMFLAGS can be removed for Automake 1.13
 ACLOCAL_AMFLAGS = -I m4
-AM_CXXFLAGS = $(WARN_CXXFLAGS)
-AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Gjs\"
+AM_CXXFLAGS = $(WARN_CXXFLAGS) $(CODE_COVERAGE_CFLAGS)
+AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Gjs\" $(CODE_COVERAGE_CPPFLAGS)
+AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
 MAINTAINERCLEANFILES =                                 \
        $(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL)      \
        $(GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN)   \
diff --git a/configure.ac b/configure.ac
index 8f7b777..a13bc89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,28 +41,12 @@ AC_PROG_SED
 
 GNOME_CXX_WARNINGS([maximum])
 
-# coverage
-AC_ARG_ENABLE([coverage],
-              [AS_HELP_STRING([--enable-coverage],
-                              [enable code coverage])],
-              , [enable_coverage=no])
-if test x$enable_coverage = xyes; then
-    if test x$GCC != xyes; then
-        AC_MSG_ERROR([GCC is required for --enable-coverage])
-    fi
-
-    AC_PATH_TOOL([LCOV], [lcov])
-    AC_PATH_TOOL([GENHTML], [genhtml])
-
-    if test x$LCOV = x || test x$GENHTML = x; then
-        AC_MSG_ERROR([lcov and genhtml are required for --enable-coverage])
-    fi
-
-    CFLAGS="$CFLAGS -g -O0 --coverage"
-    CXXFLAGS="$CXXFLAGS -g -O0 --coverage"
-    LIBS="$LIBS -lgcov"
-fi
-AM_CONDITIONAL([ENABLE_COVERAGE], [test x$enable_coverage = xyes])
+AX_CODE_COVERAGE
+dnl Clang does not need to link with -lgcov
+AX_CHECK_LINK_FLAG([-lgcov],, [
+       CODE_COVERAGE_LIBS=
+       CODE_COVERAGE_LDFLAGS=
+])
 
 # Checks for libraries.
 m4_define(glib_required_version, 2.42.0)
@@ -243,4 +227,5 @@ AC_MSG_RESULT([
        dtrace:                 ${enable_dtrace:-no}
        systemtap:              ${enable_systemtap:-no}
        Run tests under:        ${TEST_MSG}
+       Code coverage:          ${enable_code_coverage}
 ])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]