diff --git a/pkg/urbit/.gitignore b/pkg/urbit/.gitignore index f78b9fecdf..3a9050b38d 100644 --- a/pkg/urbit/.gitignore +++ b/pkg/urbit/.gitignore @@ -3,3 +3,8 @@ /include/config.h /include/ca-bundle.h /include/ivory.h + +# indexing +/.cache/ +compile_commands.json +tags diff --git a/pkg/urbit/Makefile b/pkg/urbit/Makefile index 46b90249e5..e6c4fe5bc6 100644 --- a/pkg/urbit/Makefile +++ b/pkg/urbit/Makefile @@ -1,5 +1,6 @@ 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) noun = $(wildcard noun/*.c) @@ -53,7 +54,7 @@ clean: rm -f ./tags $(all_objs) $(all_exes) 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) 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 "]" >> $@