jart / cosmopolitan

build-once run-anywhere c library
ISC License
18.38k stars 632 forks source link

compile_commands.json generator for clangd integration #1224

Open mrdomino opened 5 months ago

mrdomino commented 5 months ago

Discussed in https://github.com/jart/cosmopolitan/discussions/1206

Originally posted by **alkis** June 9, 2024 Is there build support to generate [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html)? Using https://github.com/rizsotto/Bear does not seem to be working.
mrdomino commented 5 months ago

@alkis Thank you for mentioning this!

Maybe I’m just bad at Github, but I almost never notice things under Discussions unless I’m in some weird corner of the UI. Glad I was this time though — this is something I have wanted for a while too.

I was about to reply and say that I haven’t had any smart ideas about it, but then I went and checked, and realized that this is actually probably incredibly doable.

Here, I will give you an example command to run:

build/bootstrap/make COMPILE=echo

Look at all that crap! I bet an intrepid coder could coerce that crap into some JSON.

(Okay, maybe this doesn’t exactly qualify as a “smart” idea. Well, I guess I waited long enough for a smart idea to arise; one didn’t; I am now in the market for dumb ideas.)