-
Notifications
You must be signed in to change notification settings - Fork 20
gcov: add support for CMake-based projects and UI enhancement #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
ac73ff7
44c2f0b
f9b4c7b
933e3d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,7 +141,7 @@ COVERAGE-TOOL has created the data. | |
| Currently the only supported COVERAGE-TOOL is gcov.") | ||
|
|
||
| (defvar cov-coverage-file-paths | ||
| '("." cov--locate-lcov cov--locate-coveralls cov--locate-clover cov--locate-coveragepy) | ||
| '("." cov--locate-gcov-cmake cov--locate-lcov cov--locate-coveralls cov--locate-clover cov--locate-coveragepy) | ||
| "List of paths or functions returning file paths containing coverage files. | ||
|
|
||
| Relative paths: | ||
|
|
@@ -260,6 +260,26 @@ that filename. Otherwise search for the first matching pattern in | |
| cov-lcov-patterns))) | ||
| (when lcov-file (cons lcov-file 'lcov)))) | ||
|
|
||
| (defun cov--locate-gcov-cmake (file-dir file-name) | ||
| "Locate a gcov coverage file from FILE-DIR for FILE-NAME. | ||
| This works with CMake-based projects, by constructing the path to the `.gcov' | ||
| file from object file's path extracted from the \"compile_commands.json\"." | ||
| (when-let* ((root (project-root (project-current))) | ||
| (compile-commands (expand-file-name "compile_commands.json" root))) | ||
| (when (file-exists-p compile-commands) | ||
| (when-let* ((file-cmd (cl-find-if | ||
| (lambda (entry) | ||
| (equal (file-truename (alist-get 'file entry)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback, I fixed this! |
||
| (expand-file-name file-name file-dir))) | ||
| (json-read-file compile-commands))) | ||
| (command (alist-get 'command file-cmd)) | ||
| (directory (alist-get 'directory file-cmd))) | ||
| (let* ((obj-file (when (string-match | ||
| (concat "-o \\(?1:.*" (regexp-quote (concat file-name ".o")) "\\)") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This match looks fragile to me. What if there is no space between -o and the file name for instance?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well spotted, I've changed it to |
||
| command) | ||
| (match-string-no-properties 1 command)))) | ||
| (cons (expand-file-name (file-name-with-extension obj-file ".gcov") directory) 'gcov)))))) | ||
|
|
||
| (defun cov--locate-coveralls (file-dir _file-name) | ||
| "Locate coveralls coverage from FILE-DIR for FILE-NAME. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when-let*was introduced in Emacs 26 (as far as I can tell). cov.el supports Emacs 24.4 onward. Please use other means to do this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, I fixed this!