lol
1postPhases+=" 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# FIXME: Handle the case where postUnpack is already set.
8postUnpack() {
9 # This is an uberhack to prevent libtool from remoaving gcno
10 # files. This has been fixed in libtool, but there are packages
11 # out there with old ltmain.sh scripts. See
12 # http://www.mail-archive.com/libtool@gnu.org/msg10725.html
13 for i in $(find -name ltmain.sh); do
14 substituteInPlace $i --replace '*.$objext)' '*.$objext | *.gcno)'
15 done
16}
17
18# Get rid of everything that isn't a gcno file or a C source file.
19# Also strip the `.tmp_' prefix from gcno files. (The Linux kernel
20# creates these.)
21cleanupBuildDir() {
22 if ! [ -e $out/.build ]; then return; fi
23
24 find $out/.build/ -type f -a ! \
25 \( -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.hh" -o -name "*.y" -o -name "*.l" -o -name "*.gcno" \) \
26 | xargs rm -f --
27
28 for i in $(find $out/.build/ -name ".tmp_*.gcno"); do
29 mv "$i" "$(echo $i | sed s/.tmp_//)"
30 done
31}