Imported Upstream version 1.19.0
[platform/core/ml/nnfw.git] / packaging / nnfw.spec
1 Name:    nnfw
2 Summary: nnfw
3 Version: 1.19.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 Source1001: nnapi_test_generated.tar.gz
11 Source1002: gtest.tar.gz
12 Source1003: eigen.tar.gz
13 Source1004: gemmlowp.tar.gz
14 Source1005: ruy.tar.gz
15 Source1006: cpuinfo.tar.gz
16 Source1007: XNNPACK.tar.gz
17 Source1008: FXDIV.tar.gz
18 Source1009: PTHREADPOOL.tar.gz
19 Source1010: PSIMD.tar.gz
20 Source1011: FP16.tar.gz
21 Source1012: OPENCL_HEADERS.tar.gz
22 Source1013: FARMHASH.tar.gz
23 Source1014: ABSEIL.tar.gz
24 Source1015: oourafft.tar.gz
25 Source2001: nnfw.pc.in
26 Source2002: nnfw-plugin.pc.in
27
28 %{!?build_type:     %define build_type      Release}
29 %{!?coverage_build: %define coverage_build  0}
30 %{!?test_build:     %define test_build      0}
31 %{!?extra_option:   %define extra_option    %{nil}}
32 %if %{coverage_build} == 1
33 %define test_build 1
34 %endif
35
36 BuildRequires:  cmake
37 # Require flatbuffers-devel for onert frontend (model loading)
38 BuildRequires:  flatbuffers-devel
39
40 %ifarch %{arm} aarch64
41 # Require python for acl-ex library build pre-process
42 BuildRequires:  python
43 BuildRequires:  libarmcl-devel >= v21.02
44 %endif
45
46 Requires(post): /sbin/ldconfig
47 Requires(postun): /sbin/ldconfig
48
49 %if %{test_build} == 1
50 BuildRequires:  boost-devel
51 BuildRequires:  tensorflow-lite-devel
52 BuildRequires:  hdf5-devel
53 BuildRequires:  libaec-devel
54 BuildRequires:  zlib-devel
55 BuildRequires:  libjpeg-devel
56 %endif
57
58 %description
59 nnfw is a high-performance, on-device neural network framework for Tizen
60
61 %package devel
62 Summary: NNFW Devel Package
63 Requires: %{name} = %{version}-%{release}
64
65 %description devel
66 NNFW development package for application developer using runtime
67
68 %package plugin-devel
69 Summary: NNFW Devel Package
70 Requires: %{name}-devel = %{version}-%{release}
71
72 %description plugin-devel
73 NNFW development package for backend plugin developer
74
75 %package minimal-app
76 Summary: Minimal test binary for VD manual test
77
78 %description minimal-app
79 Minimal test binary for VD manual test
80
81 %if %{test_build} == 1
82 %package test
83 Summary: NNFW Test
84
85 %description test
86 NNFW test rpm. It does not depends on nnfw rpm since it contains nnfw runtime.
87 %endif
88
89 %ifarch %{arm}
90 %define target_arch armv7l
91 %endif
92 %ifarch x86_64
93 %define target_arch x86_64
94 %endif
95 %ifarch aarch64
96 %define target_arch aarch64
97 %endif
98 %ifarch %ix86
99 %define target_arch i686
100 %endif
101
102 %define install_dir %{_prefix}
103 %define install_path %{buildroot}%{install_dir}
104 %define build_env NNFW_WORKSPACE=build
105 %define build_options -DCMAKE_BUILD_TYPE=%{build_type} -DTARGET_ARCH=%{target_arch} -DTARGET_OS=tizen -DENABLE_TEST=off -DBUILD_MINIMAL_SAMPLE=on
106
107 # Set option for test build (and coverage test build)
108 %define test_install_home /opt/usr/nnfw-test
109 %define test_install_dir %{test_install_home}/Product/out
110 %define test_install_path %{buildroot}%{test_install_dir}
111 %define coverage_option %{nil}
112 %define test_suite_list infra/scripts tests/scripts
113 %define test_build_type %{build_type}
114 %if %{coverage_build} == 1
115 %define coverage_option -DENABLE_COVERAGE=ON
116 %define test_build_type Debug
117 %endif
118 %define test_build_env NNFW_INSTALL_PREFIX=%{test_install_path} NNFW_WORKSPACE=build_for_test
119 %define test_build_options %{coverage_option} -DCMAKE_BUILD_TYPE=%{test_build_type} -DTARGET_ARCH=%{target_arch} -DTARGET_OS=tizen -DENVVAR_ONERT_CONFIG=ON
120
121 %prep
122 %setup -q
123 cp %{SOURCE1} .
124 mkdir ./externals
125 tar -xf %{SOURCE1001} -C ./tests/nnapi/src/
126 tar -xf %{SOURCE1002} -C ./externals
127 tar -xf %{SOURCE1003} -C ./externals
128 tar -xf %{SOURCE1004} -C ./externals
129 tar -xf %{SOURCE1005} -C ./externals
130 tar -xf %{SOURCE1006} -C ./externals
131 tar -xf %{SOURCE1007} -C ./externals
132 tar -xf %{SOURCE1008} -C ./externals
133 tar -xf %{SOURCE1009} -C ./externals
134 tar -xf %{SOURCE1010} -C ./externals
135 tar -xf %{SOURCE1011} -C ./externals
136 tar -xf %{SOURCE1012} -C ./externals
137 tar -xf %{SOURCE1013} -C ./externals
138 tar -xf %{SOURCE1014} -C ./externals
139 tar -xf %{SOURCE1015} -C ./externals
140
141 %build
142 %ifarch arm armv7l aarch64 x86_64 %ix86
143 # runtime build
144 %{build_env} ./nnfw configure %{build_options} %{extra_option}
145 %{build_env} ./nnfw build -j4
146 # install in workspace
147 # TODO Set install path
148 %{build_env} ./nnfw install
149
150 %if %{test_build} == 1
151 # test runtime
152 # TODO remove duplicated build process
153 %{test_build_env} ./nnfw configure %{test_build_options} %{extra_option}
154 %{test_build_env} ./nnfw build -j4
155 %if %{coverage_build} == 1
156 pwd > tests/scripts/build_path.txt
157 %endif # coverage_build
158 tar -zcf test-suite.tar.gz infra/scripts
159 %endif # test_build
160 %endif # arm armv7l aarch64
161
162 %install
163 %ifarch arm armv7l aarch64 x86_64 %ix86
164
165 mkdir -p %{buildroot}%{_libdir}
166 mkdir -p %{buildroot}%{_bindir}
167 mkdir -p %{buildroot}%{_includedir}
168 install -m 644 build/out/lib/*.so %{buildroot}%{_libdir}
169 install -m 755 build/out/bin/onert-minimal-app %{buildroot}%{_bindir}
170 cp -r build/out/include/* %{buildroot}%{_includedir}/
171
172 # For developer
173 cp %{SOURCE2001} .
174 cp %{SOURCE2002} .
175 sed -i 's:@libdir@:%{_libdir}:g
176         s:@includedir@:%{_includedir}:g
177         s:@version@:%{version}:g' ./nnfw.pc.in
178 sed -i 's:@libdir@:%{_libdir}:g
179         s:@includedir@:%{_includedir}:g
180         s:@version@:%{version}:g' ./nnfw-plugin.pc.in
181 mkdir -p %{buildroot}%{_libdir}/pkgconfig
182 install -m 0644 ./nnfw.pc.in %{buildroot}%{_libdir}/pkgconfig/nnfw.pc
183 install -m 0644 ./nnfw-plugin.pc.in %{buildroot}%{_libdir}/pkgconfig/nnfw-plugin.pc
184
185 %if %{test_build} == 1
186 %{test_build_env} ./nnfw install
187 # Share test script with ubuntu (ignore error if there is no list for target)
188 cp tests/nnapi/nnapi_gtest.skip.%{target_arch}-* %{buildroot}%{test_install_dir}/unittest/.
189 cp %{buildroot}%{test_install_dir}/unittest/nnapi_gtest.skip.%{target_arch}-linux.cpu %{buildroot}%{test_install_dir}/unittest/nnapi_gtest.skip
190 tar -zxf test-suite.tar.gz -C %{buildroot}%{test_install_home}
191
192 %if %{coverage_build} == 1
193 mkdir -p %{buildroot}%{test_install_home}/gcov
194 find . -name "*.gcno" -exec xargs cp {} %{buildroot}%{test_install_home}/gcov/. \;
195 install -m 0644 ./tests/scripts/build_path.txt %{buildroot}%{test_install_dir}/test/build_path.txt
196 %endif # coverage_build
197 %endif # test_build
198
199 %endif
200
201 %post -p /sbin/ldconfig
202 %postun -p /sbin/ldconfig
203
204 %files
205 %manifest %{name}.manifest
206 %defattr(-,root,root,-)
207 %ifarch arm armv7l aarch64 x86_64 %ix86
208 %{_libdir}/*.so
209 %exclude %{_includedir}/CL/*
210 %endif
211
212 %files devel
213 %manifest %{name}.manifest
214 %defattr(-,root,root,-)
215 %ifarch arm armv7l aarch64 x86_64 %ix86
216 %dir %{_includedir}/nnfw
217 %{_includedir}/nnfw/*
218 %{_libdir}/pkgconfig/nnfw.pc
219 %endif
220
221 %files plugin-devel
222 %manifest %{name}.manifest
223 %defattr(-,root,root,-)
224 %ifarch arm armv7l aarch64 x86_64 %ix86
225 %dir %{_includedir}/onert
226 %{_includedir}/onert/*
227 %{_libdir}/pkgconfig/nnfw-plugin.pc
228 %endif
229
230 %ifarch arm armv7l aarch64 x86_64 %ix86
231 %files minimal-app
232 %manifest %{name}.manifest
233 %defattr(-,root,root,-)
234 %{_bindir}/onert-minimal-app
235 %endif
236
237 %if %{test_build} == 1
238 %files test
239 %manifest %{name}.manifest
240 %defattr(-,root,root,-)
241 %ifarch arm armv7l aarch64 x86_64
242 %dir %{test_install_home}
243 %{test_install_home}/*
244 %endif # arm armv7l aarch64
245 %endif # test_build
246
247 %changelog
248 * Thu Mar 15 2018 Chunseok Lee <chunseok.lee@samsung.com>
249 - Initial spec file for nnfw