Skip to content

Commit f2f27d7

Browse files
mordanteStableCoder
authored andcommitted
Adds a new per target export option.
The code has been based on the ccov-all-export target.
1 parent 6dd799d commit f2f27d7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

code-coverage.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ endif()
197197
# ccov-report : Generates HTML code coverage report for every target added with 'AUTO' parameter.
198198
# ccov-${TARGET_NAME} : Generates HTML code coverage report.
199199
# ccov-report-${TARGET_NAME} : Prints to command line summary per-file coverage information.
200+
# ccov-export-${TARGET_NAME} : Exports the coverage report to a JSON file.
200201
# ccov-show-${TARGET_NAME} : Prints to command line detailed per-line coverage information.
201202
# ccov-all : Generates HTML code coverage report, merging every target added with 'ALL' parameter into a single detailed report.
202203
# ccov-all-report : Prints summary per-file coverage information for every target added with ALL' parameter to the command line.
@@ -359,6 +360,17 @@ function(target_code_coverage TARGET_NAME)
359360
${EXCLUDE_REGEX}
360361
DEPENDS ccov-processing-${target_code_coverage_COVERAGE_TARGET_NAME})
361362

363+
# Export coverage information so continuous integration tools (e.g.
364+
# Jenkins) can consume it
365+
add_custom_target(
366+
ccov-export-${target_code_coverage_COVERAGE_TARGET_NAME}
367+
COMMAND
368+
${LLVM_COV_PATH} export $<TARGET_FILE:${TARGET_NAME}> ${SO_OBJECTS}
369+
-instr-profile=${target_code_coverage_COVERAGE_TARGET_NAME}.profdata
370+
-format="text" ${EXCLUDE_REGEX} >
371+
${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/${target_code_coverage_COVERAGE_TARGET_NAME}.json
372+
DEPENDS ccov-processing-${target_code_coverage_COVERAGE_TARGET_NAME})
373+
362374
# Generates HTML output of the coverage information for perusal
363375
add_custom_target(
364376
ccov-${target_code_coverage_COVERAGE_TARGET_NAME}

0 commit comments

Comments
 (0)