cmake: toolchain abstraction for coverage
Added toolchain abstraction for coverage for both gcc and clang. Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
parent
af30f2b7d4
commit
f3eec6cba3
|
@ -2,11 +2,9 @@
|
|||
|
||||
zephyr_library()
|
||||
|
||||
zephyr_compile_options_ifdef(CONFIG_COVERAGE_GCOV
|
||||
-ftest-coverage
|
||||
-fprofile-arcs
|
||||
-fno-inline
|
||||
)
|
||||
if (CONFIG_COVERAGE)
|
||||
toolchain_cc_coverage()
|
||||
endif ()
|
||||
|
||||
zephyr_library_sources(
|
||||
exc_exit.S
|
||||
|
|
|
@ -21,14 +21,9 @@ toolchain_cc_no_freestanding_options()
|
|||
|
||||
zephyr_include_directories(${BOARD_DIR})
|
||||
|
||||
zephyr_compile_options_ifdef(CONFIG_COVERAGE
|
||||
-fprofile-arcs
|
||||
-ftest-coverage
|
||||
-fno-inline
|
||||
)
|
||||
zephyr_link_libraries_ifdef(CONFIG_COVERAGE
|
||||
-lgcov
|
||||
)
|
||||
if (CONFIG_COVERAGE)
|
||||
toolchain_cc_coverage()
|
||||
endif ()
|
||||
|
||||
if (CONFIG_ASAN)
|
||||
zephyr_compile_options(-fsanitize=address)
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
|
||||
zephyr_library()
|
||||
|
||||
zephyr_compile_options_ifdef(CONFIG_COVERAGE_GCOV
|
||||
-ftest-coverage
|
||||
-fprofile-arcs
|
||||
-fno-inline
|
||||
)
|
||||
if (CONFIG_COVERAGE)
|
||||
toolchain_cc_coverage()
|
||||
endif ()
|
||||
|
||||
zephyr_library_sources(cpuhalt.c)
|
||||
zephyr_library_sources_if_kconfig(pcie.c)
|
||||
|
|
|
@ -73,6 +73,7 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake)
|
|||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_warnings.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_coverage.cmake)
|
||||
|
||||
macro(toolchain_cc_security_fortify)
|
||||
# No op, clang doesn't understand fortify at all
|
||||
|
|
18
cmake/compiler/clang/target_coverage.cmake
Normal file
18
cmake/compiler/clang/target_coverage.cmake
Normal file
|
@ -0,0 +1,18 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
macro(toolchain_cc_coverage)
|
||||
|
||||
zephyr_compile_options(
|
||||
--coverage
|
||||
-fno-inline
|
||||
)
|
||||
|
||||
if (NOT CONFIG_COVERAGE_GCOV)
|
||||
|
||||
zephyr_link_libraries(
|
||||
--coverage
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
endmacro()
|
|
@ -140,3 +140,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_baremetal.cmake)
|
|||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_warnings.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_imacros.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_base.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_coverage.cmake)
|
||||
|
|
19
cmake/compiler/gcc/target_coverage.cmake
Normal file
19
cmake/compiler/gcc/target_coverage.cmake
Normal file
|
@ -0,0 +1,19 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
macro(toolchain_cc_coverage)
|
||||
|
||||
zephyr_compile_options(
|
||||
-fprofile-arcs
|
||||
-ftest-coverage
|
||||
-fno-inline
|
||||
)
|
||||
|
||||
if (NOT CONFIG_COVERAGE_GCOV)
|
||||
|
||||
zephyr_link_libraries(
|
||||
-lgcov
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
endmacro()
|
|
@ -76,3 +76,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake)
|
|||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_warnings.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)
|
||||
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_coverage.cmake)
|
||||
|
|
Loading…
Reference in a new issue