Adding Sonar coverage to legacy C++ repo with multiple sln/vcxproj files

SonarQube, CFamily plugin version:

I’ve been tasked with adding analysis (not code coverage) to a legacy C++ repo containing 250 solutions files with shared common code that are built as part of a single monolithic build. Static files (ex. HTML) are all analyzed, however Sonar is only showing C++ analysis from the final C++ solution builtd, as the build wrapper seems to clean the output directory on each run.

Breaking up the repo is off the table due to legacy constraints.

I have tried:

  • specifying a unique build wrapper output for each solution, but a comma delimited fails
  • invoking build-wrapper-win-x86-64.exe --out-dir <my_dir> bundle exec rake <my_target> (as per this link)
  • wrapping everything the in C# MSBuild sonar wrapper
  • specifying and using sub-modules in the file

Hello @BrianH and welcome to our community!

Indeed, can only take one directory. The only way to use several build-wrapper outputs is to run several analyses (with different project keys so that they do not overwrite one another).

What does <my_target> contain? The build command for each of your C++ solution files as written in the other post you mention? Other things?
What build command are you using?

Hi Amélie,

<my_target> was a rake script to do a build. Due to the legacy nature, I have some restrictions to work around. These 250 C++ solutions have to be compiled in a specific order, and one of the solutions in the middle actually hangs the build wrapper when it’s listening - I’m not sure how to troubleshoot that aspect… but I have a working “solution” where I build all 250 solutions using MSBuild without the build wrapper to ensure all the build requirements are met, and then generate a single batch file that does an MSBuild REbuild again on the valid 249 solutions, and I then invoke:

build-wrapper-win-x86-64.exe --out-dir #{my_dir} #{my_generated_batch}

This works, but is an embarrassing solution to end up with - but it is at least workable enough to let me go on vacation for August. If there are tips for trouble-shooting build-wrapper-win-x86-64 I’d be happy to try them in September!

Hi @BrianH ,

if I am understanding correctly the issue is during a single project/solution build, out of the 250. Could you try to run build-wrapper in isolation on the single hanging process? I would suggest trying to disable Windows defender and any other eventual antivirus as they may interfere with the build-wrapper.