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:
Jan Van Winkel 2019-08-24 11:12:38 +02:00 committed by Alberto Escolar
parent af30f2b7d4
commit f3eec6cba3
8 changed files with 49 additions and 18 deletions

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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

View 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()

View file

@ -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)

View 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()

View file

@ -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)