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