3 ms·
Is this really a major problem? Is there any tool that supports generating the database without compiling? I think the answer to both of these is "no". In fact
by wakawaka28 2y ago
Is this really a major problem? Is there any tool that supports generating the database without compiling? I think the answer to both of these is "no". In fact I can't even think of a reasonable case where it would be even a minor problem.
- jchw 2y agoNinja and CMake do. It's especially useful if you want a compilation database for a project that takes an extremely long time to build.
- wakawaka28 2y agoCMake does but I think you have to attempt a build to get the database. On the other hand I don't think that should be necessary, as it is capable of generating Ninja build files. Almost nobody is writing Ninja files by hand. If you have to write something along those lines by hand, Makefiles would make more sense than Ninja. If Ninja does support exporting commands, it's a use case that doesn't matter because almost everyone uses CMake-generated Ninja files.
- jchw 2y agoYou do not need to attempt a build with CMake. Also, that's kind of the point of mentioning Ninja. Inherently, anything that uses Ninja is in the same boat and doesn't need to start a build.
- wakawaka28 2y agoThe only thing I know that uses Ninja is CMake and I'm sure CMake does not require Ninja to generate the database.
- jchw 2y agoThe most obvious example is the build system of Chromium, which uses gn. They do have a wrapper script to actually generate the compile_commands.json file, but it's just a thin wrapper around Ninja's built-in capabilities. (I'm not sure that CMake's isn't, on that note; I'm pretty sure it's ability to build the database is in fact dependent on which generator you're using.)
- mathstuf 2y agoYes, only generators where CMake actually controls the command line itself support compilation databases (basically, non-IDE generators). FD: CMake developer
- ithkuil 2y agoIirc there is also a bazel module that does that for bazel projects and only uses the query functionality without running an actual build
- maccard 2y agoNinja does it. Visual Studio does it. > In fact I can't even think of a reasonable case where it would be even a minor problem. On my last project, a build took 2+ hours on a 128 core threadripper. It wasn't every day that the lowest level stuff changed, but it was probably once a sprint or so. Waiting 2 hours for the compilation database to be ready isn't tenable. Rider and Visual Studio could generate a usable model of the project in 2-3 minutes.
- wakawaka28 2y agoOK that does sound like an actual problem. But I think you would only be in a position to need to do it that way if you don't use CMake, Ninja, or one of those other tools. Bear works the way it does because it's kind of a hack. I have only wanted to use it for Make projects. If the problem is big enough for you and constant enough then you can switch tools to avoid having to compile. It's just an uncommon problem IMO.