about summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-03-03 13:39:30 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-03-03 13:57:08 +0100
commit497997cc388ce791ca0b4dc55f46ab515e8fb5d9 (patch)
tree867053bb31858180d2b439d1c63c610c58be54ee /pkgs/build-support/setup-hooks
parentad7c518e45221533e2094acb20fea6ade477da75 (diff)
Move generation of coverage reports from nixos/lib/testing to releaseTools
Also, turn some stdenv adapters into setup hooks.
Diffstat (limited to 'pkgs/build-support/setup-hooks')
-rw-r--r--pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh17
-rw-r--r--pkgs/build-support/setup-hooks/keep-build-tree.sh6
2 files changed, 23 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh b/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh
index 08ef490e24474..7175b408b02fd 100644
--- a/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh
+++ b/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh
@@ -1,3 +1,5 @@
+postPhases+=" cleanupBuildDir"
+
 # Force GCC to build with coverage instrumentation.  Also disable
 # optimisation, since it may confuse things.
 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -O0 --coverage"
@@ -12,3 +14,18 @@ postUnpack() {
         substituteInPlace $i --replace '*.$objext)' '*.$objext | *.gcno)'
     done
 }
+
+# Get rid of everything that isn't a gcno file or a C source file.
+# Also strip the `.tmp_' prefix from gcno files.  (The Linux kernel
+# creates these.)
+cleanupBuildDir() {
+    if ! [ -e $out/.build ]; then return; fi
+
+    find $out/.build/ -type f -a ! \
+        \( -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.hh" -o -name "*.y" -o -name "*.l" -o -name "*.gcno" \) \
+        | xargs rm -f --
+
+    for i in $(find $out/.build/ -name ".tmp_*.gcno"); do
+        mv "$i" "$(echo $i | sed s/.tmp_//)"
+    done
+}
diff --git a/pkgs/build-support/setup-hooks/keep-build-tree.sh b/pkgs/build-support/setup-hooks/keep-build-tree.sh
new file mode 100644
index 0000000000000..754900bfc337a
--- /dev/null
+++ b/pkgs/build-support/setup-hooks/keep-build-tree.sh
@@ -0,0 +1,6 @@
+prePhases+=" moveBuildDir"
+
+moveBuildDir() {
+    mkdir -p $out/.build
+    cd $out/.build
+}