[cfe-dev] CompilationDatabase support added to libclang and python binding

Arnaud de Grandmaison arnaud.allarddegrandmaison at parrot.com
Fri Jul 6 00:53:04 PDT 2012


Hi David,

Good catch. This is a leftover from when I was looking for the
invariants. Although probably true in practice, this all depends on how
the CMake build rules have been written. They are usually written like
this :

SET(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER>  <DEFINES> <FLAGS> -o
<OBJECT> -c <SOURCE>")

Where each variable betwen '<>' is expanded by cmake to create the
actual rule. We can not rely on <SOURCE> being the last argument,
especially since everyone can add its own toolchain file + build rules,
for cross compiling for example.

I will fix this part of the python binding comment.

For now it seems cmake only output compile commands for rules creating
object files (c -> obj, cpp -> obj, ... ). Other commands (linking, file
generation, ... ) are not considered, and are thus not part of the
CompilationDatabase --- as of cmake-2.8.7

Cheers,
--
Arnaud de Grandmaison

On 07/06/2012 08:46 AM, David Röthlisberger wrote:
> On 11 Jun 2012, at 09:32, Arnaud de Grandmaison wrote:
>> I am done adding the CompilationDatabase functionality to libclang
>> and the python binding
> Hi Arnaud
>
> Thanks for your work on this -- I see it has now made it onto trunk!
> Looking at using it from python, I have a question:
>
> The docstring for clang_CompileCommand_getArg in CXCompilationDatabase.h
> says:
>
>> Invariant :
>>  - argument 0 is the compiler executable
> Whereas the python CompileCommand.arguments says:
>
>> Invariants :
>>   - the first argument is the compiler executable
>>   - the last argument is the file being compiled
> Is that last invariant actually true? If so, does it hold only for the
> python, or also the C function? What happens for a command line
> compiling and linking multiple source files at once: There would be
> multiple entries in the compilation database (one per source file) so
> will libclang re-order the command-line entry for each source file so
> that the file in question comes last?
>
> Thanks!
> --Dave
>
>


-- 
Arnaud de Grandmaison
Senior CPU engineer
Business Unit Digital Tuner

Parrot S.A.
174, quai de Jemmapes
75010 Paris - France
Phone: +33 1 48 03 84 59




More information about the cfe-dev mailing list