Build with gcov 25/231825/1
authorKonrad Kuchciak <k.kuchciak@samsung.com>
Fri, 24 Apr 2020 09:33:06 +0000 (11:33 +0200)
committerKonrad Kuchciak <k.kuchciak@samsung.com>
Fri, 24 Apr 2020 09:37:33 +0000 (11:37 +0200)
 - build with gcov when --define "gcov 1" option is passed to gbs

Change-Id: I1997b14b8330eca41b5e8f2599b3b606b78ccb26
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
CMakeLists.txt
packaging/capi-system-peripheral-io.spec

index b4da425..43c0b29 100644 (file)
@@ -47,6 +47,13 @@ SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=%{_libdir}")
 
+IF("${GCOV}" STREQUAL "1")
+  STRING(REPLACE "-O2" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+  STRING(REPLACE "-D_FORTIFY_SOURCE=2 " "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fprofile-arcs -ftest-coverage")
+  SET(${fw_name}_LDFLAGS "${${fw_name}_LDFLAGS} -lgcov")
+ENDIF()
+
 SET(SOURCES src/peripheral_gpio.c
                        src/peripheral_i2c.c
                        src/peripheral_pwm.c
index 4a062ee..705b2cb 100644 (file)
@@ -13,6 +13,10 @@ BuildRequires:  pkgconfig(gio-2.0)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(capi-system-info)
+%if 0%{?gcov:1}
+BuildRequires:  lcov
+BuildRequires:  zip
+%endif
 
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
@@ -42,7 +46,7 @@ cp %{SOURCE1} ./%{name}.manifest
 
 %build
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version}
+%cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DGCOV=%{gcov}
 
 %install
 %make_install