summaryrefslogtreecommitdiff
path: root/scripts/find-gcovinfo.sh
diff options
context:
space:
mode:
authorPavel Kopyl <p.kopyl@samsung.com>2018-01-30 00:22:53 +0300
committerPavel Kopyl <p.kopyl@samsung.com>2018-01-31 15:46:45 +0300
commitdaf747e092b4a14c5c0f44fc5eaa34b1ce38c89e (patch)
treee4cfb271b032282d95717a53a59b16832e7d1b8e /scripts/find-gcovinfo.sh
parentc6cd28984ab2ca8fc08c59ccac9d5aa7cab7c404 (diff)
downloadrpm-sandbox/pavelkopyl/gcov.tar.gz
rpm-sandbox/pavelkopyl/gcov.tar.bz2
rpm-sandbox/pavelkopyl/gcov.zip
Generate gcovinfo package.sandbox/pavelkopyl/gcov
Diffstat (limited to 'scripts/find-gcovinfo.sh')
-rw-r--r--scripts/find-gcovinfo.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/find-gcovinfo.sh b/scripts/find-gcovinfo.sh
new file mode 100644
index 000000000..6dc3e9227
--- /dev/null
+++ b/scripts/find-gcovinfo.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+set -xe
+#find-debuginfo.sh - automagically generate collects gcov info(*.gcno files) and file list
+#for inclusion in an rpm spec file.
+#
+# Usage: find-debuginfo.sh [-o gcnofiles.list] [builddir]
+#
+BUILDDIR=.
+out=gcnofiles.list
+nout=0
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -o)
+ out=$2
+ shift
+ ;;
+ *)
+ BUILDDIR=$1
+ shift
+ break
+ ;;
+ esac
+ shift
+done
+
+LISTFILE="$BUILDDIR/$out"
+
+> "$LISTFILE"
+
+BUILDDIR=${BUILDDIR%/}
+
+get_gcovfn()
+{
+ dn=$(dirname "${1#$BUILDDIR}")
+ bn=$(basename "$1")
+ gcovdn=${RPM_BUILD_ROOT}${dn}
+ gcovfn=${gcovdn}/${bn}
+}
+
+append_uniq()
+{
+ grep -F -f "$1" -x -v >> "$1" || true
+}
+
+set -o pipefail
+
+find $BUILDDIR -name "*.gcno" | sort |
+while read f; do
+ get_gcovfn $f
+ mkdir -p $gcovdn
+ cp $f $gcovfn
+ echo "$dn/$bn" >> "${LISTFILE}.tmp"
+ echo "%dir $dn" | append_uniq "${LISTFILE}"
+done
+
+if [[ -f "${LISTFILE}.tmp" ]]; then
+ cat "${LISTFILE}.tmp" >> "${LISTFILE}"
+fi