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