aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-21 15:57:50 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-21 15:57:50 +0100
commitfd62678a9cf38e3f70efbdd093c1012d448548e1 (patch)
tree0bd4f3e5a6572bc4f0d9c80674ea06039fb78f36
parent671a58519ef6207b54947ff70eea497ff7eb58ae (diff)
downloadLibft-fd62678a9cf38e3f70efbdd093c1012d448548e1.tar.gz
Libft-fd62678a9cf38e3f70efbdd093c1012d448548e1.zip
Add compile_commands.json generation for clangd support
-rw-r--r--.gitignore2
-rw-r--r--Makefile5
-rw-r--r--tests/.gitignore2
-rw-r--r--tests/Makefile5
4 files changed, 14 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 71e00b9..81ff9bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,5 @@ obj/*
lib/*
bin/*
!.gitkeep
+compile_commands.json
+.cache/
diff --git a/Makefile b/Makefile
index c1af191..5774cc9 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,7 @@ $(OBJDIR):
clean:
rm -rf $(OBJDIR)
+ rm -f compile_commands.json
fclean: clean
rm -f $(NAME)
@@ -41,4 +42,8 @@ re: fclean all
test: $(NAME)
$(MAKE) -C tests
+compile_commands.json: $(SRCS:%=$(SRCDIR)/%)
+ @echo '$(foreach src,$(SRCS),{"directory":"$(CURDIR)","command":"$(CC) $(CFLAGS) -I $(INCDIR) -c $(SRCDIR)/$(src)","file":"$(SRCDIR)/$(src)"})' \
+ | jq -s '.' > $@
+
.PHONY: all clean fclean re test
diff --git a/tests/.gitignore b/tests/.gitignore
index 0e64d2c..a325c28 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,3 +1,5 @@
*.o
bin/*
!.gitkeep
+compile_commands.json
+.cache/
diff --git a/tests/Makefile b/tests/Makefile
index f7f7ed4..c0c8059 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -38,5 +38,10 @@ $(LIB):
clean:
rm -f $(BINS)
+ rm -f compile_commands.json
+
+compile_commands.json: $(TESTS:%=$(SRCDIR)/%.c)
+ @echo '$(foreach t,$(TESTS),{"directory":"$(CURDIR)","command":"$(CC) $(CFLAGS) -c $(SRCDIR)/$(t).c","file":"$(SRCDIR)/$(t).c"})' \
+ | jq -s '.' > $@
.PHONY: all clean