danielbarter/mini_compile_commands

Support collecting compile commands from packages

Opened this issue · 1 comments

This is already somewhat possible, as described in https://github.com/danielbarter/mini_compile_commands#build-input-hook, but I think it could be improved.

  1. make the derivation multi-output, and put compile_commands.json in $dev instead of $out and
  2. replace all occurrences of the compiler invocation path in compile_commands.json with @src@.

Then, a derivation that wants to reference compile_commands.json can depend on my-package.dev, copy compile_commands.json to the source tree and substituteInPlace compile-commands.json --subst-var src … or something like that. And maybe this side could be captured in another hook.

This is an interesting idea. My guess is there will probably be lots of weird edge cases, especially for out of tree builds. That said, there are already lots of weird edge cases, eg when you can't override the compiler being used, and the only way to get things working if to overlay mini compile commands deep into nixpkgs and rebuild the world.

I personally, only ever use the project interactively, but if you want to try and implement this, I will be around to help