summaryrefslogtreecommitdiff
path: root/checkFormat.sh
blob: 027cc3b45e825e8f5be3ffb88c6da8c6c0070b5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

CLANG_FORMAT=clang-format-6.0

files_to_lint=$(find ./src ./lib -type f -name '*.c' -or -name '*.h')

fail=0
for f in ${files_to_lint}; do
  d="$(diff -u "$f" <($CLANG_FORMAT -style=file "$f") || true)"
  if ! [ -z "$d" ]; then
    printf "The file %s is not compliant with the coding style:\n%s\n" "$f" "$d"
    fail=1
  fi
done

if [ "$fail" -eq "1" ]; then
  if [ ! -z $XMAP_ENFORCE_FORMAT ]; then
    exit 1
  fi
fi