aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-03-25 08:52:37 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-03-25 08:52:37 +0200
commit64776239575b33b165b88f81107e0203b9286ab4 (patch)
tree586c8c03930082a6975b5bcf1250bb2ecb8d283b
parentPlace bootstrap code into multiboot section (diff)
downloadkernel.cpp-64776239575b33b165b88f81107e0203b9286ab4.tar.xz
makefile: add clang-tidy target
-rw-r--r--.clang-tidy21
-rw-r--r--.gitignore1
-rw-r--r--makefile18
3 files changed, 37 insertions, 3 deletions
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..bf7aa57
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,21 @@
+---
+Checks: '-*,bugprone-*,cert-*,clang-analyzer-*,cppcoreguidelines-*,performance-*,portability-*,readability-*'
+WarningsAsErrors: ''
+HeaderFilterRegex: '.*'
+AnalyzeTemporaryDtors: false
+FormatStyle: none
+CheckOptions:
+ - key: modernize-loop-convert.MaxCopySize
+ value: '16'
+ - key: modernize-loop-convert.MinConfidence
+ value: reasonable
+ - key: modernize-loop-convert.NamingStyle
+ value: CamelCase
+ - key: modernize-pass-by-value.IncludeStyle
+ value: llvm
+ - key: modernize-replace-auto-ptr.IncludeStyle
+ value: llvm
+ - key: modernize-use-nullptr.NullMacros
+ value: 'NULL'
+...
+
diff --git a/.gitignore b/.gitignore
index 54a2a5a..fc83119 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ tools/kconfig/lexer.lex.h
tools/kconfig/parser.tab.c
tools/kconfig/parser.tab.h
+compile_commands.json
.config.old
*.tar*
diff --git a/makefile b/makefile
index 6e44faf..58bce7f 100644
--- a/makefile
+++ b/makefile
@@ -2,7 +2,7 @@ include .config
OBJ_DIR != echo $(CONFIG_OBJ_DIR)
include toolchain.makefile
-.PHONY: default clean test todo run menuconfig
+.PHONY: default clean test tidy todo run menuconfig
all: $(OBJ_DIR)/glitch.elf
include libk/makefile
@@ -10,12 +10,15 @@ include src/makefile
include drivers/makefile
AS_OBJ := $(addprefix $(OBJ_DIR)/, $(AS_OBJ))
+CXX_SRC := $(CXX_OBJ:%.o=%.cc)
CXX_OBJ := $(addprefix $(OBJ_DIR)/, $(CXX_OBJ))
CXX_DEP = $(CXX_OBJ:%.o=%.d)
+CXX_JSON = $(CXX_OBJ:.o=.json)
CXX_TEST_OBJ := $(addprefix $(OBJ_DIR)/, $(CXX_TEST_OBJ))
CXX_INCLUDE := $(addprefix -I, $(CXX_INCLUDE))
SYSTEM_INCLUDE := $(addprefix -isystem, $(SYSTEM_INCLUDE))
+
$(OBJ_DIR)/glitch.elf: $(autogen) $(AS_OBJ) $(CXX_OBJ) linker.ld
@echo " LD $@"
@$(LD) $(LD_FLAGS) -o $@ $(AS_OBJ) $(CXX_OBJ)
@@ -26,20 +29,29 @@ $(AS_OBJ): $(OBJ_DIR)/%.o: %.S
@$(AS) -target $(TARGET) $(AS_FLAGS) $(SYSTEM_INCLUDE) -c $^ -o $@
-include $(CXX_DEP)
-$(CXX_OBJ): $(OBJ_DIR)/%.o : %.cc
+$(OBJ_DIR)/%.o $(OBJ_DIR)%.json : %.cc
@mkdir -p $(@D)
@echo " CXX $<"
- @$(CXX) -target $(TARGET) $(CXX_FLAGS) $(CXX_INCLUDE) $(SYSTEM_INCLUDE) -MMD -c $< -o $@
+ @$(CXX) -target $(TARGET) $(CXX_FLAGS) $(CXX_INCLUDE) $(SYSTEM_INCLUDE) -MMD -MJ$(subst .o,.json,$@) -c $< -o $@
$(CXX_TEST_OBJ): $(OBJ_DIR)/%.o : %.cc
@mkdir -p $(@D)
@echo " TEST $<"
@$(TEST_CXX) -target $(TARGET) $(CXX_TEST_FLAGS) $(CXX_INCLUDE) -MMD -c $< -o $@
+compile_commands.json: $(CXX_JSON)
+ @echo [ > $@
+ @cat $(CXX_JSON) >> $@
+ @echo ] >> $@
+
clean:
@rm -rf $(autogen) $(AS_OBJ) $(CXX_OBJ) $(CXX_DEP) $(CXX_TEST_OBJ) $(OBJ_DIR)/glitch.elf $(OBJ_DIR)/isodir
+ @rm -f $(CXX_JSON) compile_commands.json
@make -C tools/kconfig OBJ_DIR=$(CURDIR)/$(OBJ_DIR)/kconfig clean
+tidy: compile_commands.json
+ $(foreach x, $(CXX_SRC), $(shell clang-tidy $x))
+
# testing
test: $(CXX_TEST_OBJ)