[Top][All Lists]

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

Re: Create compile_commands.json for integration with other build system

From: Duane Griffin
Subject: Re: Create compile_commands.json for integration with other build systems and IDEs
Date: Mon, 30 Jul 2018 10:44:18 +1200

Hi Doron,

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.

If you want to generate a compilation database you can write makefile
rules to do that, however it will necessarily be at least somewhat
project-specific. For example, see the attached makefile module that
does this for us. Note that it references a bunch of variables defined
elsewhere, contains code that is specific to our needs, and will
certainly not work out-of-the-box for anyone else. It also assumes you
have other rules which are generating "ccmd" files containing the
exact compiler command invocations (you will need this anyway in order
to detect and handle compiler flags changing -- another thing that
ninja handles automatically that make cannot). Also it has a lot of
hackiness to deal with target-specific variables. So much regret:
learn from my mistakes! Do not use target-specific variables!


On Sun, Jul 29, 2018 at 3:13 AM, Doron Behar <address@hidden> wrote:
> 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, 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?
> _______________________________________________
> Bug-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-make

"I never could learn to drink that blood and call it wine" - Bob Dylan

Attachment: CompilationDB.mk
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]