[cfe-dev] Compilation Database format

Manuel Klimek klimek at google.com
Mon Mar 2 01:06:55 PST 2015


Hi Pierrick,

On Mon, Mar 2, 2015 at 1:58 AM Pierrick Bouvier <bouvier.pierrick at yahoo.fr>
wrote:

> Hello Clang community,
>
> I am currently working on a tool able to generate a compilation database
> by catching all exec done, something similar to
> https://github.com/rizsotto/Bear but with the end goal of providing more
> than just this feature to user (I want to use libclang for providing
> autocompletion, refactoring, stats and other stuff related to user's
> codebase, independently of any editor or IDE).
>
> I really like the idea of compilation database, and I have a few
> questions that were not answered by the manual page:
> http://clang.llvm.org/docs/JSONCompilationDatabase.html
>
> Those are my questions:
> 1) Is that possible to provide a cwd relative to compilation database
> file itself? What I aim is possibility for user to move his source
> folder from place without having to use sed or regenerate the
> compilation database. For example, if compilation database is
> "/my/project/compilation_database.json" and my source is in
> "/my/project/src/main.cpp" I want to offer cwd as "src/" and source file
> as "main.cpp". Is this correct and more than all, is that supported by
> libclang?
>

I don't think that's currently supported, but patches are welcome :)


> 2) Is that possible to extend compilation_database without breaking
> libclang? I would like to add a list of fields named "dependency" to
> precise which files the source depends on. This can be used for creating
> statistics or simply to know if file (or any dep) has changed without
> having to preprocess, thus enabling speedlight on big projects.
> For example:
>    - cwd "src/"
>    - file "main.cpp"
>    - command ...
>    - dependency "/usr/include/stdio.h"
>    - dependency "/usr/include/stdlib.h"
>
> If those feature are not possible with current libclang, and if you
> agree, I can work on a patch to make this possible.
>

Two part answer:
a) regarding local extensions to the command line database: I'd suggest not
to do them; the probability we hit incompatibilities seem high enough, and
it seems easy to just put another json file next to the compilation
database having all your extra data
b) regrading dependencies: I'm not sure the compilation database is the
right venue for that; that's why we have build systems; if you want
dependencies, you'll immediately need information on how to build those
dependencies, and suddenly you have a new build system

Cheers,
/Manuel


>
> Thank you, and thank you again for providing clang/llvm to people.
> Pierrick
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150302/15bd87e8/attachment.html>


More information about the cfe-dev mailing list