[clangd-dev] compile_commands.json for an unusual file structure
Mikael Springer via clangd-dev
clangd-dev at lists.llvm.org
Tue May 28 00:29:11 PDT 2019
Hi.
We have our code structured in a somewhat unusual way. All *.cpp source files are included (#include …) in a number of *_package.cpp files. These *_package.cpp files are the ones configured in a Xcode project and in a Visual Studio project. The primary reason for this organization is to minimise the need to update Xcode and Visual Studio projects when adding new source files to the project (one just includes the new file in a suitable *_package.cpp file which is already a part of the project).
A consequence of this is that only the *_package.cpp files are visible in the compilation output. When we generate a compile_commands.json (using xcpretty since I’m on MacOS and using Xcode) this compilation database only contains entries for the *_package.cpp files. If I want to use for example Emacs and LSP this doesn’t work since a large part of the code base is not in the compilation database.
Would it be possible to add entries for each cpp source file that is included in the *_package.cpp files to the compile_commands.json (using a script). Would Clangd be able to parse this correctly? The idea is to copy the corresponding *_package.cpp entry in which the source file is included and alter the “file” part of the entry to refer to the source file instead, but leave the “command” part intact. This makes sense in a way since this is the way the source file is compiled even if it doesn’t show. Can Clangd work with this input?
Regards, Micke.
More information about the clangd-dev
mailing list