summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/gcov-prune33
-rwxr-xr-xbuild-aux/lint-generic15
-rwxr-xr-xbuild-aux/valgrind2
3 files changed, 45 insertions, 5 deletions
diff --git a/build-aux/gcov-prune b/build-aux/gcov-prune
new file mode 100755
index 0000000..dc190a9
--- /dev/null
+++ b/build-aux/gcov-prune
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# build-aux/gcov-prune - Prune old GCC coverage files
+#
+# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+set -e
+
+[[ $# == 1 ]]
+
+sourcedir="$(realpath -- .)"
+builddir="$(realpath -- "$1")"
+
+# `gcc` writes .gcno
+# Running the program writes .gcda (updates existing files, concurrent-safe)
+# GCC `gcov` post-processes .gcno+.gcda to .gcov
+# `gcovr` is a Python script that calls `gcov` and merges and post-processes the .gcov files to other formats
+
+# Prune orphaned .gcno files.
+find "$builddir" -name '*.gcno' -printf '%P\0' | while read -d '' -r gcno_file; do
+ rel_base="${gcno_file%/CMakeFiles/*}"
+ src_file="$gcno_file"
+ src_file="${src_file#*/CMakeFiles/*.dir/}"
+ src_file="${src_file%.gcno}"
+ src_file="${src_file//__/..}"
+ src_file="$rel_base/$src_file"
+ if [[ ! -e "$sourcedir/$src_file" || "$sourcedir/$src_file" -nt "$builddir/$gcno_file" ]]; then
+ rm -fv -- "$builddir/$gcno_file"
+ fi
+done
+
+# Prune all .gcda files.
+find "$builddir" -name '*.gcda' -delete
diff --git a/build-aux/lint-generic b/build-aux/lint-generic
index d982527..9bf88dd 100755
--- a/build-aux/lint-generic
+++ b/build-aux/lint-generic
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
# build-aux/lint-generic - Non-language-specific lint checks
#
# Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
@@ -16,12 +16,19 @@ r=0
for filename in "$@"; do
# File header ##########################################################
- shebang="$(sed -n '1{/^#!/{/^#!\/hint\//q; p;};}' "$filename")"
- if [ -x "$filename" ] && [ -z "$shebang" ]; then
+ shebang="$(sed -n '1{/^#!/p;}' "$filename")"
+ if [[ -x $filename && (-z $shebang || $shebang == '#!/hint/'*) ]]; then
err "$filename" 'is executable but does not have a shebang'
- elif [ -n "$shebang" ] && ! [ -x "$filename" ]; then
+ elif [[ (-n $shebang && $shebang != '#!/hint/'*) && ! -x $filename ]]; then
err "$filename" 'has a shebang but is not executable'
fi
+ case "$shebang" in
+ '') : ;;
+ '#!/bin/sh') : ;;
+ '#!/usr/bin/env bash') : ;;
+ '#!/usr/bin/env python3') : ;;
+ *) err "$filename" 'has an unrecognized shebang' ;;
+ esac
if ! grep -E -q 'Copyright \(C\) 202[4-9]((-|, )202[5-9])* Luke T. Shumaker' "$filename"; then
err "$filename" 'is missing a copyright statement'
diff --git a/build-aux/valgrind b/build-aux/valgrind
index 7ad2712..8fe7c6e 100755
--- a/build-aux/valgrind
+++ b/build-aux/valgrind
@@ -1,4 +1,4 @@
-#!/bin/env bash
+#!/usr/bin/env bash
# build-aux/valgrind - Wrapper around valgrind to keep flags consistent
#
# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com>