summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml4
-rwxr-xr-xclang-tidy-diff.sh13
2 files changed, 16 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml
index a070c8977..bf46930a9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -64,7 +64,9 @@ jobs:
- ./scripts/gen-s-parser.py | diff src/gen-s-parser.inc -
- BUILD_SUBDIR=${BUILD_SUBDIR:-.}
- mkdir -p ${BUILD_SUBDIR} && cd ${BUILD_SUBDIR}
- - cmake ${TRAVIS_BUILD_DIR} -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS" -DCMAKE_INSTALL_PREFIX=install
+ - cmake ${TRAVIS_BUILD_DIR} -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS" -DCMAKE_INSTALL_PREFIX=install -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
+ # clang-tidy-diff.sh may not exist when BUILD_SUBDIR is a subdirectory
+ - if [ -f clang-tidy-diff.sh ]; then ./clang-tidy-diff.sh; fi
- make -j2 install
- cd ${TRAVIS_BUILD_DIR}
- ./check.py --binaryen-bin=${BUILD_SUBDIR}/install/bin
diff --git a/clang-tidy-diff.sh b/clang-tidy-diff.sh
new file mode 100755
index 000000000..931ad1a11
--- /dev/null
+++ b/clang-tidy-diff.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+CLANG_DIR=$(dirname $(dirname $(which clang-tidy)))
+CLANG_TIDY_DIFF=$CLANG_DIR/share/clang/clang-tidy-diff.py
+MERGE_BASE=$(git merge-base master HEAD)
+TIDY_MSG=$(git diff -U0 $MERGE_BASE | $CLANG_TIDY_DIFF -quiet -p1 2> /dev/null)
+if [ -n "$TIDY_MSG" -a "$TIDY_MSG" != "No relevant changes found." ]
+then
+ echo "Fix clang-tidy errors before committing!"
+ echo
+ # Run clang-tidy once again to show the error
+ git diff -U0 $MERGE_BASE | $CLANG_TIDY_DIFF -quiet -p1
+ exit 1
+fi