File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -141,5 +141,16 @@ matrix:
141141 after_success :
142142 - coveralls --gcov gcov-7 --gcov-options '\-lp' --exclude src
143143
144+ - compiler : clang
145+ addons :
146+ apt :
147+ sources : ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
148+ packages : ['clang-5.0', 'clang-tidy-5.0']
149+ env :
150+ - CXX=clang++-5.0
151+ - CLANG_TIDY=clang-tidy-5.0
152+ script :
153+ - make -kj3 clang-tidy
154+
144155script :
145156 make -j3
Original file line number Diff line number Diff line change @@ -29,17 +29,26 @@ endif
2929CPPFLAGS ?= -pedantic
3030CXXFLAGS ?= -Wall -Wextra -Wshadow -Werror -O3
3131
32- .PHONY : all clean
32+ CLANG_TIDY ?= clang-tidy
3333
34+ HEADERS := $(shell find include -name '* .hpp')
3435SOURCES := $(shell find src -name '* .cpp')
3536DEPENDS := $(SOURCES:%.cpp=build/%.d )
3637BINARIES := $(SOURCES:%.cpp=build/% )
3738
3839UNIT_TESTS := $(filter build/src/test/% ,$(BINARIES ) )
3940
40- all : $(BINARIES )
41+ .PHONY : all
42+ all : compile check
43+
44+ .PHONY : compile
45+ compile : $(BINARIES )
46+
47+ .PHONY : check
48+ check : $(UNIT_TESTS )
4149 @set -e; for T in $( UNIT_TESTS) ; do echo $$ T; $$ T > /dev/null; done
4250
51+ .PHONY : clean
4352clean :
4453 @rm -rf build
4554 @find . -name ' *~' -delete
@@ -51,6 +60,15 @@ build/%.d: %.cpp Makefile
5160build/% : % .cpp build/% .d
5261 $(CXX ) $(CXXSTD ) -Iinclude $(CPPFLAGS ) $(CXXFLAGS ) $< -o $@
5362
63+ build/% .clang-tidy : %
64+ $(CLANG_TIDY ) -extra-arg " -Iinclude" -extra-arg " -std=c++11" -checks=* ,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-misc-macro-parentheses -warnings-as-errors=* $< 2> /dev/null
65+ @mkdir -p $(@D )
66+ @touch $@
67+
68+ .PHONY : clang-tidy
69+ clang-tidy : $(HEADERS:%=build/%.clang-tidy ) $(SOURCES:%=build/%.clang-tidy )
70+ @echo " All $( words $( HEADERS) $( SOURCES) ) clang-tidy tests passed."
71+
5472ifeq ($(findstring $(MAKECMDGOALS ) ,clean) ,)
5573-include $(DEPENDS )
5674endif
You can’t perform that action at this time.
0 commit comments