From 2c18d0d3d6c38ed298cfad26f0b622d8bfea5889 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 28 May 2021 11:41:20 +0200 Subject: [PATCH] makefiles/clang-tidy: initial support --- Makefile.include | 2 ++ makefiles/clang_tidy.inc.mk | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 makefiles/clang_tidy.inc.mk diff --git a/Makefile.include b/Makefile.include index 0e66ee4a6e..4d95807a22 100644 --- a/Makefile.include +++ b/Makefile.include @@ -833,6 +833,8 @@ objdump: $(call check_cmd,$(OBJDUMP),Objdump program) $(OBJDUMP) $(OBJDUMPFLAGS) $(ELFFILE) | less +# inlcude clang-tidy +include $(RIOTMAKE)/clang_tidy.inc.mk # Support Eclipse IDE. include $(RIOTMAKE)/eclipse.inc.mk diff --git a/makefiles/clang_tidy.inc.mk b/makefiles/clang_tidy.inc.mk new file mode 100644 index 0000000000..9161f8c00e --- /dev/null +++ b/makefiles/clang_tidy.inc.mk @@ -0,0 +1,18 @@ +.PHONY: clang-tidy + +ifneq (, $(filter clang-tidy,$(MAKECMDGOALS))) +ifneq (llvm,$(TOOLCHAIN)) + $(error clang-tidy must be ran with TOOLCHAIN=llvm) +endif +endif + +FILE_REFEX = '.([CcHh]|[ch]pp)$$' +DIFF_FILTER ?= 'ACMR' +BASE_BRANCH ?= master + +CLANG_TIDY_CHECKS ?= * +CLANG_TIDY_SRCS ?= $(shell git diff --diff-filter=$(DIFF_FILTER) --name-only $(BASE_BRANCH) | grep -E $(FILE_REFEX)) + +clang-tidy: + $(Q)cd $(RIOTBASE); \ + clang-tidy -checks=$(CLANG_TIDY_CHECKS) $(CLANG_TIDY_SRCS) -- $(CFLAGS) $(INCLUDES)