Change the way coverage is triggered in spec 83/229683/4
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Thu, 2 Apr 2020 15:40:16 +0000 (17:40 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Fri, 26 Jun 2020 15:36:20 +0000 (17:36 +0200)
Use --define "build_type COVERAGE". This way I can set -O0 which is
required for reliable results. Also removed unused CMAKE variable.

Change-Id: I8a1540d0ea9966f8aa49cf6d24509dcfb5bf65bd

CMakeLists.txt
packaging/yaca.spec

index 0ed5d6b980aef1093995d8c4101b975aa24f1377..ec14e13a506edb6088915d02e28d922e3833fce4 100644 (file)
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+#  Copyright (c) 2016-2020 Samsung Electronics Co., Ltd All Rights Reserved
 #
 #  Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
 #
@@ -54,6 +54,7 @@ MESSAGE(STATUS "-------------------------------------------------")
 
 SET(CMAKE_C_FLAGS_DEBUG        "-std=c11 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
 SET(CMAKE_C_FLAGS_RELEASE      "-std=c11 -O2 -DNDEBUG")
+SET(CMAKE_C_FLAGS_COVERAGE     "-std=c11 -O0 -ggdb --coverage -Wp,-U_FORTIFY_SOURCE")
 
 ADD_DEFINITIONS("-fPIC")   # Position Independent Code
 ADD_DEFINITIONS("-Werror") # Make all warnings into errors
index 538f47cc28865c51686646392ce4f2521bcae69d..4f9cd027d9d7a2693b29461d0dcbe25433739b0b 100644 (file)
@@ -1,3 +1,5 @@
+%{!?build_type:%define build_type "RELEASE"}
+
 Name:               yaca
 Version:            0.0.5
 Release:            0
@@ -9,8 +11,8 @@ BuildRequires:      cmake
 BuildRequires:      python3 >= 3.4
 BuildRequires:      pkgconfig(capi-base-common)
 BuildRequires:      pkgconfig(openssl1.1)
-%if 0%{?gcov:1}
-BuildRequires: lcov
+%if %{build_type} == "COVERAGE"
+BuildRequires:      lcov
 %endif
 Requires(post):     /sbin/ldconfig
 Requires(postun):   /sbin/ldconfig
@@ -32,31 +34,20 @@ The package provides Yet Another Crypto API.
 %setup -q
 
 %build
-%{!?build_type:%define build_type "RELEASE"}
-
-%if 0%{?gcov:1}
-export CFLAGS+=" -fprofile-arcs -ftest-coverage"
-export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
-export FFLAGS+=" -fprofile-arcs -ftest-coverage"
-export LDFLAGS+=" -lgcov"
-%endif
-
-%cmake . -DCMAKE_BUILD_TYPE=%{build_type} \
-        -DBUILD_GCOV={?gcov:1}%{!?gcov:0}
+%cmake . -DCMAKE_BUILD_TYPE=%{build_type}
 
 make -k %{?jobs:-j%jobs}
 
-%if 0%{?gcov:1}
+%if %{build_type} == "COVERAGE"
 mkdir -p gcov-obj
 find . \( -name '*.gcno' ! -name 'tc_*' \) -exec cp '{}' gcov-obj ';'
 %endif
 
-
 %install
 %make_install
 %py3_compile %{buildroot}/%{python3_sitearch}
 
-%if 0%{?gcov:1}
+%if "%{build_type}" == "COVERAGE"
 mkdir -p %{buildroot}%{_datadir}/gcov/obj
 install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
 %endif
@@ -105,7 +96,7 @@ The package provides Yet Another Crypto API bindings for Python3.
 %{python3_sitearch}/%{name}
 
 ## gcov Package ############################################################
-%if 0%{?gcov:1}
+%if "%{build_type}" == "COVERAGE"
 %package gcov
 Summary:  yaca gcov for measuring test coverage
 Group:    Secureity/Testing
@@ -115,5 +106,3 @@ New yaca gcov objects
 %files gcov
 %{_datadir}/gcov/obj/*
 %endif
-
-