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