mirror of
https://github.com/intel/isa-l.git
synced 2024-12-12 09:23:50 +01:00
build: Add format checking script
Signed-off-by: Greg Tucker <greg.b.tucker@intel.com>
This commit is contained in:
parent
9099918dcb
commit
74d5d3660b
@ -30,6 +30,10 @@ the included indent script to format C code.
|
||||
|
||||
./tools/iindent your_files.c
|
||||
|
||||
And use check format script before submitting.
|
||||
|
||||
./tools/check_format.sh
|
||||
|
||||
[mailing list]:https://lists.01.org/mailman/listinfo/isal
|
||||
[license]:LICENSE
|
||||
[signed-off-by language]:https://01.org/community/signed-process
|
||||
|
59
tools/check_format.sh
Executable file
59
tools/check_format.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
rc=0
|
||||
verbose=0
|
||||
indent_args='-npro -kr -i8 -ts8 -sob -l95 -ss -ncs -cp1 -lps'
|
||||
|
||||
while [ -n "$*" ]; do
|
||||
case "$1" in
|
||||
-v )
|
||||
verbose=1
|
||||
shift
|
||||
;;
|
||||
-h )
|
||||
echo check_format.sh [-h -v]
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "Checking format of files in the git index at $PWD"
|
||||
if ! git rev-parse --is-inside-work-tree >& /dev/null; then
|
||||
echo "Not in a git repo: Fail"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if hash indent && indent --version | grep -q GNU; then
|
||||
echo "Checking C files for coding style..."
|
||||
for f in `git ls-files '*.c'`; do
|
||||
[ "$verbose" -gt 0 ] 2> /dev/null && echo "checking $f"
|
||||
if ! indent $indent_args -st $f | diff -q $f - >& /dev/null; then
|
||||
echo " File found with formatting issues: $f"
|
||||
[ "$verbose" -gt 0 ] 2> /dev/null && indent $indent_args -st $f | diff -u $f -
|
||||
rc=1
|
||||
fi
|
||||
done
|
||||
[ "$rc" -gt 0 ] && echo " Run ./tools/iindent on files"
|
||||
else
|
||||
echo "You do not have indent installed so your code style is not being checked!"
|
||||
fi
|
||||
|
||||
if hash grep; then
|
||||
echo "Checking for dos and whitespace violations..."
|
||||
for f in `git ls-files '*.c' '*.h' '*.asm' '*.inc' '*.am' '*.txt' '*.md' `; do
|
||||
[ "$verbose" -gt 0 ] 2> /dev/null && echo "checking $f"
|
||||
if grep -q '[[:space:]]$' $f ; then
|
||||
echo " File found with trailing whitespace: $f"
|
||||
rc=1
|
||||
fi
|
||||
if grep -q $'\r' $f ; then
|
||||
echo " File found with dos formatting: $f"
|
||||
rc=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
[ "$rc" -gt 0 ] && echo Format Fail || echo Format Pass
|
||||
|
||||
exit $rc
|
2
tools/remove_trailing_whitespace
Executable file
2
tools/remove_trailing_whitespace
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
sed -i -i.bak 's/[[:blank:]]*$//' "$@"
|
Loading…
Reference in New Issue
Block a user