I am using 8.6.1. And I am trying to run build-wrapper on a project that has a toplevel Makefile, and which calls multiple subdirectories makefiles. build-wrapper isn’t capturing the correct path relative to code root, and sonar-scanner isn’t working. I would like to avoid having to modify the subdirectory makefiles if at all possible. How can I do this?
build_root/
Makefile
subdir1/
subdir2/
In makefile:
mybuild:
make -C subdir1
make -C subdir2
please write how you are using build-wrapper and invoking sonar-scanner.
It should be as easy as:
cd toproot
build-wrapper --out-dir cfamily-output make clean all
sonar-scanner -Dsonar.sources=. -Dsonar.cfamily.build-wrapper-output=cfamily-output -D......
yes my build-wrapper and sonar-scanner commands look the same. But I end up getting the error below. If I look at sonar_output/build-wrapper-dump.json, the paths are not correct. For example to add to the above drawing, I see stuff like “src/app1.cpp”, instead of “subdir1/src/app1.cpp” which I think is the problem.
you should take into the consideration the cwd too. Would you be able to share the build-wrapper output folder, the tree list of your folder, and the entire sonar-scanner output log? I can send you a PM if you prefer to share privately.
Sorry for the delay as I was out of town. I was able to try to make a smaller build environment to help debug this, and I don’t think it is the subdir’s that is the issue, as it must be something with the legacy build files I am using for this project. Because I created 2 simple subdir’s builds and sonarqube does find it, but doesn’t find liblegacy correctly. Attached is the output log. So if you could see what is wrong with the liblegacy portion.build-wrapper.zip (20.3 KB)
I can see all correct compiler invocations, for all the files you listed. I believe you are creating a problem from something which is not a problem and a simple and common use case.
Yes but in the end in the analysis that gets sent to sonarqube, and view the code analyzed only the 2 subdirs/src/main.cpp show up, and none of the liblegacy/src/*.cpp files.
I do see this in my sonar-scanner output:
INFO: Indexing files...
INFO: Project configuration:
INFO: Included sources: **/*.h, **/*.cpp, **/*.hpp, **/*.c
INFO: Excluded sources: **/*.js
INFO: 2 files indexed
INFO: 418 files ignored because of inclusion/exclusion patterns
INFO: 14 files ignored because of scm ignore settings
this has nothing to do with the build-wrapper. This has to do with the sonar-scanner invocation working directory, the sonar.sources, the sonar.inclusions property, the sonar.exclusions property and the scm ignore property.
Ok to be clear on my problem, in this example why isn’t a file like ./liblegacy/src/u_messaging.cpp being submitted to sonarqube, whereas ./subdir1/src/main.cpp is?
Ok now I see these incriminating lines, and I did check that it is not covered by a .gitignore file, but it is inside a git submodule, so I wonder if this is confusing scanner?
11:17:41.496 DEBUG: File ‘/mnt/sonar_test/liblegacy/include/u_messaging.h’ is excluded by the scm ignore settings.