util/lint: Improve final newline check

- Change .inc to .mk. This was missed when renaming the makefiles.
- Verify that dirs/files exist before checking.
- Use $FINDOPTS to control search when not in a git repo.

Change-Id: If0d80403a3e799b8103164cc075601a50c33a8d9
Signed-off-by: Martin Roth <gaumless@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88238
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
Martin Roth 2025-06-28 10:24:45 -06:00 committed by Martin L Roth
commit a0f2e42879

View file

@ -13,7 +13,7 @@ LINTDIR="$(
. "${LINTDIR}/helper_functions.sh"
PIDS=""
INCLUDED_DIRS_AND_FILES='util/* src/* payloads/* configs/* Makefile *.inc'
INCLUDED_DIRS_AND_FILES='util/* src/* payloads/* configs/* Makefile *.mk'
EXCLUDED_DIRS="\
src/vendorcode/\|\
cbfstool/lzma/\|\
@ -64,12 +64,14 @@ test_for_final_newline() {
done
}
for directory in $INCLUDED_DIRS_AND_FILES ; do
${FIND_FILES} "${directory}" | sed 's|^\./||' | sort | \
grep -v "$EXCLUDED_DIRS" | \
grep -v "$EXCLUDED_FILES" | \
test_for_final_newline &
PIDS="$PIDS $!"
for dir_or_file in $INCLUDED_DIRS_AND_FILES; do
if [ -e "${dir_or_file}" ] || [ -d "${dir_or_file}" ]; then
${FIND_FILES} "${dir_or_file}" ${FINDOPTS} | sed 's|^\./||' | sort | \
grep -v "$EXCLUDED_DIRS" | \
grep -v "$EXCLUDED_FILES" | \
test_for_final_newline &
PIDS="$PIDS $!"
fi
done
# wait for tests to finish.