Scanner fails if nested build output directories don't exist when using compile_commands from qbs

Some of the projects in my company are using qbs. And I tried to change the sonarqube job that analyzes one of those from using the build wrapper to using compile_commands instead. This seems like it’s a fairly straight forward transformation to make, since you can easily generate a compilation database from qbs.

However, I ran into this issue
java.lang.IllegalStateException: java.io.IOException: Cannot run program "C:/BuildTools/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/cl.exe" (in directory "C:\builds\company-products\someproduct\build\release\SomeProduct.ddc819e0"): CreateProcess error=267, The directory name is invalid

Which seems to indicate that the scanner requires each build output directory to exist already. However, it seems like a qbs project creates a separate nested output directory for each Project that is part of the build. And when only generating the compilation database, these directories aren’t created by default.

If I have the build script first build the project before generating the compilation database, then I can run the scanner using the compile_commands.json.

So I’m wondering if the best solution here to figure out qbs can create the relevant directories in addition to the compilation database, or if the scanner could create relevant directories if they don’t already exist.

Otherwise, building the project using the build wrapper continues to work. I was just hoping to migrate to using a compilation database for the purpose of avoiding a full project build.

Hi @torgeir.skogen ,

We use the directory specified in the compile_commands.json, we expect those folders to be available. I see different options here:

  • still build the project, but instead of a full rebuild, do an incremental build with compilation database generation
  • report the issue to qbs
  • post-process the compile_commands.json to have valid directories, either by creating those folders yourself or by editing the folders to existing ones