6f17cf94a33678538588eed389dfc18a8f3e8fe2
[platform/core/ml/nnfw.git] / packaging / nnfw.spec
1 Name:    nnfw
2 Summary: nnfw
3 Version: 1.22.1
4 Release: 1
5 Group:   Development
6 License: Apache-2.0 and MIT and BSD-2-Clause and MPL-2.0
7
8 Source0: %{name}-%{version}.tar.gz
9 Source1: %{name}.manifest
10 Source1001: nnapi_test_generated.tar.gz
11 Source2001: nnfw.pc.in
12 Source2002: nnfw-plugin.pc.in
13 Source3001: ABSEIL.tar.gz
14 Source3002: CPUINFO.tar.gz
15 Source3003: EGL_HEADERS.tar.gz
16 Source3004: FARMHASH.tar.gz
17 Source3005: FP16.tar.gz
18 Source3006: FXDIV.tar.gz
19 Source3007: GEMMLOWP.tar.gz
20 Source3008: OOURAFFT.tar.gz
21 Source3009: OPENCL_HEADERS.tar.gz
22 Source3010: OPENGL_HEADERS.tar.gz
23 Source3011: PSIMD.tar.gz
24 Source3012: PTHREADPOOL.tar.gz
25 Source3013: TENSORFLOW-2.8.0-EIGEN.tar.gz
26 Source3014: TENSORFLOW-2.8.0-GEMMLOWP.tar.gz
27 Source3015: TENSORFLOW-2.8.0-RUY.tar.gz
28 Source3016: TENSORFLOW-2.8.0.tar.gz
29 Source3017: VULKAN.tar.gz
30 Source3018: XNNPACK.tar.gz
31 Source3019: FLATBUFFERS-2.0.tar.gz
32
33 %{!?build_type:     %define build_type      Release}
34 %{!?npud_build:     %define npud_build      0}
35 %{!?trix_support:   %define trix_support    1}
36 %{!?coverage_build: %define coverage_build  0}
37 %{!?test_build:     %define test_build      0}
38 %{!?extra_option:   %define extra_option    %{nil}}
39 %{!?config_support: %define config_support  0}
40
41 %if %{coverage_build} == 1
42 # Coverage test requires debug build runtime
43 %define build_type Debug
44 %define test_build 1
45 %endif
46
47 BuildRequires:  cmake
48
49 Requires(post): /sbin/ldconfig
50 Requires(postun): /sbin/ldconfig
51
52 %if %{test_build} == 1
53 BuildRequires:  pkgconfig(boost)
54 BuildRequires:  pkgconfig(tensorflow2-lite)
55 BuildRequires:  hdf5-devel
56 BuildRequires:  libaec-devel
57 BuildRequires:  pkgconfig(zlib)
58 BuildRequires:  pkgconfig(libjpeg)
59 BuildRequires:  gtest-devel
60 %endif
61
62 %if %{npud_build} == 1
63 BuildRequires:  pkgconfig(glib-2.0)
64 %endif
65
66 %if %{trix_support} == 1
67 BuildRequires:  pkgconfig(npu-engine)
68 %endif
69
70 %description
71 nnfw is a high-performance, on-device neural network framework for Tizen
72
73 %package devel
74 Summary: NNFW Devel Package
75 Requires: %{name} = %{version}-%{release}
76
77 %description devel
78 NNFW development package for application developer using runtime
79
80 %package plugin-devel
81 Summary: NNFW Devel Package
82 Requires: %{name}-devel = %{version}-%{release}
83
84 %description plugin-devel
85 NNFW development package for backend plugin developer
86
87 %package minimal-app
88 Summary: Minimal test binary for VD manual test
89
90 %description minimal-app
91 Minimal test binary for VD manual test
92
93 %if %{test_build} == 1
94 %package test
95 Summary: NNFW Test
96
97 %description test
98 NNFW test rpm.
99 If you want to use test package, you should install runtime package which is build with test build option
100 If you want to get coverage info, you should install runtime package which is build with coverage build option
101 # TODO Use release runtime pacakge for test
102 %endif
103
104 %if %{npud_build} == 1
105 %package npud
106 Summary: NPU daemon
107
108 %description npud
109 NPU daemon for optimal management of NPU hardware
110 %endif
111
112 %ifarch armv7l
113 %define target_arch armv7l
114 %endif
115 %ifarch armv7hl
116 %define target_arch armv7hl
117 %endif
118 %ifarch x86_64
119 %define target_arch x86_64
120 %endif
121 %ifarch aarch64
122 %define target_arch aarch64
123 %endif
124 %ifarch %ix86
125 %define target_arch i686
126 %endif
127
128 %define install_dir %{_prefix}
129 %define install_path %{buildroot}%{install_dir}
130 %define nnfw_workspace build
131 %define build_env NNFW_WORKSPACE=%{nnfw_workspace}
132
133 # Path to install test bin and scripts (test script assumes path Product/out)
134 # TODO Share path with release package
135 %define test_install_home /opt/usr/nnfw-test
136 %define test_install_dir %{test_install_home}/Product/out
137 %define test_install_path %{buildroot}%{test_install_dir}
138
139 # Set option for test build (and coverage test build)
140 %define option_test -DENABLE_TEST=OFF
141 %define option_coverage %{nil}
142 %define test_suite_list infra/scripts tests/scripts
143
144 %if %{test_build} == 1
145 # ENVVAR_ONERT_CONFIG: Use environment variable for runtime core configuration and debug
146 %define option_test -DENABLE_TEST=ON -DENVVAR_ONERT_CONFIG=ON
147 %endif # test_build
148
149 # Set option for configuration
150 %define option_config %{nil}
151 %if %{npud_build} == 1
152 %if %{config_support} == 1
153 # ENVVAR_NPUD_CONFIG: Use environment variable for npud configuration and debug
154 %define option_config -DBUILD_NPUD=ON -DENVVAR_NPUD_CONFIG=ON
155 %else
156 %define option_config -DBUILD_NPUD=ON -DENVVAR_NPUD_CONFIG=OFF
157 %endif # config_support
158 %else
159 %define option_config -DBUILD_NPUD=OFF
160 %endif # npud_build
161
162 %if %{coverage_build} == 1
163 %define option_coverage -DENABLE_COVERAGE=ON
164 %endif # coverage_build
165
166 %define build_options -DCMAKE_BUILD_TYPE=%{build_type} -DTARGET_ARCH=%{target_arch} -DTARGET_OS=tizen -DBUILD_MINIMAL_SAMPLE=ON \\\
167         %{option_test} %{option_coverage} %{option_config} %{extra_option}
168
169 %prep
170 %setup -q
171 cp %{SOURCE1} .
172 mkdir ./externals
173 tar -xf %{SOURCE1001} -C ./tests/nnapi/src/
174 tar -xf %{SOURCE3001} -C ./externals
175 tar -xf %{SOURCE3002} -C ./externals
176 tar -xf %{SOURCE3003} -C ./externals
177 tar -xf %{SOURCE3004} -C ./externals
178 tar -xf %{SOURCE3005} -C ./externals
179 tar -xf %{SOURCE3006} -C ./externals
180 tar -xf %{SOURCE3007} -C ./externals
181 tar -xf %{SOURCE3008} -C ./externals
182 tar -xf %{SOURCE3009} -C ./externals
183 tar -xf %{SOURCE3010} -C ./externals
184 tar -xf %{SOURCE3011} -C ./externals
185 tar -xf %{SOURCE3012} -C ./externals
186 tar -xf %{SOURCE3013} -C ./externals
187 tar -xf %{SOURCE3014} -C ./externals
188 tar -xf %{SOURCE3015} -C ./externals
189 tar -xf %{SOURCE3016} -C ./externals
190 tar -xf %{SOURCE3017} -C ./externals
191 tar -xf %{SOURCE3018} -C ./externals
192 tar -xf %{SOURCE3019} -C ./externals
193
194 %build
195 %ifarch arm armv7l armv7hl aarch64 x86_64 %ix86
196 # runtime build
197 %{build_env} ./nnfw configure %{build_options}
198 %{build_env} ./nnfw build -j4
199 # install in workspace
200 # TODO Set install path
201 %{build_env} ./nnfw install
202
203 %if %{test_build} == 1
204 %if %{coverage_build} == 1
205 pwd > tests/scripts/build_path.txt
206 %endif # coverage_build
207 tar -zcf test-suite.tar.gz infra/scripts
208 %endif # test_build
209 %endif # arm armv7l armv7hl aarch64
210
211 %install
212 %ifarch arm armv7l armv7hl aarch64 x86_64 %ix86
213
214 mkdir -p %{buildroot}%{_libdir}
215 mkdir -p %{buildroot}%{_bindir}
216 mkdir -p %{buildroot}%{_includedir}
217 install -m 644 build/out/lib/*.so %{buildroot}%{_libdir}
218 install -m 755 build/out/bin/onert-minimal-app %{buildroot}%{_bindir}
219 cp -r build/out/include/* %{buildroot}%{_includedir}/
220
221 # For developer
222 cp %{SOURCE2001} .
223 cp %{SOURCE2002} .
224 sed -i 's:@libdir@:%{_libdir}:g
225         s:@includedir@:%{_includedir}:g
226         s:@version@:%{version}:g' ./nnfw.pc.in
227 sed -i 's:@libdir@:%{_libdir}:g
228         s:@includedir@:%{_includedir}:g
229         s:@version@:%{version}:g' ./nnfw-plugin.pc.in
230 mkdir -p %{buildroot}%{_libdir}/pkgconfig
231 install -m 0644 ./nnfw.pc.in %{buildroot}%{_libdir}/pkgconfig/nnfw.pc
232 install -m 0644 ./nnfw-plugin.pc.in %{buildroot}%{_libdir}/pkgconfig/nnfw-plugin.pc
233
234 %if %{test_build} == 1
235 mkdir -p %{test_install_path}/bin
236 mkdir -p %{test_install_path}/nnapi-gtest
237 mkdir -p %{test_install_path}/unittest
238 mkdir -p %{test_install_path}/test
239
240 install -m 755 build/out/bin/onert_run %{test_install_path}/bin
241 install -m 755 build/out/bin/tflite_comparator %{test_install_path}/bin
242 install -m 755 build/out/bin/tflite_run %{test_install_path}/bin
243 install -m 755 build/out/nnapi-gtest/* %{test_install_path}/nnapi-gtest
244 install -m 755 build/out/unittest/*_test %{test_install_path}/unittest
245 install -m 755 build/out/unittest/test_* %{test_install_path}/unittest
246 cp -r build/out/test/* %{test_install_path}/test
247 cp -r build/out/unittest/nnfw_api_gtest_models %{test_install_path}/unittest
248
249 # Share test script with ubuntu (ignore error if there is no list for target)
250 cp tests/nnapi/nnapi_gtest.skip.%{target_arch}-* %{test_install_path}/nnapi-gtest/.
251 cp %{test_install_path}/nnapi-gtest/nnapi_gtest.skip.%{target_arch}-linux.cpu %{test_install_path}/nnapi-gtest/nnapi_gtest.skip
252 tar -zxf test-suite.tar.gz -C %{buildroot}%{test_install_home}
253
254 %if %{coverage_build} == 1
255 mkdir -p %{buildroot}%{test_install_home}/gcov
256 find %{nnfw_workspace} -name "*.gcno" -exec xargs cp {} %{buildroot}%{test_install_home}/gcov/. \;
257 install -m 0644 ./tests/scripts/build_path.txt %{buildroot}%{test_install_dir}/test/build_path.txt
258 %endif # coverage_build
259 %endif # test_build
260
261 %if %{npud_build} == 1
262 install -m 755 build/out/bin/npud %{buildroot}%{_bindir}
263
264 %if %{test_build} == 1
265 mkdir -p %{test_install_path}/npud-gtest
266 install -m 755 build/out/npud-gtest/* %{test_install_path}/npud-gtest
267 %endif # test_build
268
269 %endif # npud_build
270
271 %endif
272
273 %post -p /sbin/ldconfig
274 %postun -p /sbin/ldconfig
275
276 %files
277 %manifest %{name}.manifest
278 %defattr(-,root,root,-)
279 %ifarch arm armv7l armv7hl aarch64 x86_64 %ix86
280 %{_libdir}/*.so
281 %exclude %{_includedir}/CL/*
282 %endif
283
284 %files devel
285 %manifest %{name}.manifest
286 %defattr(-,root,root,-)
287 %ifarch arm armv7l armv7hl aarch64 x86_64 %ix86
288 %dir %{_includedir}/nnfw
289 %{_includedir}/nnfw/*
290 %{_libdir}/pkgconfig/nnfw.pc
291 %endif
292
293 %files plugin-devel
294 %manifest %{name}.manifest
295 %defattr(-,root,root,-)
296 %ifarch arm armv7l armv7hl aarch64 x86_64 %ix86
297 %dir %{_includedir}/onert
298 %{_includedir}/onert/*
299 %{_libdir}/pkgconfig/nnfw-plugin.pc
300 %endif
301
302 %ifarch arm armv7l armv7hl aarch64 x86_64 %ix86
303 %files minimal-app
304 %manifest %{name}.manifest
305 %defattr(-,root,root,-)
306 %{_bindir}/onert-minimal-app
307 %endif
308
309 %if %{test_build} == 1
310 %files test
311 %manifest %{name}.manifest
312 %defattr(-,root,root,-)
313 %ifarch arm armv7l armv7hl aarch64 x86_64
314 %dir %{test_install_home}
315 %{test_install_home}/*
316 %endif # arm armv7l armv7hl aarch64
317 %endif # test_build
318
319 %if %{npud_build} == 1
320 %files npud
321 %manifest %{name}.manifest
322 %defattr(-,root,root,-)
323 %ifarch arm armv7l armv7hl aarch64 x86_64 %ix86
324 %{_bindir}/npud
325 %endif # arm armv7l armv7hl aarch64 x86_64 %ix86
326 %endif # npud_build
327
328 %changelog
329 * Thu Mar 15 2018 Chunseok Lee <chunseok.lee@samsung.com>
330 - Initial spec file for nnfw