diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-02-05 12:49:53 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-02-05 19:18:33 +0100 |
commit | bea2b3c5177a9fae5df5598574bd25bca8f6cb09 (patch) | |
tree | eaa77fa73920e4042a0c4edabd7784e7a7c40b75 /pkgs/stdenv/adapters.nix | |
parent | 58a863268a8f4cb0b5e9ed7bf7cb00b164b576a8 (diff) |
addCoverageInstrumentation: Set NIX_CFLAGS_COMPILE as an attribute
This allows it to show up in nix-shell.
Diffstat (limited to 'pkgs/stdenv/adapters.nix')
-rw-r--r-- | pkgs/stdenv/adapters.nix | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index da4e0691e43e1..3bac534115490 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -231,8 +231,17 @@ rec { programs like lcov to produce pretty-printed reports. */ addCoverageInstrumentation = stdenv: - addAttrsToDerivation - { + # 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. + let stdenv' = cleanupBuildTree (keepBuildTree stdenv); in + { mkDerivation = args: stdenv'.mkDerivation (args // { + NIX_CFLAGS_COMPILE = toString (args.NIX_CFLAGS_COMPILE or "") + " -O0 --coverage"; postUnpack = '' # This is an uberhack to prevent libtool from removing gcno @@ -242,21 +251,9 @@ rec { for i in $(find -name ltmain.sh); do substituteInPlace $i --replace '*.$objext)' '*.$objext | *.gcno)' done - - export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -O0 --coverage" - ''; - } - - # 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. - (cleanupBuildTree (keepBuildTree stdenv)); + '' + args.postUnpack or ""; + }); + }; /* Replace the meta.maintainers field of a derivation. This is useful |