diff --git a/.gitignore b/.gitignore index 1c0f60b991..790df5e1a6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /Release /build /config.* +/compile_commands.json /makeobj/makeobj /makeobj/makeobj.exe *sim diff --git a/common.mk b/common.mk index a62e2892e7..e9f1eb9707 100644 --- a/common.mk +++ b/common.mk @@ -5,7 +5,7 @@ DIRS := $(sort $(dir $(OBJS))) # Make build directories DUMMY := $(shell mkdir -p $(DIRS)) -.PHONY: all clean +.PHONY: all clean compile-commands .SUFFIXES: .rc @@ -30,6 +30,13 @@ clean: -include $(DEPS) +compile-commands: + @echo "[" > compile_commands.json + @for file in $(SOURCES); do \ + echo "{ \"directory\": \"$(PROGDIR)\", \"command\": \"$(HOSTCXX) $(CXXFLAGS) -c -MMD $$(pwd)/$$file\", \"file\": \"$$(pwd)/$$file\" }," >> compile_commands.json; \ + done; + @echo "{ \"directory\": \"no\", \"command\": \"trailing\", \"file\": \"comma\"}]" >> compile_commands.json + # Silence stale header dependency errors %.h: @true