sniper          Tue Nov 29 18:20:07 2005 EDT

  Added files:                 (Branch: PHP_5_1)
    /php-src    Makefile.gcov 

  Modified files:              
    /php-src    NEWS configure.in 
  Log:
  MFH: - Added --enable-gcov configure option to enable C-level code coverage.
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2027.2.252&r2=1.2027.2.253&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.252 php-src/NEWS:1.2027.2.253
--- php-src/NEWS:1.2027.2.252   Tue Nov 29 15:43:52 2005
+++ php-src/NEWS        Tue Nov 29 18:19:55 2005
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 200?, PHP 5.1.2
+- Added --enable-gcov configure option to enable C-level code coverage.
+  (John, Jani)
 - Added missing support for 'B' format identifier to date() function. (Ilia)
 - Improved SPL: (Marcus)
   . Added class SplFileInfo as root class for DirectoryIterator and 
http://cvs.php.net/diff.php/php-src/configure.in?r1=1.579.2.24&r2=1.579.2.25&ty=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.579.2.24 php-src/configure.in:1.579.2.25
--- php-src/configure.in:1.579.2.24     Sun Nov 27 12:29:52 2005
+++ php-src/configure.in        Tue Nov 29 18:20:01 2005
@@ -1,4 +1,4 @@
- ## $Id: configure.in,v 1.579.2.24 2005/11/27 17:29:52 iliaa Exp $ -*- 
autoconf -*-
+ ## $Id: configure.in,v 1.579.2.25 2005/11/29 23:20:01 sniper Exp $ -*- 
autoconf -*-
 dnl ## Process this file with autoconf to produce a configure script.
 
 divert(1)
@@ -378,7 +378,8 @@
 utime.h \
 sys/utsname.h \
 sys/ipc.h \
-dlfcn.h
+dlfcn.h \
+assert.h
 ],[],[],[
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
@@ -597,6 +598,72 @@
 
 PHP_HELP_SEPARATOR([General settings:])
 
+PHP_ARG_ENABLE(gcov,  whether to include gcov symbols,
+[  --enable-gcov           Enable GCOV code coverage (requires LTP) - FOR 
DEVELOPERS ONLY!!], no, no)
+
+if test "$PHP_GCOV" = "yes"; then
+
+  if test "$GCC" != "yes"; then
+    AC_MSG_ERROR([GCC is required for --enable-gcov])
+  fi
+  
+  dnl Check if ccache is being used
+  dnl FIXME: Need a check for ccache usage, the one below does not work!
+  PHP_CHECK_GCC_ARG([--ccache-skip], [gcc_ccache=yes])
+  
+  if test "$gcc_ccache" = "yes"; then
+    if test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"; then
+      AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. 
You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
+    fi
+    lcov_target="lcov-ccache"
+  fi
+  
+  ltp_version_list="1.4"
+
+  AC_CHECK_PROG(LTP, lcov, lcov)
+  AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
+  PHP_SUBST(LTP)
+  PHP_SUBST(LTP_GENHTML)
+
+  if test "$LTP"; then
+    AC_CACHE_CHECK([for ltp version], php_cv_ltp_version, [
+      php_cv_ltp_version=invalid
+      ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
+      for ltp_check_version in $ltp_version_list; do
+        if test "$ltp_version" = "$ltp_check_version"; then
+          php_cv_ltp_version="$ltp_check_version (ok)"
+        fi
+      done
+    ])
+  else
+    ltp_msg="To enable code coverage reporting you must have one of the 
following LTP versions installed: $ltp_version_list"      
+    AC_MSG_ERROR([$ltp_msg])
+  fi
+
+  case $php_cv_ltp_version in
+    ""|invalid[)]
+      ltp_msg="You must have one of the following versions of LTP: 
$ltp_version_list (found: $ltp_version)."
+      AC_MSG_ERROR([$ltp_msg])
+      LTP="exit 0;"
+      ;;
+  esac
+
+  if test -z "$LTP_GENHTML"; then
+    AC_MSG_ERROR([Could not find genhtml from the LTP package])
+  fi
+
+  AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov])
+  PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Makefile.gcov, $abs_srcdir)
+
+  dnl Remove all optimization flags from CFLAGS
+  changequote({,})
+  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
+  changequote([,])
+
+  dnl Add the special gcc flags
+  CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
+fi
+
 PHP_ARG_ENABLE(debug, whether to include debugging symbols,
 [  --enable-debug          Compile with debugging symbols], no, no)
 
@@ -1180,7 +1247,7 @@
 INLINE_CFLAGS="$INLINE_CFLAGS $standard_libtool_flag"
 CXXFLAGS="$CXXFLAGS $standard_libtool_flag"
 
-all_targets='$(OVERALL_TARGET) $(PHP_MODULES) $(PHP_CLI_TARGET)'
+all_targets="$lcov_target \$(OVERALL_TARGET) \$(PHP_MODULES) 
\$(PHP_CLI_TARGET)"
 install_targets="$install_modules install-build install-headers 
install-programs $install_pear"
 
 case $PHP_SAPI in

http://cvs.php.net/co.php/php-src/Makefile.gcov?r=1.1&p=1
Index: php-src/Makefile.gcov
+++ php-src/Makefile.gcov
.php_cov_info.ltpdata:
        @mkdir -p .cov/; \
        find . -name \*.gcda -o -name \*.gcno | sed -e 's/^\.\/\.cov\/.*//' | 
xargs --replace cp {} .cov/; \
        find . -name \*.gcda -o -name \*.gcno | sed -e 's/^\.\/\.cov\/.*//' | 
sed -e 's/^\.\///' | xargs --max-args=1 dirname | sed -e 's/\/.*//' | xargs 
--replace ln -s `pwd`/{} `pwd`/.cov > /dev/null 2>&1; \
        $(LTP) --directory .cov --output-file=.php_cov_info.ltpdata --capture; \

cov: .php_cov_info.ltpdata

cov-html: cov 
        @$(LTP_GENHTML) -o cov_html/ .php_cov_info.ltpdata -t "PHP Code 
Coverage" -s;

cov-clean:
        find . -name \*.gcda -o -name \*.gcno -exec rm -f {} \;
        rm -f .cov/*      # This is done first, since we are symlinked inside..
        rm -Rf .cov       # Now remove the directory
        rm -f .php_cov_info.ltpdata
        rm -Rf cov_html

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to