Merge pull request #5880 from midlyx-hatrys/compdb

vere: build: add ability to create compdb (for Clangd etc.)
This commit is contained in:
Joe Bryan 2022-07-05 22:42:19 -04:00 committed by GitHub
commit f9e4822026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -3,3 +3,8 @@
/include/config.h /include/config.h
/include/ca-bundle.h /include/ca-bundle.h
/include/ivory.h /include/ivory.h
# indexing
/.cache/
compile_commands.json
tags

View File

@ -1,5 +1,6 @@
include config.mk include config.mk
include $(foreach dir,$(compat),$(wildcard compat/$(dir)/*.mk)) compat_mks := $(foreach dir,$(compat),$(wildcard compat/$(dir)/*.mk))
include $(compat_mks)
jets = jets/tree.c $(wildcard jets/*/*.c) jets = jets/tree.c $(wildcard jets/*/*.c)
noun = $(wildcard noun/*.c) noun = $(wildcard noun/*.c)
@ -53,7 +54,7 @@ clean:
rm -f ./tags $(all_objs) $(all_exes) rm -f ./tags $(all_objs) $(all_exes)
mrproper: clean mrproper: clean
rm -f config.mk include/config.h rm -f config.mk include/config.h compile_commands.json
################################################################################ ################################################################################
@ -80,3 +81,15 @@ build/urbit: $(common_objs) $(daemon_objs) $(worker_objs)
tags: $(all_srcs) $(headers) tags: $(all_srcs) $(headers)
ctags $^ ctags $^
compile_commands.json: Makefile config.mk $(compat_mks)
@echo "[" > $@ && sep= && \
for src in $(all_srcs); do \
echo "$$sep{" >> $@; \
printf '"directory": "%s",\n' $$(pwd) >> $@; \
printf '"command": "%s",\n' "$(CC) -I./include $(CFLAGS) $$src $(CCEXTRA) -c" >> $@; \
printf '"file": "%s",\n' $$src >> $@; \
echo "}" >> $@; \
sep=','; \
done && \
echo "]" >> $@