Open abougouffa opened 1 year ago
I think it would have made more sense to submit these as two separate PRs, but please do not close this PR if you decide to split it.
Hello @snogge ,
Thank you for the reviews, I've fixed some of your spotted issues, mainly for the CMake+gcov stuff. I will try to fix documentation and tests issues later when I have some free time.
I will leave this PR for CMake+gcov stuff. So reverted the highlighting commit, I will open a separate PR for that.
To respond to your comments, for the compile_commands.json
file, it is indeed an optional output of CMake (can be enabled by passing -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
to cmake
when configuring the project).
The file is generally generated in the build directory, so when configuring a CMake project with a command like this:
cmake -S . -B build/debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
The compile_commands.json
will be generated under build/debug/compile_commands.json
; however, the common workflow with CMake projects is to symlink this file in the project's root directory. This enables LSP servers to find the right build options for the project (enabled compiler features, system libraries, include paths, ...).
So I think it is Ok to assume the file is in the root directory, but if it is not, the cov--locate-gcov-cmake
returns nil, so we can test other rules.
I've added a last check in the function to assure the generated .gcov
file actually exists. This will help to avoid shadowing other functions in cov-coverage-file-paths
with files that doesn't exist.
I will try later to add a toy example for a CMake based project to test the code, as well as mentioning this in the README file.
For CMake projects, the
.gcov
files aren't stored beside the source file, instead, they are placed next to the generated object files (in CMake projects, it will be somewhere likepath/to/build/dir/CMakeFiles/target.src/path/to/file/file.cpp.gcov
)Also, as CMake generates object files as
file.cpp.o
instead offile.o
, gcov generates a file based on thatfile.cpp.gcov
and notfile.gcov
.I've added a function which leverages the information included in the
compile_commands.json
, it extracts the build directory and the build command for the file, and then constructs the path to the.gcov
file which will be next to the.o
file.The second commit adds support for line highlighting with bright versions of
cov-*-face
s. This feature is configurable viacov-highlight-lines
, I've set its initial value tonil
.Here are some examples:
cov-highlight-lines = t, cov-coverage-mode = t
cov-highlight-lines = t, cov-coverage-mode = nil