Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Enforce clang-format for c-like sources on Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer committed Sep 11, 2017
1 parent 19590d2 commit fdb1e42
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ before_script:
script:
- ./travis/build.sh
- ./travis/test.sh
- ./travis/format.sh
35 changes: 35 additions & 0 deletions travis/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
echo "Checking formatting..."

case "$(uname -s)" in
Darwin)
OS="mac-x64"
;;
Linux)
OS="linux-x64"
;;
*)
echo "Unknown operating system."
exit -1
;;
esac

CLANG_FORMAT="buildtools/$OS/clang/bin/clang-format"
$CLANG_FORMAT --version

FILES="$(find flutter/ -name '*.cpp' -or -name '*.h' -or -name '*.c' -or -name '*.cc' -or -name '*.m' -or -name '*.mm')"

FAILED_CHECKS=0
for FILE in $FILES; do
RESULT="$(diff -u "$FILE" <($CLANG_FORMAT --style=file "$FILE"))"
if ! [ -z "$RESULT" ]; then
echo "$RESULT"
FAILED_CHECKS=$(($counter+1))
fi
done

if [ $FAILED_CHECKS -ne 0 ]; then
echo "Some files are formatted incorrectly. To fix, apply diffs from above."
fi

exit $FAILED_CHECKS

0 comments on commit fdb1e42

Please sign in to comment.