nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 20 lines 755 B view raw
1appendToVar postPhases cleanupBuildDir 2 3# Force GCC to build with coverage instrumentation. Also disable 4# optimisation, since it may confuse things. 5export NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE:-} -O0 --coverage" 6 7# Get rid of everything that isn't a gcno file or a C source file. 8# Also strip the `.tmp_' prefix from gcno files. (The Linux kernel 9# creates these.) 10cleanupBuildDir() { 11 if ! [ -e $out/.build ]; then return; fi 12 13 find $out/.build/ -type f -a ! \ 14 \( -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.hh" -o -name "*.y" -o -name "*.l" -o -name "*.gcno" \) \ 15 | xargs rm -f -- 16 17 for i in $(find $out/.build/ -name ".tmp_*.gcno"); do 18 mv "$i" "$(echo $i | sed s/.tmp_//)" 19 done 20}