Add option --enable-gcov to build GStreamer with -fprofile-arcs and -ftest-coverage...
authorDavid Schleef <ds@schleef.org>
Fri, 9 Jan 2004 01:42:11 +0000 (01:42 +0000)
committerDavid Schleef <ds@schleef.org>
Fri, 9 Jan 2004 01:42:11 +0000 (01:42 +0000)
Original commit message from CVS:
Add option --enable-gcov to build GStreamer with -fprofile-arcs
and -ftest-coverage, which allows gcov to show information about
testsuite coverage.

ChangeLog
Makefile.am
configure.ac

index e90df06..add1b8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-01-08  David Schleef  <ds@schleef.org>
+
+       * Makefile.am:
+       * configure.ac:
+       Add option --enable-gcov to build GStreamer with -fprofile-arcs
+       and -ftest-coverage, which allows gcov to show information about
+       testsuite coverage.
+
 2004-01-08  Benjamin Otte  <in7y118@public.uni-hamburg.de>
 
        * gst/gstutils.h:
index c3c43e5..244d02b 100644 (file)
@@ -50,6 +50,7 @@ EXTRA_DIST = gstreamer.spec.in gst-element-check.m4 \
 
 CLEANFILES = gst-element-check-@GST_MAJORMINOR@.m4
 
+
 dist-hook:
        cp gstreamer.spec $(distdir)
        rm -rf `find $(distdir)/common -name CVS`
@@ -59,3 +60,43 @@ rpm: dist
 
 include $(top_srcdir)/idiottest.mak
 
+
+if GST_GCOV_ENABLED
+clean-gcov:
+       find -name "*.da" -o -name "*.gcov" | xargs rm || true
+
+clean-bbg:
+       find -name "*.bbg" -o -name "*.bb" | xargs rm || true
+
+GCOV_DIRS=gst libs
+
+## .PHONY so it always rebuilds it
+.PHONY: coverage-report.txt
+coverage-report.txt:
+       BBG_FILES=`find $(GCOV_DIRS) -name "*.bbg"` ;                             \
+       C_FILES= ;                                                                \
+       for F in $$BBG_FILES ; do                                                 \
+               F_nolibs=`echo $$F | sed -e 's/.libs\///g'` ;                     \
+               C=`echo $$F_nolibs | sed -e 's/.bbg/.c/g'` ;                      \
+               B=`basename $$F .bbg` ;                                           \
+               D=`dirname $$F` ;                                                 \
+               DA=`echo $$F | sed -e 's/.bbg/.da/g'` ;                           \
+               DA_libs=`echo $$D/.libs/$$B/.da` ;                                \
+               if test -e $$DA || test -e $$DA_libs; then                        \
+                       C_FILES="$$C_FILES $$C" ;                                 \
+               fi ;                                                              \
+       done ;                                                                    \
+       echo $$C_FILES ;                                                          \
+       $(top_builddir)/testsuite/decode-gcov --report $$C_FILES > coverage-report.txt
+
+check-coverage: clean-gcov all check coverage-report.txt
+       cat coverage-report.txt
+
+else
+coverage-report.txt:
+       echo "Need to reconfigure with --enable-gcov"
+
+check-coverage:
+       echo "Need to reconfigure with --enable-gcov"
+
+endif
index f3b82b0..ac216e5 100644 (file)
@@ -161,6 +161,22 @@ if test x$HAVE_CPU_PPC = xyes ; then
     true)
 fi
 
+AC_ARG_ENABLE(gcov,
+  [--enable-gcov         compile with coverage profiling instrumentation (gcc only)],
+  enable_gcov=$enableval,enable_gcov=no)
+if test x$enable_gcov = xyes ; then
+  AS_COMPILER_FLAG(["-fprofile-arcs"],
+    [GST_INT_CFLAGS="$GST_INT_CFLAGS -fprofile-arcs"],
+    true)
+  AS_COMPILER_FLAG(["-ftest-coverage"],
+    [GST_INT_CFLAGS="$GST_INT_CFLAGS -ftest-coverage"],
+    true)
+  GST_INT_CFLAGS=`echo "$GST_INT_CFLAGS" | sed -e 's/-O[0-9]*//g'`
+
+  AC_DEFINE_UNQUOTED(GST_GCOV_ENABLED, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing])
+fi
+AM_CONDITIONAL(GST_GCOV_ENABLED, test x$enable_gcov = xyes)
+
 
 dnl Check for essential libraries first:
 dnl ====================================