Files
system76-embedded-controller/scripts/lint/02-uncrustify.sh
Tim Crawford d3894392d5 Replace clang-format with uncrustify
LLVM/clang is not used for any compilation due to it not supporting the
8-bit architectures we use (MCS-51, AVR). This means we are effectively
installing 250+ MiB of dependencies for a C formatting tool.

Replace it with uncrustify, which uses only ~600 KiB of space and has
more granular control of formatting (800+ options).

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-07-03 15:58:28 -06:00

37 lines
724 B
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-only
# Check if any C files or headers need to be formatted.
# shellcheck disable=SC1091
LINT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
. "$LINT_DIR/util.sh"
echo -n "Checking C style..."
if ! command -v uncrustify > /dev/null; then
skipped "uncrustify not found"
exit 0
fi
needs_formatting=()
for file in $(git ls-files '*.c' '*.h'); do
if ! uncrustify -c .uncrustify.cfg -q --check "$file" >/dev/null 2>&1; then
needs_formatting+=("$file")
fi
done
if [[ "${#needs_formatting[@]}" != "0" ]]; then
failed
for file in "${needs_formatting[@]}"; do
echo "- $file"
done
exit 1
fi
passed