diff options
author | Scott Murray <scott.murray@konsulko.com> | 2020-09-18 15:51:14 -0400 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2020-09-29 22:36:08 +0000 |
commit | 6b60df806daef288a1143822677c8497f56958de (patch) | |
tree | f511dcc4c233ed41ae041947544f8137fecb36ff | |
parent | fa461349a7fd4d4abad04ae0acbe517ab343c36e (diff) |
Add source and coverage information to widgetsjellyfish_10.0.3jellyfish_10.0.2jellyfish_10.0.1jellyfish/10.0.3jellyfish/10.0.2jellyfish/10.0.110.0.310.0.210.0.1jellyfish
Add source and coverage information installation to debug and
coverage widgets. The source tree will be installed to "src" in
debug and coverage widgets, with some non-source directories like
doc/docs excluded. The gcc produced "gcno" files for generating
coverage reports will be installed to "coverage" in coverage
widgets. A different directory than that for source is used, as
the gcno files are in the build output hierarchy, which is not the
same as the source tree hierarchy when using CMake. This hierarchy
needs to be preserved to be able to use gcc's coverage support.
As part of this scheme, an environment file containing values for
the GCOV_PREFIX and GCOV_PREFIX_STRIP variables is generated and
added to "coverage". The latter variable can only be calculated
during widget build, and is essential for abstracting the build
directory location and enabling gcov usage on target.
Bug-AGL: SPEC-3589
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I258fff0295444bb257d24d442798347728ee7875
(cherry picked from commit 7c03348d9c2de43684fa69c3c9e227b25daceaaa)
-rw-r--r-- | src/cmake/cmake.d/03-macros.cmake | 18 | ||||
-rw-r--r-- | src/cmake/gcov-helper.sh.in | 17 | ||||
-rw-r--r-- | src/cmake/src_exclude | 5 |
3 files changed, 40 insertions, 0 deletions
diff --git a/src/cmake/cmake.d/03-macros.cmake b/src/cmake/cmake.d/03-macros.cmake index 0b4b276..32182f9 100644 --- a/src/cmake/cmake.d/03-macros.cmake +++ b/src/cmake/cmake.d/03-macros.cmake @@ -1,5 +1,6 @@ ########################################################################### # Copyright 2015, 2016, 2017 IoT.bzh +# Copyright (C) 2020 Konsulko Group # # author: Fulup Ar Foll <fulup@iot.bzh> # contrib: Romain Forlot <romain.forlot@iot.bzh> @@ -652,6 +653,23 @@ You need a config.xml template: please specify WIDGET_CONFIG_TEMPLATE correctly. ) list(APPEND test_widget_files_items ${PROJECT_PKG_TEST_DIR}/config.xml) + IF(${CMAKE_BUILD_TYPE} MATCHES DEBUG OR ${CMAKE_BUILD_TYPE} MATCHES COVERAGE) + # populate wgt/src + add_custom_command(OUTPUT ${PROJECT_PKG_BUILD_DIR}/src + COMMAND mkdir -p ${PROJECT_PKG_BUILD_DIR}/src + COMMAND tar -C ${CMAKE_SOURCE_DIR} -cf - -X ${PROJECT_APP_TEMPLATES_DIR}/cmake/src_exclude . | tar -C ${PROJECT_PKG_BUILD_DIR}/src -xf -) + list(APPEND widget_files_items ${PROJECT_PKG_BUILD_DIR}/src) + ENDIF() + + IF(${CMAKE_BUILD_TYPE} MATCHES COVERAGE) + # populate wgt/coverage + configure_file(${PROJECT_APP_TEMPLATES_DIR}/cmake/gcov-helper.sh.in ${CMAKE_BINARY_DIR}/gcov-helper.sh @ONLY) + add_custom_command(OUTPUT ${PROJECT_PKG_BUILD_DIR}/coverage + COMMAND mkdir -p ${PROJECT_PKG_BUILD_DIR}/coverage + COMMAND /bin/sh ${CMAKE_BINARY_DIR}/gcov-helper.sh) + list(APPEND widget_files_items ${PROJECT_PKG_BUILD_DIR}/coverage) + ENDIF() + # add test launcher add_custom_command(OUTPUT ${PROJECT_PKG_TEST_DIR}/bin COMMAND mkdir -p ${PROJECT_PKG_TEST_DIR}/bin diff --git a/src/cmake/gcov-helper.sh.in b/src/cmake/gcov-helper.sh.in new file mode 100644 index 0000000..4278148 --- /dev/null +++ b/src/cmake/gcov-helper.sh.in @@ -0,0 +1,17 @@ +#!/bin/sh + +# Copy gcno files +for f in `find @CMAKE_BINARY_DIR@ -name '*\.gcno'`; do + d="${f%/*}" + mkdir -p "@PROJECT_PKG_BUILD_DIR@/coverage/${d#@CMAKE_BINARY_DIR@}" + cp "$f" "@PROJECT_PKG_BUILD_DIR@/coverage/${d#@CMAKE_BINARY_DIR@}" +done + +# Make gcov environment file +mkdir -p "@PROJECT_PKG_BUILD_DIR@/coverage" +dirs=`echo "@CMAKE_BINARY_DIR@" | tr -cd '/' | wc -c` +cat > "@PROJECT_PKG_BUILD_DIR@/coverage/gcov.env" <<EOF +GCOV_PREFIX=/tmp/gcov/@PROJECT_NAME@ +GCOV_PREFIX_STRIP=${dirs} +EOF + diff --git a/src/cmake/src_exclude b/src/cmake/src_exclude new file mode 100644 index 0000000..03e0124 --- /dev/null +++ b/src/cmake/src_exclude @@ -0,0 +1,5 @@ +.git* +build* +doc +docs +can_samples |