forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce clang-format for c-like sources on Travis (flutter#4089)
* Enforce clang-format for c-like sources on Travis * Edit CONTRIBUTING,md * review feedback: * ++ * ++ * ++
- Loading branch information
1 parent
08961f8
commit ff0a9a8
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ before_script: | |
script: | ||
- ./travis/build.sh | ||
- ./travis/test.sh | ||
- ./travis/format.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
set -e | ||
echo "Checking formatting..." | ||
cd .. | ||
|
||
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 | ||
set +e | ||
RESULT="$(diff -u "$FILE" <($CLANG_FORMAT --style=file "$FILE"))" | ||
set -e | ||
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 |