Reinstate clang-tidy.
gn, very helpfully, has built in support for generating a
compile_commands.json file which is used by clang-tidy to determine the
compiler flags for each file.
Change-Id: I4ef5ab7f0eda57f250aa771dd624906d9109e2f8
diff --git a/Makefile b/Makefile
index cb70b7d..15751a2 100644
--- a/Makefile
+++ b/Makefile
@@ -11,11 +11,12 @@
ARCH ?= aarch64
PLATFORM ?= qemu
+.PHONY: all
all: $(OUT)/build.ninja
@$(NINJA) -C $(OUT)
$(OUT)/build.ninja: $(OUT)/args.gn
- @$(GN) gen $(OUT)
+ @$(GN) --export-compile-commands gen $(OUT)
# Configure the build by loading the configuration arguments for the
# architecture and platform
@@ -27,20 +28,26 @@
@echo >> $@
@cat $< >> $@
+.PHONY: clean
clean:
@$(NINJA) -C $(OUT) -t clean
+.PHONY: clobber
clobber:
rm -rf $(OUT)
# see .clang-format
+.PHONY: format
format:
@find src/ -name *.c -o -name *.h | xargs clang-format -style file -i
@find inc/ -name *.c -o -name *.h | xargs clang-format -style file -i
@find test/ -name *.c -o -name *.h | xargs clang-format -style file -i
@find . -name *.gn -o -name *.gni -exec $(GN) format {} \;
-# TODO: get this working again. Need to extract a compile database to get the correct args.
# see .clang-tidy
-# tidy: $(GLOBAL_OFFSETS)
-# @find $(ROOT_DIR)src/ -name *.c -exec clang-tidy {} -fix -- -target $(TARGET) $(COPTS) \;
+.PHONY: tidy
+tidy: $(OUT)/build.ninja
+ @$(NINJA) -C $(OUT)
+ @echo "Tidying..."
+ @find src/ -name *.c -exec clang-tidy -p $(OUT) -fix {} \;
+ @find test/ -name *.c -exec clang-tidy -p $(OUT) -fix {} \;