Hi, I have problems with analysing C++/Objective-C project with sonar-scaner
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
* you are using the latest version of the build-wrapper and the CFamily analyzer
* you are correctly invoking the scanner with correct configuration
* your compiler is supported
* you are wrapping your build correctly
* you are wrapping a full/clean build
* you are providing the path to the correct build-wrapper output directory
Can you help with this, I can also provide with build-wrapper.log or build-wrapper-dump.json. Thanks in advance !
The issue you are facing is most likely caused by the configuration problem. For analysis to work correctly, you need to provide the information about build of the project to the scanner. This information can be presented either as:
build-wrapper output - generated by wrapping your build by build-wrapper
If you are using build wrapper, please make sure that the same directory is passed as --out-dir to build-wrapper invocation sonar.cfamily.build-wrapper-output to sonnar-scanner. Note that this two invocation needs to be performed on same machine.
I misinterpreted the error in your first message, the build-wrapper-dump.json was found in your case (it means that the configuration was right), but it was essentially empty. Please accepts my apologies for the confusion.
They may be multiple reasons for the empty build wrapper, and for further investigation, it would be best if you could share the content of the build wrapper output directory ($WORKSPACE/sq_wrapper). If you are not comfortable sharing it publicly, let us know, and we’ll send you a private message that will allow you to send it privately.
Finally, as this is C++/Objective-C++ project, do you use macOS with Apple Silicon hardware (ARM architecture) for the build? In such a case, you need to use a compilation database.
I checked the output of the build-wrapper, and for the xcodebode build, we capture only commands to build set of swift files using , and includes (if I understand correctly) some Objective-C headers. We currently support analysis for the project that compiles C/Objective-C/C++ files and we analyze headers that are included in them.
Could you please validate that provided command is compiling some C++/Objective-C sources? One way would be to temporarily modify one such file to cause a compilation error and see if the build failed.
Also, I have noticed that you are using the following setting in the properties:
This one is used by a third-party plugin and we do not recognize it.
I wrote to the developers using this command - they said that it does compile the code when looking at the output of the command:
CompileC /Users/jenkins/Library/Developer/Xcode/DerivedData/Project-dvamnhvicvcntbbcqaqmxzsiqcdy/Build/Intermediates.noindex/ArchiveIntermediates/Project/IntermediateBuildFilesPath/aaaaaa.build/Release-iphoneos/aaaaaa.build/Objects-normal/arm64/CocosLogger.o /Volumes/bigdisk0/builds/workspace/Mobile/ProjectTC_SQ1/platform/modules/client_shared/cocos/CocosLogger.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'aaaaaa' from project 'aaaaaa')
Also I did remove:
but same behaviour. Could it be because we use -workspace "my.xcworkspace" ?
I have noticed that the CompileC entries in your build output use ccache-clang to build a process file (it is on the last line on each entry). Could you please try to configure the build to use plain clang instead of cache-clang and see if that fixed the issue?
Also, if you could provide more information on what ccache-clang is doing, that would be helpfull.
The purpose of clang-ccache is to speed up recompilation by caching previous compilations and detecting when the same compilation is being done again. Unfortunatelly switching to plain clang did not resolve the issue, It is sitll giving the same error as before.
sorry for the delay, I’ll follow up on your topic.
I would like you to do 2 tests:
run build-wrapper-macosx-x86 --out-dir $WORKSPACE/sq_wrapper /usr/bin/xcodebuild ... clean archive without ccache-clang. Can you confirm it is working without your ccache-clang interception? I would like to clarify that before going further with the investigation