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