mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
* A stdenv adapter to build a package with coverage instrumentation.
svn path=/nixpkgs/trunk/; revision=16890
This commit is contained in:
parent
df5cd8776a
commit
0fd5ed507e
@ -121,4 +121,54 @@ rec {
|
||||
{ mkDerivation = args: stdenv.mkDerivation (args // extraAttrs); };
|
||||
|
||||
|
||||
/* Return a modified stdenv that builds packages with GCC's coverage
|
||||
instrumentation. The coverage note files (*.gcno) are stored in
|
||||
$out/.coverage, along with the source code of the package, to
|
||||
enable programs like lcov to produce pretty-printed reports.
|
||||
*/
|
||||
addCoverageInstrumentation = stdenv:
|
||||
addAttrsToDerivation
|
||||
{ NIX_CFLAGS_COMPILE = "-O0 --coverage";
|
||||
|
||||
prePhases = "moveBuildDir";
|
||||
postPhases = "cleanupBuildDir";
|
||||
|
||||
# Object files instrumented with coverage analysis write
|
||||
# runtime coverage data to <path>/<object>.gcda, where <path>
|
||||
# is the location where gcc originally created the object
|
||||
# file. That would be /tmp/nix-build-<something>, which will
|
||||
# be long gone by the time we run the program. Furthermore,
|
||||
# the <object>.gcno files created at compile time are also
|
||||
# written there. And to make nice coverage reports with lcov,
|
||||
# we need the source code. So we move the whole build tree to
|
||||
# $out/.coverage.
|
||||
moveBuildDir =
|
||||
''
|
||||
ensureDir $out/.coverage
|
||||
cd $out/.coverage
|
||||
'';
|
||||
|
||||
# This is an uberhack to prevent libtool from removing gcno
|
||||
# files. This has been fixed in libtool, but there are
|
||||
# packages out there with old ltmain.sh scripts.
|
||||
# See http://www.mail-archive.com/libtool@gnu.org/msg10725.html
|
||||
postUnpack =
|
||||
''
|
||||
for i in $(find -name ltmain.sh); do
|
||||
substituteInPlace $i --replace '*.$objext)' '*.$objext | *.gcno)'
|
||||
done
|
||||
'';
|
||||
|
||||
# Get rid of everything that isn't a gcno file or a C source
|
||||
# file. This also includes the gcda files; we're not
|
||||
# interested in coverage resulting from the package's own test
|
||||
# suite.
|
||||
cleanupBuildDir =
|
||||
''
|
||||
find $out/.coverage/ -type f -a ! \
|
||||
\( -name "*.c" -o -name "*.gcno" -o -name "*.h" \) \
|
||||
| xargs rm -f --
|
||||
'';
|
||||
}
|
||||
stdenv;
|
||||
}
|
||||
|
@ -226,7 +226,8 @@ let
|
||||
|
||||
inherit (import ../stdenv/adapters.nix {inherit (pkgs) dietlibc fetchurl runCommand;})
|
||||
overrideGCC overrideInStdenv overrideSetup
|
||||
useDietLibC useKlibc makeStaticBinaries;
|
||||
useDietLibC useKlibc makeStaticBinaries addAttrsToDerivation
|
||||
addCoverageInstrumentation;
|
||||
|
||||
|
||||
### BUILD SUPPORT
|
||||
@ -2771,11 +2772,11 @@ let
|
||||
inherit (xlibs) libX11;
|
||||
};
|
||||
|
||||
apr = import ../development/libraries/apr {
|
||||
apr = makeOverridable (import ../development/libraries/apr) {
|
||||
inherit fetchurl stdenv;
|
||||
};
|
||||
|
||||
aprutil = import ../development/libraries/apr-util {
|
||||
aprutil = makeOverridable (import ../development/libraries/apr-util) {
|
||||
inherit fetchurl stdenv apr expat db4;
|
||||
bdbSupport = true;
|
||||
};
|
||||
@ -2802,7 +2803,7 @@ let
|
||||
inherit fetchurl stdenv;
|
||||
});
|
||||
|
||||
aterm25 = import ../development/libraries/aterm/2.5.nix {
|
||||
aterm25 = makeOverridable (import ../development/libraries/aterm/2.5.nix) {
|
||||
inherit fetchurl stdenv;
|
||||
};
|
||||
|
||||
@ -4500,7 +4501,7 @@ let
|
||||
### SERVERS
|
||||
|
||||
|
||||
apacheHttpd = import ../servers/http/apache-httpd {
|
||||
apacheHttpd = makeOverridable (import ../servers/http/apache-httpd) {
|
||||
inherit fetchurl stdenv perl openssl zlib apr aprutil pcre;
|
||||
sslSupport = true;
|
||||
};
|
||||
@ -6613,7 +6614,7 @@ let
|
||||
inherit fetchurl stdenv Xaw3d ghostscriptX;
|
||||
};
|
||||
|
||||
hello = import ../applications/misc/hello/ex-2 {
|
||||
hello = makeOverridable (import ../applications/misc/hello/ex-2) {
|
||||
inherit fetchurl stdenv;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user