Hi,
Since the build-wrapper is no longer supported, we’re using sonar-scanner
to analyze our C++ Xcode project.
As described we create our compile_commands.json
via
xcodebuild ... OTHER_CFLAGS="\$(inherited) -gen-cdb-fragment-path \$(PROJECT_DIR)/CompilationDatabase"
followed by this sed expression
sed -e '1s/^/[\'$'\n''/' -e '$s/,$/\'$'\n'']/' ...
And this works fine for sonar-scanner. That is if you perform an additional compilation w/o the OTHER_CFLAGS
option and thus require two compilations for every analysis.
However, clangd (e.g. used in VS Code / clang-tidy) has problems with this file.
For clangd I need to create the compile_commands.json
via xcpretty:
xcodebuild ... | xcpretty -r json-compilation-database -o build/compile_commands.json
Can anyone tell me what the difference is between these approaches? Ideally, we could use the same compile_commands.json
for both purposes. It would be even better if sonar-scanner could process the xcpretty version, because this doesn’t require an additional compilation.