Clean up gcov integration a bit
authorJohan Dahlin <johan@src.gnome.org>
Sat, 9 Aug 2008 13:17:00 +0000 (13:17 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Sat, 9 Aug 2008 13:17:00 +0000 (13:17 +0000)
svn path=/trunk/; revision=342

Makefile.am
gcov.mak

index b761c60a44df2206b88910bfaacc6672c82eb6ba..d382d24b450c52fe037e62948046e1c1e94beb53 100644 (file)
@@ -1,47 +1,30 @@
 ## Process this file with automake to produce Makefile.in
-ACLOCAL_AMFLAGS = -I m4
+include $(top_srcdir)/gcov.mak
 
-SUBDIRS = gir girepository giscanner tools tests
-DIST_SUBDIRS = m4 $(SUBDIRS)
-man_MANS = docs/g-ir-scanner.1
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = gobject-introspection-1.0.pc
-EXTRA_DIST = $(pkgconfig_DATA)
+GCOVSOURCES =
 
 if GI_GCOV_ENABLED
 GCOV_DIRS = girepository tools
 
-clean-gcov:
-       find  -name "*.gcda" -o -name "*.gcov" -delete
-
-clean-gcno:
-       find  -name "*.gcno" -delete
-
-gcov-all:
-       @for dir in $(GCOV_DIRS); do \
-               cd $(abs_srcdir)/$$dir && \
-               for file in *.c; do \
-                       gcov -f -p -o `find $(abs_builddir)/$$dir -newer $$file -name "*-$${file/.c/.gcda}" -print0 | sed -e 's/\.gcda/\.o/'` $$file > /dev/null; \
-               done \
-       done
-
-coverage-report.txt: clean clean-gcov all check gcov-all
-       @rm  -f $(top_builddir)/coverage-report.txt
-       @echo -e "=== Coverage Report ===\n" >> $(top_builddir)/coverage-report.txt
-       @for dir in $(GCOV_DIRS); do \
-               echo "Module '$$dir':" >> $(top_builddir)/coverage-report.txt; \
-               $(MAKE) -C $$dir coverage-report; \
-       done
-
 check-coverage: coverage-report.txt
        @cat $(top_builddir)/coverage-report.txt
 
-.PHONEY: gcov-all coverage-report.txt
-
 else
 
 check-coverage:
-       @echo "Need to reconfigure with --enable-gcov"
+       @echo "ERROR: Need to reconfigure with --enable-gcov to run make check-coverage"
 
 endif
+
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = gir girepository giscanner tools tests
+DIST_SUBDIRS = m4 $(SUBDIRS)
+
+man_MANS = docs/g-ir-scanner.1
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = gobject-introspection-1.0.pc
+
+EXTRA_DIST = $(pkgconfig_DATA)
+
index e62d602ae53c09d64cc7bba9b9b2a1ad26e11aa9..b626a69242bc7c41d8f91d198bc79dbc50a50c8f 100644 (file)
--- a/gcov.mak
+++ b/gcov.mak
@@ -1,21 +1,45 @@
+# -*- Mode: makefile -*-
 if GI_GCOV_ENABLED
 
-.PHONEY: coverage-report
+clean-gcov:
+       find  -name "*.gcda" -o -name "*.gcov" -delete
+
+clean-gcno:
+       find  -name "*.gcno" -delete
+
+gcov-all:
+       @for dir in $(GCOV_DIRS); do \
+          cd $(abs_srcdir)/$$dir && \
+          for file in *.c; do \
+            gcov -f -p -o `find $(abs_builddir)/$$dir -newer $$file -name "*-$${file/.c/.gcda}" -print0 | sed -e 's/\.gcda/\.o/'` $$file > /dev/null; \
+          done \
+        done
+
+coverage-report.txt: clean clean-gcov all check gcov-all
+       @rm  -f $(top_builddir)/coverage-report.txt
+       @echo -e "=== Coverage Report ===\n" >> $(top_builddir)/coverage-report.txt
+       @for dir in $(GCOV_DIRS); do \
+         echo "Module '$$dir':" >> $(top_builddir)/coverage-report.txt; \
+         $(MAKE) -C $$dir coverage-report; \
+       done
+
 coverage-report:
        @total_covered=0; total_lines=0; \
        for file in $(GCOVSOURCES); do \
-               if test -f $$file.gcov; then \
-                       covered=`grep -e '[0-9]\+:' $$file.gcov | wc -l` ; \
-                       uncovered=`grep '#####:' $$file.gcov | wc -l`; \
-                       lines=$$(($$covered + $$uncovered)); \
-                       total_covered=$$((total_covered + covered)); \
-                       total_lines=$$((total_lines + lines)); \
-                       echo -n "    $$file: $$covered / $$lines"; \
-                       echo " ($$((($$covered * 100) / $$lines))%)"; \
-               fi \
+         if test -f $$file.gcov; then \
+           covered=`grep -e '[0-9]\+:' $$file.gcov | wc -l` ; \
+           uncovered=`grep '#####:' $$file.gcov | wc -l`; \
+           lines=$$(($$covered + $$uncovered)); \
+           total_covered=$$((total_covered + covered)); \
+           total_lines=$$((total_lines + lines)); \
+           echo -n "    $$file: $$covered / $$lines"; \
+           echo " ($$((($$covered * 100) / $$lines))%)"; \
+         fi \
        done >> $(top_builddir)/coverage-report.txt; \
        echo -e "  Total coverage:"\
-            "$$((($$total_covered * 100) / $$total_lines))%\n" \
-            >> $(top_builddir)/coverage-report.txt
+         "$$((($$total_covered * 100) / $$total_lines))%\n" \
+         >> $(top_builddir)/coverage-report.txt
+
+.PHONEY: coverage-report gcov-all coverage-report.txt
 
 endif