git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Makefile: add support for generating JSON compilation database

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Sep 1, 2020, 13:18 UTC
Message-ID
<867D6718-E377-47B8-BD32-0800872B3DE0@gmail.com>
In-Reply-To
<20200901073827.GA3967005@coredump.intra.peff.net>
Show 28 quoted lines
> Le 1 sept. 2020 à 03:38, Jeff King <peff@peff.net> a écrit :
> 
> On Sun, Aug 30, 2020 at 09:24:03PM -0700, Junio C Hamano wrote:
> 
>> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
>> 
>>> On 2020-08-30 at 19:28:27, Philippe Blain via GitGitGadget wrote:
>>>> From: Philippe Blain <levraiphilippeblain@gmail.com>
>>>> 
>>>> Tools based on LibClang [1] can make use of a 'JSON Compilation
>>>> Database' [2] that keeps track of the exact options used to compile a set
>>>> of source files.
>>> 
>>> For additional context why this is valuable, clangd, which is a C
>>> language server protocol implementation, can use these files to
>>> determine the flags needed to compile a file so it can provide proper
>>> editor integration.  As a result, editors supporting the language server
>>> protocol (such as VS Code, or Vim with a suitable plugin) can provide
>>> better searching, integration, and refactoring tools.
>> 
>> I found that the proposed commit log was very weak to sell the
>> change; some of what you gave above should definitely help strenthen
>> it.
> 
> Likewise. Looking at the output, I'm confused how it would help with
> things like searching and refactoring. It might be nice to spell it out
> for those of us exposed to it for the first time (I tried following the
> links but remained unenlightened).

OK, I'll improve the commit message. I'm not at all an expert in this subject, I just had to generate a compilation database myself to use the Sourcetrail source explorer [1] with Git so I figured I'd share what I had done. Further exploration of the topic are in [2] and [3]. Note that I did try some of the tools listed in [2] before resorting to modifying the Makefile, but these tools either did not work at all or produced wrong output (ex. strings in the JSON were not properly quoted, etc.)

> I'd also be curious to hear what advantages it gives to add a new
> Makefile knob rather than just letting interested parties add -MJ to
> their CFLAGS. Is it just a convenience to create the concatenated form?

Unfortunately this would not work because the '-MJ' flag needs a file name to know where to put the JSON fragment.

Thanks, Philippe.

[1] www.sourcetrail.com [2] https://sarcasm.github.io/notes/dev/compilation-database.html [3] https://eli.thegreenplace.net/2014/05/21/compilation-databases-for-clang-based-tools

Previous: Jeff KingNext: brian m. carlson
Message 6 of 15 in “Makefile: add support for generating JSON compilation database”
  1. Makefile: add support for generating JSON compilation databasePhilippe Blain via GitGitGadget, Aug 30, 2020
  2. brian m. carlsonAug 30, 2020
  3. Philippe BlainAug 31, 2020
  4. Junio C HamanoAug 31, 2020
  5. Jeff KingSep 1, 2020
  6. Philippe BlainSep 1, 2020
  7. brian m. carlsonSep 2, 2020
  8. Jeff KingSep 2, 2020
  9. Philippe BlainAug 30, 2020
  10. Makefile: add support for generating JSON compilation databasePhilippe Blain via GitGitGadget, Sep 1, 2020
  11. Junio C HamanoSep 2, 2020
  12. Philippe BlainSep 3, 2020
  13. Junio C HamanoSep 3, 2020
  14. Philippe BlainSep 3, 2020
  15. Makefile: add support for generating JSON compilation databasePhilippe Blain via GitGitGadget, Sep 3, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.