Makefile: Generate compile_commands.json

Introduce a make target for generating compile_commands.json to feed
clangd and the Language Server Protocol, to gain better editor
integration.

Add the relevant files to .gitignore.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
This commit is contained in:
Bjorn Andersson
2024-03-25 09:50:59 -05:00
committed by Konrad Dybcio
parent 7cc077d066
commit a10d2bf57b
2 changed files with 6 additions and 0 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
*.o
qdl
ks
compile_commands.json
.cache

View File

@@ -19,9 +19,13 @@ $(OUT): $(OBJS)
$(KS_OUT): $(KS_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
compile_commands.json: $(SRCS) $(KS_SRCS)
@echo -n $^ | jq -snR "[inputs|split(\" \")[]|{directory:\"$(PWD)\", command: \"$(CC) $(CFLAGS) -c \(.)\", file:.}]" > $@
clean:
rm -f $(OUT) $(OBJS)
rm -f $(KS_OUT) $(KS_OBJS)
rm -f compile_commands.json
install: $(OUT) $(KS_OUT)
install -d $(DESTDIR)$(prefix)/bin