On Mon, 2018-07-30 at 10:44 +1200, Duane Griffin wrote: > I am not a GNU make developer but I am pretty sure that it is not > possible to do this generically within make itself. Make does not > work at that level. It just runs shell code, it doesn't understand > that a particular command is, for example, invoking clang and should > be added to a compilation database.
Is it really critical that only compilation commands be added to compile_commands.json? What would be the impact if other commands (that had recipes) were also added? On Sun, 2018-07-29 at 18:14 +0300, Doron Behar wrote: > With probably the most common one, the GNU build system, this is not > supported out of the box. Although there is currently 1 workaround > (https://github.com/rizsotto/scan-build), It would be great it would > be supported right out of the box, perhaps by introducing a new flag > like `--compdb` which will create this file. > > I think it would be worth the effort of the developers, what do you > guys think? To my mind the most difficult thing is that it's somewhat rare, in a makefile, that the recipe to compile a file consists of exactly one command line that invokes the compiler. Often the recipe is a small script that does some pre-op stuff, runs the command, then does some post-op stuff. This is especially true when auto-generated dependencies are wanted, which is almost all the time. As far as I can see from the description of this format it's not valid to have multiple commands associated with a file. At first consideration it seems that, given the limitations of the format, the only way for it to be generated from a makefile would be for makefile authors to note which recipe lines were appropriate for inclusion. Since makefile authors would need to do that work anyway, I'm not sure that it's worthwhile to add something like this embedded in GNU make; I suspect that it could be done using make functions. _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make