diff options
Diffstat (limited to 'scripts/find-gcovinfo.sh')
-rw-r--r-- | scripts/find-gcovinfo.sh | 58 |
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 |