Apply gcov automation
[platform/core/api/vine.git] / packaging / capi-network-vine.spec
1 %bcond_without lws_static
2 %bcond_without lws_static_prebuilt
3 %bcond_without use_glib_event_loop
4 Name:    capi-network-vine
5 Summary: An service discovery framework
6 Version: 1.2.9
7 Release: 0
8 Group:   Network & Connectivity/API
9 License: Apache-2.0
10 Source0: %{name}-%{version}.tar.gz
11 Source1: %{name}.manifest
12
13 BuildRequires: cmake
14 BuildRequires: pkgconfig(dns_sd)
15 %if %{with lws_static}
16 BuildRequires: pkgconfig(openssl1.1)
17 %endif
18 %if %{without lws_static}
19 BuildRequires: pkgconfig(libwebsockets)
20 %endif
21
22 %if 0%{?_with_tizen:1}
23 BuildRequires: pkgconfig(capi-base-common)
24 BuildRequires: pkgconfig(capi-system-info)
25 BuildRequires: pkgconfig(dlog)
26
27 %ifnarch %i586 i686 x86_64
28 BuildRequires: pkgconfig(capi-network-wifi-aware)
29 %endif
30 BuildRequires: pkgconfig(capi-network-bluetooth)
31 %endif
32
33 %if %{with use_glib_event_loop}
34 BuildRequires: pkgconfig(glib-2.0)
35 %endif
36
37 BuildRequires: pkgconfig(gmock)
38
39 %if 0%{?gcov:1}
40 BuildRequires: gtest-devel
41 BuildRequires: lcov
42 %endif
43
44 Requires(post): /sbin/ldconfig
45 Requires(postun): /sbin/ldconfig
46
47 %description
48 A Vine library is a Tizen Framework to provide service discovery and connection to communicate between devices in a local network
49
50 %package devel
51 Summary: A Vine library in Native API (Development)
52 Group: Development/Libraries
53 Requires: %{name} = %{version}-%{release}
54 Requires: capi-base-common-devel
55
56 %description devel
57 A Vine library in Native API (Development)
58
59 %package test
60 Summary: Vine - Test binaries
61
62 %description test
63 Test Application for Vine
64
65 %if 0%{?gcov:1}
66 %package gcov
67 Summary: Coverage Data of %{name}
68
69 %description gcov
70 The %{name}-gcov package contains gcov objects
71 %endif
72
73 %package unittests
74 Summary: %{name} unittests binary
75
76 %description unittests
77 unittests binary
78
79 %prep
80 %setup -q
81 chmod 644 %{SOURCE0}
82 cp %{SOURCE1} ./%{name}.manifest
83
84 %ifarch %{arm}
85 export ARCH=arm
86 %else
87 export ARCH=i586
88 %endif
89
90 %build
91 %if 0%{?gcov:1}
92 export CFLAGS+=" -fprofile-arcs -ftest-coverage"
93 export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
94 export FFLAGS+=" -fprofile-arcs -ftest-coverage"
95 %endif
96
97 %cmake . \
98         -DTIZEN_OS=%{?_with_tizen} \
99 %ifarch armv7hl
100         -DHW_FP=ON \
101 %endif
102         -DCMAKE_BUILD_TYPE=%{?build_type} \
103         -DCMAKE_VERBOSE_MAKEFILE=ON \
104         -DLIB_DIR:PATH=%{_libdir} \
105         -DBIN_DIR:PATH=%{_bindir} \
106         -DINCLUDE_DIR:PATH=%{_includedir} \
107         -DUSE_EVENT_LOOP_EPOLL=ON \
108 %if %{with use_glib_event_loop}
109         -DUSE_EVENT_LOOP_EXTERNAL_GLIB=ON \
110 %else
111         -DUSE_EVENT_LOOP_EXTERNAL_GLIB=OFF \
112 %endif
113 %if %{with lws_static}
114         -DUSE_LIBWEBSOCKETS_STATIC=ON \
115 %else
116         -DUSE_LIBWEBSOCKETS_STATIC=OFF \
117 %endif
118 %ifnarch %i586 i686 x86_64
119         -DNAN_SUPPORT=ON \
120 %endif
121 %if %{with lws_static_prebuilt}
122         -DUSE_LIBWEBSOCKETS_STATIC_PREBUILT=ON \
123 %else
124         -DUSE_LIBWEBSOCKETS_STATIC_PREBUILT=OFF \
125 %endif
126         -DWITH_UNITTEST=ON \
127         -DENABLE_DATAPATH_PLUGIN_DEBUG=ON \
128         -DWITH_VINE_TEST=ON
129
130 make %{?jobs:-j%jobs}
131
132 %install
133 rm -rf %{buildroot}
134 %make_install
135
136 %if %{with lws_static}
137 rm -rf %{buildroot}%{_libdir}/cmake/libwebsockets
138 %endif
139
140 %if 0%{?gcov:1}
141 builddir=$(basename $PWD)
142 gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
143 mkdir -p "$gcno_obj_dir"
144 find . -name '*.gcno' ! -path '*/verifier/*' ! -path '*/vine-test/*' ! -path '*/tool/*' -exec cp --parents '{}' "$gcno_obj_dir" ';'
145 %endif
146
147 cat << EOF > run-unittest.sh
148 #!/bin/sh
149 setup() {
150     echo "setup start"
151 }
152
153 test_main() {
154     echo "test_main start"
155     /usr/bin/vine-unittest
156 }
157
158 teardown() {
159     echo "teardown start"
160 }
161
162 main() {
163     setup
164     test_main
165     teardown
166 }
167
168 main "\$*"
169 EOF
170
171 mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
172 install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/
173
174
175 %check
176 %if 0%{?gcov:1}
177 LD_LIBRARY_PATH=%{buildroot}%{_libdir} tests/unittest/vine-unittest
178 lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
179 genhtml %{name}.info -o out --legend --show-details
180 %endif
181
182 %post -p /sbin/ldconfig
183
184 %postun -p /sbin/ldconfig
185
186 %files
187 %manifest %{name}.manifest
188 %license LICENSE
189 %defattr(-,root,root,-)
190 %{_libdir}/*.so*
191
192 %files devel
193 %defattr(-,root,root,-)
194 %{_libdir}/pkgconfig/vine.pc
195 %{_includedir}/*.h
196 %if %{with lws_static} && %{without lws_static_prebuilt}
197 %{_includedir}/libwebsockets/*.h
198 %{_includedir}/libwebsockets/abstract/*.h
199 %{_includedir}/libwebsockets/abstract/protocols/*.h
200 %{_includedir}/libwebsockets/abstract/transports/*.h
201 %exclude %{_libdir}/pkgconfig/libwebsockets.pc
202 %exclude %{_libdir}/pkgconfig/libwebsockets_static.pc
203 %endif
204 %{_libdir}/*.so
205
206 %files test
207 %manifest %{name}.manifest
208 %attr(755,root,root) %{_bindir}/*
209 %attr(644,root,root) %{_datadir}/vine-verifier/certs/rootCA/ca.pem
210 %attr(644,root,root) %{_datadir}/vine-verifier/certs/server/*
211
212 %if 0%{?gcov:1}
213 %files gcov
214 %{_datadir}/gcov/obj/*
215 %endif
216
217 %files unittests
218 %{_bindir}/vine-unittest
219 %{_bindir}/tizen-unittests/%{name}/run-unittest.sh