File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,22 @@ ifeq ($(CMAKE),)
22CMAKE := cmake
33endif
44
5+ ifeq ($(CLANG_FORMAT ) ,)
6+ CLANG_FORMAT := clang-format
7+ endif
8+
9+ ifeq ($(RUN_CLANG_TIDY ) ,)
10+ RUN_CLANG_TIDY := run-clang-tidy
11+ endif
12+
13+
14+ SRC_DIR = "$(shell pwd) /src"
15+ INC_DIR = "$(shell pwd) /include"
16+
17+ SOURCE_DIR = "$(SRC_DIR ) " "$(INC_DIR ) "
18+ SOURCE_REGEX = '.*\.\(cpp\|hpp\|c\|h\)'
19+
20+
521.PHONY : all
622all : build/Makefile
723 @$(MAKE ) --no-print-directory -C build
@@ -14,3 +30,19 @@ build/Makefile: | build
1430
1531build :
1632 @mkdir -p $@
33+
34+ .PHONY : format
35+ format :
36+ @find $(SOURCE_DIR ) -type f -regex $(SOURCE_REGEX ) -print0 | xargs -0 $(CLANG_FORMAT ) --dry-run
37+
38+ .PHONY : format-fix
39+ format-fix :
40+ @find $(SOURCE_DIR ) -type f -regex $(SOURCE_REGEX ) -print0 | xargs -0 $(CLANG_FORMAT ) -i
41+
42+ .PHONY : tidy
43+ tidy : all
44+ $(RUN_CLANG_TIDY ) -p build -quiet -j $(shell nproc) -header-filter=$(SOURCE_DIR ) $(SOURCE_DIR )
45+
46+ .PHONY : tidy-fix
47+ tidy-fix : all
48+ $(RUN_CLANG_TIDY ) -p build -quiet -fix -j $(shell nproc) -header-filter=$(SOURCE_DIR ) $(SOURCE_DIR )
You can’t perform that action at this time.
0 commit comments