Created
June 12, 2019 19:13
-
-
Save ambroff/64e9e9cc7ac1000366c05e5ed59cca95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/code-coverage.cmake b/code-coverage.cmake | |
index 76f1762..f2dd41f 100644 | |
--- a/code-coverage.cmake | |
+++ b/code-coverage.cmake | |
@@ -241,10 +241,13 @@ function(target_code_coverage TARGET_NAME) | |
DEPENDS ccov-run-${TARGET_NAME}) | |
if(LLVM_COV_VERSION VERSION_GREATER_EQUAL "7.0.0") | |
+ set(EXCLUSIONS_STRING) | |
foreach(EXCLUDE_ITEM ${target_code_coverage_EXCLUDE}) | |
set(EXCLUDE_REGEX ${EXCLUDE_REGEX} | |
-ignore-filename-regex='${EXCLUDE_ITEM}') | |
+ string(APPEND EXCLUSIONS_STRING "${EXCLUDE_ITEM}\n") | |
endforeach() | |
+ file(WRITE ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/exclusions/${TARGET_NAME}.txt "${EXCLUSIONS_STRING}") | |
endif() | |
add_custom_target(ccov-show-${TARGET_NAME} | |
@@ -396,6 +399,10 @@ function(add_code_coverage_all_targets) | |
endforeach() | |
endif() | |
+ add_custom_target(ccov-exclusions | |
+ COMMAND cat ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/exclusions/* | sort -u | sed '/^[[:space:]]*\$$/d' | tr '\\n' '|' | sed 's/|$$//' > ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/exclusions.txt | |
+ ) | |
+ | |
add_custom_target( | |
ccov-all-report | |
COMMAND | |
@@ -410,10 +417,19 @@ function(add_code_coverage_all_targets) | |
${LLVM_COV_PATH} show `cat ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/binaries.list` | |
-instr-profile=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.profdata | |
-show-line-counts-or-regions | |
+ -ignore-filename-regex=`cat ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/exclusions.txt` | |
-output-dir=${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged | |
-format="html" ${EXCLUDE_REGEX} | |
- DEPENDS ccov-all-processing) | |
+ DEPENDS ccov-all-processing ccov-exclusions) | |
+ add_custom_target( | |
+ ccov-all-txt | |
+ COMMAND ${LLVM_COV_PATH} show `cat ${CMAKE_BINARY_DIR}/ccov/binaries.list` | |
+ -show-line-counts-or-regions | |
+ -ignore-filename-regex=`cat ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/exclusions.txt` | |
+ -instr-profile=${CMAKE_BINARY_DIR}/ccov/all-merged.profdata > ${CMAKE_BINARY_DIR}/coverage.txt | |
+ DEPENDS ccov-all-processing ccov-exclusions | |
+ ) | |
elseif(CMAKE_COMPILER_IS_GNUCXX) | |
# Targets | |
set(COVERAGE_INFO "${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged.info") | |
@@ -449,7 +465,6 @@ function(add_code_coverage_all_targets) | |
${COVERAGE_INFO} | |
COMMAND ${CMAKE_COMMAND} -E remove ${COVERAGE_INFO} | |
DEPENDS ccov-all-processing) | |
- | |
endif() | |
add_custom_command( | |
@@ -458,5 +473,15 @@ function(add_code_coverage_all_targets) | |
COMMENT | |
"Open ${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/all-merged/index.html in your browser to view the coverage report." | |
) | |
+ | |
+ if (APPLE) | |
+ add_custom_target(coverage | |
+ COMMAND open ${CMAKE_BINARY_DIR}/all-merged/index.html | |
+ DEPENDS ccov-all) | |
+ else() | |
+ add_custom_target(coverage | |
+ COMMAND xdg-open ${CMAKE_BINARY_DIR}/ccov/all-merged/index.html | |
+ DEPENDS ccov-all) | |
+ endif() | |
endif() | |
endfunction() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment