File: clang-format.sh

package info (click to toggle)
simdjson 4.3.1-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 31,396 kB
  • sloc: cpp: 195,760; ansic: 20,954; sh: 1,126; python: 885; makefile: 47; ruby: 25; javascript: 13
file content (25 lines) | stat: -rwxr-xr-x 736 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
BASE=$SCRIPTPATH/..
cd $BASE

STYLE=$(which clang-format)
if [ $? -ne 0 ]; then
	echo "clang-format not installed. Unable to check source file format policy." >&2
	exit 1
fi
OURSTYLE="" # defer to .clang-format
OURCONTENT="include benchmark tools tests src"
RE=0
BASE=$(git rev-parse --show-toplevel)
ALLFILES=$(find $OURCONTENT -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.cc' -o -name '*.hh')
for FILE in $ALLFILES; do
  eval "$STYLE $OURSTYLE $BASE/$FILE" | cmp -s $BASE/$FILE -
  if [ $? -ne 0 ]; then
        echo "$BASE/$FILE does not respect the coding style. Formatting. " >&2
        eval "$STYLE $OURSTYLE -i $BASE/$FILE"
        RE=1
  fi
done

exit $RE