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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-08-30 at 19:28:27, Philippe Blain via GitGitGadget wrote:
> From: Philippe Blain <levraiphilippeblain@xxxxxxxxx>
> 
> 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.

So I'm very much in favor of a change like this.

> +ifeq ($(GENERATE_COMPILATION_DATABASE),yes)
> +all:: compile_commands.json
> +compile_commands.json:
> +	@$(RM) $@
> +	$(QUIET_GEN)sed -e '1s/^/[/' -e '$$s/,$$/]/' $(compdb_dir)*.o.json > $@+
> +	@if test -s $@+; then mv $@+ $@; else $(RM) $@+; fi
> +endif

How are those commas at the end of the line added?  Are they natively
part of the files?  If so, this seems reasonable.
-- 
brian m. carlson: Houston, Texas, US

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux