labwc/scripts/check
Tomi Ollila eaf66a23d0 scripts/check: run checkpatch.pl processes with max 16 args each
Reduce the overhead of fork/execve/perl startup time by not
doing those for every files that are checked.

This also makes the check execution complete faster.

On similar systems and similar background load, the execution time
varies based on how find(1) outputs the (*.[ch]) files it sees on
filesystem -- the filenames are not sorted but are written from
directories src/ include/ clients/ t/ in that order -- more than
80% of the time goes checking files in src/, and how the 16-file
batches from that dir (108 files in src/, 208 total, as of 2026-01)
are distributed the checkpatch.pl processes affect mostly to the
total run time.
2026-01-09 23:46:55 +02:00

46 lines
859 B
Bash
Executable file

#!/bin/sh
file=
usage_message="Usage: check [OPTIONS]
OPTIONS:
--file=<filename> Specify file to check. If none specified, all
files in src/ and include/ will be checked.
"
run_checkpatch() {
nice scripts/checkpatch.pl --terse --no-tree --strict --file "$1"
return $?
}
run_checks () {
if [ ! -z "$file" ]; then
run_checkpatch "${file}"
return $?
fi
find src/ include/ clients/ t/ \( -name "*.c" -o -name "*.h" \) -type f -print0 |
nice xargs -0 --max-args 16 --max-procs $(nproc) \
scripts/checkpatch.pl --terse --no-tree --strict --file
return $?
}
main () {
for arg
do
opt=${arg%%=*}
var=${arg#*=}
case "$opt" in
--file)
file="$var" ;;
-h|--help)
printf '%b' "$usage_message"; exit 1 ;;
*)
printf '%b\n' "warn: unknown option $opt" >&2 ;;
esac
done
run_checks
}
main "$@"