diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-09-01 21:56:46 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-09-01 21:56:46 +0000 |
commit | 58e61617682239f5d20320066b1a79de127bcc61 (patch) | |
tree | 9d823bb53fe62c826937eee30731bec01dda3a8a /pkgs/stdenv | |
parent | 043fe38f80db59dbc0d6283575892ea06a4b55c5 (diff) |
* addCoverageInstrumentation: factor out the code that keeps the build
tree under $out into a separate stdenv adapter named keepBuildTree. * makeModulesClosure: support building an initrd for a kernel that has been compiled with coverage instrumentation. svn path=/nixpkgs/trunk/; revision=16916
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/adapters.nix | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 621aef466aa3a..92970b1c51f1a 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -121,33 +121,33 @@ rec { { mkDerivation = args: stdenv.mkDerivation (args // extraAttrs); }; + /* Return a modified stdenv that perfoms the build under $out/.build + instead of in $TMPDIR. Thus, the sources are kept available. + This is useful for things like debugging or generation of + dynamic analysis reports. */ + keepBuildTree = stdenv: + addAttrsToDerivation + { prePhases = "moveBuildDir"; + + moveBuildDir = + '' + ensureDir $out/.build + cd $out/.build + ''; + } stdenv; + + /* 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. + $out/.build, 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. @@ -165,10 +165,21 @@ rec { # suite. cleanupBuildDir = '' - find $out/.coverage/ -type f -a ! \ - \( -name "*.c" -o -name "*.gcno" -o -name "*.h" \) \ - | xargs rm -f -- + find $out/.build/ -type f -a ! \ + \( -name "*.c" -o -name "*.gcno" -o -name "*.h" \) \ + | xargs rm -f -- ''; } - stdenv; + + # 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 have to use the + # `keepBuildTree' adapter as well. + (keepBuildTree stdenv); + } |