dev tools: add runner script for clang-tidy

This commit is contained in:
Moritz Bunkus 2019-01-02 21:44:49 +01:00
parent ac38b8ec2a
commit 0e2cea9cf4
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85

View File

@ -0,0 +1,37 @@
#!/bin/zsh
if [[ -z $RUN_CLANG_TIDY_PARALLEL ]]; then
export RUN_CLANG_TIDY_PARALLEL=1
typeset -a args files
while [[ -n $@ ]]; do
if [[ -f $1 ]]; then
files+=($1)
else
args+=($1)
fi
shift
done
print -l $files | xargs -P $(nproc) -n 1 -d '\n' -I{} $0 {} $args
exit
fi
SOURCE=${1}
OUT=${SOURCE}.tidy.out.txt
ERR=${SOURCE}.tidy.err.txt
shift
clang-tidy $@ ${SOURCE} > ${OUT} 2> ${ERR}
RESULT=$?
sed -E -i \
-e '/^[0-9]+ warnings generated/d' \
-e '/^Suppressed [0-9]+ warnings/d' \
-e '/^Use -header-filter=/d' \
${ERR}
if [[ ! -s ${OUT} ]] rm ${OUT}
if [[ ! -s ${ERR} ]] rm ${ERR}
exit ${RESULT}