Skip to content

Build using compile_commands.json to automatically assign language for discovered sources #1321

@i-garrison

Description

@i-garrison

There are issues using current CDT (with original Indexer) with GDB The GNU Project Debugger sources. I understand there is a new cdt-lsp to try - unfortunately that is not as usable for me at the moment so maybe we can improve original implementation too.

Currently GDB The GNU Project Debugger sources are a mix of C and C++ language code where lots (about 500) of files have .c extension but are in fact already transitioned to C++ and are compiled using C++ compiler (here, g++). The other lots (also about 500) of .c files are remaining C code and that of dependencies which are also in C language and are compiled using C compiler (here, gcc). The major issues I see are:

  1. I'm unable to configure CDT Indexer properly since I only know about file type mappings by file extension.
    With that I can either configure per-project File Types entry*.c -> C++ source file which breaks Indexer for the other half because lots of C constructs are not valid C++, or do nothing and C++ half of files is not parsed properly because C Indexer parser is used.

  2. I'm using Compilation Database Parser with GDB sources and it helps a lot but at the moment compilation database parser ask project to select language for discovered source file and uses that information to populate language-specific entry for macros etc..
    This does not work for GDB source since about half of .c files are C++ and due to first issue discovered macros end up in the wrong language-specific bin with 50% chance.

Ideally I'd like Compilation Database Parser to use discovered language type from compilation database and configure language for discovered source files in project for me. It already knows which compiler (e.g. g++ or gcc) is used for each of compiled files so this should be possible. This probably requires adding a mapping selection of compiler to language in compilation database parser options but that should not be hard part.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions