Fix spec file for coverage measurement
[platform/core/base/bundle.git] / packaging / bundle.spec
1 Name:       bundle
2 Summary:    String key-val dictionary ADT
3 Version:    0.9.7
4 Release:    0
5 Group:      System/Libraries
6 License:    Apache-2.0
7 Source0:        bundle-%{version}.tar.gz
8 Source1001:     bundle.manifest
9 Source1002:     parcel.manifest
10 BuildRequires:  cmake
11 BuildRequires:  pkgconfig(glib-2.0)
12 BuildRequires:  pkgconfig(dlog)
13 BuildRequires:  pkgconfig(capi-base-common)
14 BuildRequires:  pkgconfig(json-glib-1.0)
15 BuildRequires:  pkgconfig(gmock)
16
17 %if 0%{?gcov:1}
18 BuildRequires:  lcov
19 BuildRequires:  zip
20 %endif
21
22 %description
23 Simple string key-val dictionary ADT
24
25 %package devel
26 Summary:    String key-val dictionary ADT (devel)
27 Group:      Development/Libraries
28 Requires:   %{name} = %{version}-%{release}
29
30 %description devel
31 Simple string key-val dictionary ADT (devel)
32
33 #################################################
34 # unittests
35 #################################################
36 %package unittests
37 Summary:    GTest for bundle
38 Group:      Development/Libraries
39
40 %description unittests
41 GTest for bundle
42
43 #################################################
44 # gcov
45 #################################################
46 %if 0%{?gcov:1}
47 %package gcov
48 Summary:    Simple string key-val dictionary ADT (gcov)
49 Group:      Application Framework/Testing
50
51 %description gcov
52 Simple string key-val dictionary ADT gcov objects
53 %endif
54
55 #################################################
56 ## parcel
57 #################################################
58 %package -n parcel
59 Summary:    Parcel Library
60 Group:      Development/Libraries
61
62 %description -n parcel
63 Parcel Library
64
65 %package -n parcel-devel
66 Summary:    Parcel Library (devel)
67 Group:      Development/Libraries
68 Requires:   parcel = %{version}-%{release}
69
70 %description -n parcel-devel
71 Parcel Library (devel)
72
73 #################################################
74 # parcel-unittests
75 #################################################
76 %package -n parcel-unittests
77 Summary:    GTest for parcel
78 Group:      Development/Libraries
79
80 %description -n parcel-unittests
81 GTest for parcel
82
83 %prep
84 %setup -q -n %{name}-%{version}
85 cp %{SOURCE1001} .
86 cp %{SOURCE1002} .
87
88 %build
89 %if 0%{?gcov:1}
90 export CFLAGS+=" -fprofile-arcs -ftest-coverage"
91 export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
92 export FFLAGS+=" -fprofile-arcs -ftest-coverage"
93 export LDFLAGS+=" -lgcov"
94 %endif
95
96 %cmake -DVERSION=%{version} .
97 %__make %{?_smp_mflags}
98
99 %check
100 ctest --verbose %{?_smp_mflags}
101 %if 0%{?gcov:1}
102 lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
103 genhtml %{name}.info -o out --legend --show-details
104 %endif
105
106 %install
107 %make_install
108
109 %if 0%{?gcov:1}
110 builddir=$(basename $PWD)
111 gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
112 mkdir -p "$gcno_obj_dir"
113 find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';'
114 %endif
115
116 cat << EOF > run-unittest.sh
117 #!/bin/sh
118 setup() {
119     echo "setup start"
120 }
121
122 test_main() {
123     echo "test_main start"
124     /usr/bin/bundle_unittests
125 }
126
127 teardown() {
128     echo "teardown start"
129 }
130
131 main() {
132     setup
133     test_main
134     teardown
135 }
136
137 main "\$*"
138 EOF
139
140 mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
141 install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/
142
143 cat << EOF > run-parcel-unittest.sh
144 #!/bin/sh
145 setup() {
146     echo "setup start"
147 }
148
149 test_main() {
150     echo "test_main start"
151     /usr/bin/parcel_unittests
152 }
153
154 teardown() {
155     echo "teardown start"
156 }
157
158 main() {
159     setup
160     test_main
161     teardown
162 }
163
164 main "\$*"
165 EOF
166
167 mkdir -p %{buildroot}%{_bindir}/tizen-unittests/parcel
168 install -m 0755 run-parcel-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/parcel/run-unittest.sh
169
170 %post -p /sbin/ldconfig
171
172 %postun -p /sbin/ldconfig
173
174 %post -n parcel
175 /sbin/ldconfig
176
177 %postun -n parcel
178 /sbin/ldconfig
179
180 %post unittests
181 %if 0%{?gcov:1}
182 %{_bindir}/bundle_unittests
183 %endif
184
185 %files
186 %manifest %{name}.manifest
187 %defattr(-,root,root,-)
188 %{_libdir}/libbundle.so.*
189 %license LICENSE
190
191 %files devel
192 %manifest %{name}.manifest
193 %defattr(-,root,root,-)
194 %{_includedir}/*.h
195 %{_libdir}/pkgconfig/bundle.pc
196 %{_libdir}/libbundle.so
197
198 #################################################
199 # unittests
200 #################################################
201 %files unittests
202 %{_bindir}/bundle_unittests
203 %{_bindir}/tizen-unittests/%{name}/run-unittest.sh
204
205 #################################################
206 # bundle-gcov
207 #################################################
208 %if 0%{?gcov:1}
209 %files gcov
210 %{_datadir}/gcov/obj/*
211 %endif
212
213 #################################################
214 # parcel
215 #################################################
216 %files -n parcel
217 %manifest parcel.manifest
218 %license LICENSE
219 %{_libdir}/libparcel.so.*
220
221 %files -n parcel-devel
222 %manifest parcel.manifest
223 %{_includedir}/*
224 %{_libdir}/pkgconfig/parcel.pc
225 %{_libdir}/libparcel.so
226
227 %files -n parcel-unittests
228 %{_bindir}/parcel_unittests
229 %{_bindir}/tizen-unittests/parcel/run-unittest.sh