I am trying to do a Sonar scan of Objective-C on an AWS Mac instance. The environment details are as follows:
Sonar server version: Developer Edition v10.8.1 (101195)
build-wrapper-macosx-x86: version 6.61
Sonar-scanner: 6.2.1
Mac server: Macmini8,1 (AWS Instance mac1.metal. )
Architecture of the system: x86_64
I first execute build-wrapper-macosx-x86, which generates the required JSON. Then, while executing sonar-scanner with the above-generated JSON, it doesn’t scan the code. I observed the following debug info in the log:
DEBUG Unpacking analyzer to: /opt/workspace/workspace/6.1/dev/Sonar-Mobile.MobileAuthenticationSDK.6.1-Iphone-v1/IPhone/SDK/SDK/.scannerwork/.sonartmp/238723421286715366
DEBUG Trying to get the architecture using ‘/usr/sbin/sysctl -n hw.optional.arm64’
DEBUG **No arm64 hardware support detected. The sysctl command exited with code (1)**:
DEBUG Total system memory: 32768MB
DEBUG Initial Java memory used: 54
DEBUG Java memory after analysis setup (used, peak): 45, 81
----
ERROR Error during SonarScanner Engine execution 08:23:41 java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
I would like to check if this '/usr/sbin/sysctl -n hw.optional.arm64' is the root cause of this failure? If yes, how can I override this behavior?r
thank you for the files. You are going to have to switch to generate a compilation database through xcode/clang. The configuration is described in [CPP-4941] - Jira
To generate a Compilation Database use Clang compiler feature to generate partial compilation database files and aggregate them. You need to set -gen-cdb-fragment-path on OTHER_CFLAGS of xcodebuild command line:
# add to your xcodebuild command: OTHER_CFLAGS="\$(inherited) -gen-cdb-fragment-path \$(PROJECT_DIR)/CompilationDatabase"
xcodebuild clean build arg1 .. argN OTHER_CFLAGS="\$(inherited) -gen-cdb-fragment-path \$(PROJECT_DIR)/CompilationDatabase"
pushd CompilationDatabase
sed -e '1s/^/[\'$'\n''/' -e '$s/,$/\'$'\n'']/' *.json > ../compile_commands.json
popd
Then properly set the sonar.cfamily.compile-commands property to point to the generated compile_commands.json.