hackrf/tools/reformat-source.sh
Martin Ling a06232270e Fix issues with clang-format version detection.
Recent versions include a suffix in brackets, e.g:

$ clang-format --version
Debian clang-format version 21.1.8 (3+b1)

Require a specific version rather than a minimum one, due to differences
in output between versions.
2026-04-07 12:01:53 +01:00

20 lines
565 B
Bash
Executable file

#!/bin/bash
REQUIRED_VERSION=14
VERSION=`clang-format --version | grep -o 'version [^ ]' | cut -d ' ' -f 2 | cut -d '.' -f 1`
if [ "$VERSION" -eq "$REQUIRED_VERSION" ]; then
CLANG_FORMAT=clang-format
elif command -v clang-format-$REQUIRED_VERSION > /dev/null; then
CLANG_FORMAT=clang-format-$REQUIRED_VERSION
else
echo "clang-format version $REQUIRED_VERSION is required."
exit 1
fi
$CLANG_FORMAT \
-i \
--style=file \
host/libhackrf/src/*.{c,h} \
host/hackrf-tools/src/*.c \
firmware/{common,common/rad1o,hackrf_usb}/*.{c,h}