Discussion:
Make autoconf and automake generate compile_commands.json for integration with other build systems and IDEs
Doron Behar
2018-07-24 16:59:21 UTC
Permalink
Many build systems, IDEs and text editors plugins, integrate with source
code files using a compilation database. It is `compile_commands.json`
and it is placed in a project's root directory.

It is best explained here:
https://clang.llvm.org/docs/JSONCompilationDatabase.html

As listed here:
(https://github.com/cquery-project/cquery/wiki/compile_commands.json),
some build systems support it out of the box (ninja, cmake and waf) -
(https://ninja-build.org/ https://cmake.org https://waf.io/)

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, through `automake` or `autoconf`.

I think it would be worth the effort of the developers, what do you guys
think?
Basin Ilya
2018-07-24 19:47:20 UTC
Permalink
Hi Doron.

The list of source files and resulting object files isn't known until `make` is launched. The IDE should be ready to support a constantly updating compilation database.

It is possible to create a wrapper program for GNU Make that will do the job. It won't be part of Make, you will have to install it separately. An IDE can be configured to run the wrapper instead of the real Make binary.

The wrapper can handle the shell commands executed by Make. For instance, it can pass these commands and other information to another component that will update the compilation database.

I have a script that stores the needed info in a binary format, but somebody has to write at least the part that reads the binary data from the standard input and converts it to JSON.

I think this question belongs to the GNU Make mailing list, not Autotools.
Post by Doron Behar
Many build systems, IDEs and text editors plugins, integrate with source
code files using a compilation database. It is `compile_commands.json`
and it is placed in a project's root directory.
https://clang.llvm.org/docs/JSONCompilationDatabase.html
(https://github.com/cquery-project/cquery/wiki/compile_commands.json),
some build systems support it out of the box (ninja, cmake and waf) -
(https://ninja-build.org/ https://cmake.org https://waf.io/)
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, through `automake` or `autoconf`.
I think it would be worth the effort of the developers, what do you guys
think?
Tom Tromey
2018-07-26 19:20:18 UTC
Permalink
Post by Basin Ilya
The list of source files and resulting object files isn't known until
`make` is launched.
It seems to me that Automake knows more about the build than a generic
system would, and could implement this. Well, at least it could in most
cases, for example those where all the sources are visible in the
Makefile.am.

FWIW this is the second time in the last week or so that I've heard this
request. It seems like a reasonable thing to attempt.

Tom
Doron Behar
2018-07-28 12:25:47 UTC
Permalink
Post by Basin Ilya
Hi Doron.
The list of source files and resulting object files isn't known until `make` is launched. The IDE should be ready to support a constantly updating compilation database.
It is possible to create a wrapper program for GNU Make that will do the job. It won't be part of Make, you will have to install it separately. An IDE can be configured to run the wrapper instead of the real Make binary.
The wrapper can handle the shell commands executed by Make. For instance, it can pass these commands and other information to another component that will update the compilation database.
I have a script that stores the needed info in a binary format, but somebody has to write at least the part that reads the binary data from the standard input and converts it to JSON.
I wonder how this script compares to the tool I mentioned called
`scan-build` (https://github.com/neomutt/neomutt/issues/1014). Could you
please share it with us?
Ilya Basin
2018-07-28 13:41:22 UTC
Permalink
https://gist.github.com/basinilya/9320b806efacece314c2ad16524993c1
Post by Basin Ilya
Post by Basin Ilya
Hi Doron.
The list of source files and resulting object files isn't known until
`make` is launched. The IDE should be ready to support a constantly
updating compilation database.
Post by Basin Ilya
It is possible to create a wrapper program for GNU Make that will do the
job. It won't be part of Make, you will have to install it separately. An
IDE can be configured to run the wrapper instead of the real Make binary.
Post by Basin Ilya
The wrapper can handle the shell commands executed by Make. For
instance, it can pass these commands and other information to another
component that will update the compilation database.
Post by Basin Ilya
I have a script that stores the needed info in a binary format, but
somebody has to write at least the part that reads the binary data from the
standard input and converts it to JSON.
I wonder how this script compares to the tool I mentioned called
`scan-build` (https://github.com/neomutt/neomutt/issues/1014). Could you
please share it with us?
immanuel litzroth
2018-07-28 15:48:31 UTC
Permalink
This is a tool that generates a compilation database from a make file:
https://github.com/rizsotto/Bear
i
Post by Basin Ilya
Post by Basin Ilya
Hi Doron.
The list of source files and resulting object files isn't known until
`make` is launched. The IDE should be ready to support a constantly
updating compilation database.
Post by Basin Ilya
It is possible to create a wrapper program for GNU Make that will do the
job. It won't be part of Make, you will have to install it separately. An
IDE can be configured to run the wrapper instead of the real Make binary.
Post by Basin Ilya
The wrapper can handle the shell commands executed by Make. For
instance, it can pass these commands and other information to another
component that will update the compilation database.
Post by Basin Ilya
I have a script that stores the needed info in a binary format, but
somebody has to write at least the part that reads the binary data from the
standard input and converts it to JSON.
I wonder how this script compares to the tool I mentioned called
`scan-build` (https://github.com/neomutt/neomutt/issues/1014). Could you
please share it with us?
Doron Behar
2018-07-28 15:59:30 UTC
Permalink
I'm aware of that. Plus, the author of `Bear` is the same author of
`scan-build`. I've had a discussion with him about the duplicity of
those two tools which seem to be doing the same thing. I just think that
such a tool should be an official part of `make`.

I've sent an mail to the Make mailing list about it.
Post by immanuel litzroth
https://github.com/rizsotto/Bear
i
Post by Basin Ilya
Post by Basin Ilya
Hi Doron.
The list of source files and resulting object files isn't known until
`make` is launched. The IDE should be ready to support a constantly
updating compilation database.
Post by Basin Ilya
It is possible to create a wrapper program for GNU Make that will do the
job. It won't be part of Make, you will have to install it separately. An
IDE can be configured to run the wrapper instead of the real Make binary.
Post by Basin Ilya
The wrapper can handle the shell commands executed by Make. For
instance, it can pass these commands and other information to another
component that will update the compilation database.
Post by Basin Ilya
I have a script that stores the needed info in a binary format, but
somebody has to write at least the part that reads the binary data from the
standard input and converts it to JSON.
I wonder how this script compares to the tool I mentioned called
`scan-build` (https://github.com/rizsotto/scan-build). Could you
please share it with us?
Loading...