Compilation database compile_commands.json is not created when using build-wrapper and MSBuild

On-Premise Sonarqube Enterprise EditionVersion 9.9 (build 65466)
Build Wrapper version:6.41

C++ Build via build-wrapper as follows:

$ build-wrapper-win-x86-64.exe --out-dir wrapperDir MSBuild.exe temp_${it.substring(4)}.vcxproj /m:2 “”"

Creates the following files:

wrapperDir/build-wrapper.log
wrapperDir/build-wrapper-dump.json

According to the documentation the build-wrapper should also create the compilation database, compile_commands.json in the same directory

Docs reference:

Can anyone please advise if we are missing any configuration that will trigger compile_commands.json to be created?

Many thanks
Janko Linhart

Hey there.

You’re looking at the docs for SonarCloud. I suggest making sure you look at the docs for your specific version of SonarQube. In v9.9 LTS, a compilation database isn’t generated by the build wrapper.

Thanks for the reply Colin, agreed and I’m aware the doc is for Sonarcloud.

Considering the wrapper runs on the build client to observe the build locally I expected its behaviour to be the same.

Do you have any pointers how to generate the compilation database with this setup?

The build wrapper version is tied to the version of SonarQube, which controls the behavior.

It can be generated by tools like CMake and Ninja, as documented.

If you’re already using the build wrapper, why are you trying to generate a compilation database? For something else?

I’m experiencing a little confusion in this area too. We have a huge project where we run the build-wrapper and sonar-scanner in a daily CI job, with the wrapper downloaded from the SonarQube instance as part of the job to ensure that we always use the correct one. So far so good.

We want to enable the developers to use SonarLint in VSCode, but even when it is configured to use connected mode it seems that it wants a local compile_commands.json file. Shouldn’t it be able to pull that information from the server? The build system used by the developers’ day to day work is a bit of a clunky hodgepodge so it’s not a simple task to generate the file in their local workspaces.

Any suggestions?

I was hoping to get a cross-platform analysis running with the compilation database as it won’t work with the build wrapper. Abandoned that approach in the end as the scanner always probes the compiler first, I assume it would have been the same using the compilation database.
I have now successfully used the wrapper dump, analysis runs runs fine with that.