forked from espressif/esp-idf
Merge branch 'fix/gcov_win_mixed_path' into 'master'
fix(gcov): Fixed mixed path separators on Windows Closes IDF-868 and IDF-3358 See merge request espressif/esp-idf!29917
This commit is contained in:
@@ -5,21 +5,25 @@ function(idf_create_coverage_report report_dir)
|
|||||||
set(gcov_tool ${_CMAKE_TOOLCHAIN_PREFIX}gcov)
|
set(gcov_tool ${_CMAKE_TOOLCHAIN_PREFIX}gcov)
|
||||||
idf_build_get_property(project_name PROJECT_NAME)
|
idf_build_get_property(project_name PROJECT_NAME)
|
||||||
|
|
||||||
|
file(TO_NATIVE_PATH "${report_dir}" _report_dir)
|
||||||
|
file(TO_NATIVE_PATH "${project_dir}" _project_dir)
|
||||||
|
file(TO_NATIVE_PATH "${report_dir}/html/index.html" _index_path)
|
||||||
|
|
||||||
add_custom_target(pre-cov-report
|
add_custom_target(pre-cov-report
|
||||||
COMMENT "Generating coverage report in: ${report_dir}"
|
COMMENT "Generating coverage report in: ${_report_dir}"
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "Using gcov: ${gcov_tool}"
|
COMMAND ${CMAKE_COMMAND} -E echo "Using gcov: ${gcov_tool}"
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${report_dir}/html
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${_report_dir}/html
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(lcov-report
|
add_custom_target(lcov-report
|
||||||
COMMENT "WARNING: lcov-report is deprecated. Please use gcovr-report instead."
|
COMMENT "WARNING: lcov-report is deprecated. Please use gcovr-report instead."
|
||||||
COMMAND lcov --gcov-tool ${gcov_tool} -c -d ${CMAKE_CURRENT_BINARY_DIR} -o ${report_dir}/${project_name}.info
|
COMMAND lcov --gcov-tool ${gcov_tool} -c -d ${CMAKE_CURRENT_BINARY_DIR} -o ${_report_dir}/${project_name}.info
|
||||||
COMMAND genhtml -o ${report_dir}/html ${report_dir}/${project_name}.info
|
COMMAND genhtml -o ${_report_dir}/html ${_report_dir}/${project_name}.info
|
||||||
DEPENDS pre-cov-report
|
DEPENDS pre-cov-report
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(gcovr-report
|
add_custom_target(gcovr-report
|
||||||
COMMAND gcovr -r ${project_dir} --gcov-executable ${gcov_tool} -s --html-details ${report_dir}/html/index.html
|
COMMAND gcovr -r ${_project_dir} --gcov-executable ${gcov_tool} -s --html-details ${_index_path}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
DEPENDS pre-cov-report
|
DEPENDS pre-cov-report
|
||||||
)
|
)
|
||||||
@@ -29,7 +33,9 @@ endfunction()
|
|||||||
#
|
#
|
||||||
# Clean coverage report.
|
# Clean coverage report.
|
||||||
function(idf_clean_coverage_report report_dir)
|
function(idf_clean_coverage_report report_dir)
|
||||||
|
file(TO_CMAKE_PATH "${report_dir}" _report_dir)
|
||||||
|
|
||||||
add_custom_target(cov-data-clean
|
add_custom_target(cov-data-clean
|
||||||
COMMENT "Clean coverage report in: ${report_dir}"
|
COMMENT "Clean coverage report in: ${_report_dir}"
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${report_dir})
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${_report_dir})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@@ -2,8 +2,12 @@
|
|||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
file(TO_NATIVE_PATH "$ENV{IDF_PATH}/tools/cmake/project.cmake" _project_path)
|
||||||
|
|
||||||
|
include(${_project_path})
|
||||||
project(gcov_example)
|
project(gcov_example)
|
||||||
|
|
||||||
idf_create_coverage_report(${CMAKE_CURRENT_BINARY_DIR}/coverage_report)
|
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/coverage_report" _coverage_path)
|
||||||
idf_clean_coverage_report(${CMAKE_CURRENT_BINARY_DIR}/coverage_report)
|
|
||||||
|
idf_create_coverage_report(${_coverage_path})
|
||||||
|
idf_clean_coverage_report(${_coverage_path})
|
||||||
|
Reference in New Issue
Block a user