- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
- SonarQube - 9.9.2
- sonar-scanner-5.0.1.3006-windows
- how is SonarQube deployed: zip, Docker, Helm
- zip
- what are you trying to achieve
- analyze C project with compilation database
hi
I am using SonarQube to analyze a C project with a compilation database and this is my command
sonar-scanner.bat -X -D"sonar.projectKey=Test1030-2" -D"sonar.sources=C:\ProgramData\Jenkins\.jenkins\workspace\sonarTest" -D"sonar.inclusions=**/*.c, **/*.h" -D"sonar.sourceEncoding=utf-8" -D"sonar.cfamily.compile-commands=C:\ProgramData\Jenkins\.jenkins\workspace\sonarTest\compile_commands.json" -D"sonar.host.url=http://localhost:9000" -D"sonar.login=sqp_f****************d87ed"
But I encountered the following error: “The Compilation Database JSON file was found but 0 C/C++/Objective-C.” I want to know if my compile_commands.json file is not being recognized correctly or if there is another reason for this?
18:00:40.668 DEBUG: C:\ProgramData\Jenkins\.jenkins\workspace\sonarTest\PWR_Platform\ep_mfg_nvs_data.h not marked as unchanged: file added
18:00:40.669 DEBUG: C:\ProgramData\Jenkins\.jenkins\workspace\sonarTest\GUI\lvgl_app\widgets\gl_dot_anim.h not marked as unchanged: file added
18:00:40.669 DEBUG: C:\ProgramData\Jenkins\.jenkins\workspace\sonarTest\PWR_Platform\app\app_version.c not marked as unchanged: file added
18:00:40.669 INFO: 0/974 files marked as unchanged
18:00:40.670 INFO: Cache: 0/0 hits, 126 bytes
18:00:40.670 INFO: 0 compilation units analyzed
18:00:40.744 INFO: ------------------------------------------------------------------------
18:00:40.745 INFO: EXECUTION FAILURE
18:00:40.751 INFO: ------------------------------------------------------------------------
18:00:40.752 INFO: Total time: 57.856s
18:00:40.795 INFO: ------------------------------------------------------------------------
18:00:40.796 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The Compilation Database JSON file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
* you are correctly invoking the scanner with correct configuration
* your compiler is supported
* you are providing the path to the correct Compilation Database JSON
* you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:494)
and this is the format of my compile_commands.json :
[
{
"directory": "C:/ProgramData/Jenkins/.jenkins/workspace/sonarTest",
"command": "C:/ITEGCC/bin/arm-none-eabi-gcc.exe -DAPP=2 -O3 -g3 -DNDEBUG -o CMakeFiles/PWR_Platform/app_func_sub.c.obj -c C:/ProgramData/Jenkins/.jenkins/workspace/sonarTest/app_func_sub.c",
"file": "C:/ProgramData/Jenkins/.jenkins/workspace/sonarTest/app_func_sub.c"
},
{
"directory": "C:/ProgramData/Jenkins/.jenkins/workspace/sonarTest",
"command": "C:/ITEGCC/bin/arm-none-eabi-gcc.exe -DAPP=2 -O3 -g3 -DNDEBUG -o CMakeFiles/PWR_Platform/app_key.c.obj -c C:/ProgramData/Jenkins/.jenkins/workspace/sonarTest/app_key.c",
"file": "C:/ProgramData/Jenkins/.jenkins/workspace/sonarTest/app_key.c"
}
]
thanks