Skip to content

Instantly share code, notes, and snippets.

@presuku
Last active October 24, 2017 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save presuku/9aea6725da3a20ce109bb17f7f9bb0dd to your computer and use it in GitHub Desktop.
Save presuku/9aea6725da3a20ce109bb17f7f9bb0dd to your computer and use it in GitHub Desktop.
## make compile_commands.json for clangd
MK_C_C_JSON_PWD := `pwd`
MK_C_C_JSON_SRCS := $(ALL_SRC)
MK_C_C_JSON_CFLAGS := $(ALL_CFLAGS)
mk_c_c_json-clean:
@-rm -f compile_commands.json
mk_c_c_json: mk_c_c_json-clean
@echo "[" > compile_commands.json
@for i in $(MK_C_C_JSON_SRCS) ; do \
echo "{\n\
\"directory\": \"$(MK_C_C_JSON_PWD)\",\n\
\"command\": \"/usr/bin/cc $(MK_C_C_JSON_CFLAGS) -o /tmp/$$i.o -c $(MK_C_C_JSON_PWD)/$$i\",\n\
\"file\": \"$(MK_C_C_JSON_PWD)/$$i\"\n\
}," >> compile_commands.json ;\
done
@sed -i '$$d' compile_commands.json
@echo "}\n]\n" >> compile_commands.json
mk_compile_commands.json: mk_c_c_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment