[runtime/gbs] Revise nnfw.spec for tizen runtime rpm build (#8908)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 13 Nov 2019 04:30:22 +0000 (13:30 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 13 Nov 2019 04:30:22 +0000 (13:30 +0900)
- Build twice
  - Build for runtime (disable environment variable setting)
  - Build for test (enable environment variable setting)
- Enable extra option
- Use command instead of makefile
- Change file copy to install for library install
- Set required packages for package install
- Set own directory

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
packaging/nnfw.spec

index 5495fa6..b03982d 100644 (file)
@@ -11,18 +11,19 @@ Source1001: flatbuffers.tar.gz
 Source1002: nnapi_test_generated.tar.gz
 Source2001: nnfw.pc.in
 
-BuildRequires: cmake
-BuildRequires: boost-devel
-BuildRequires: gmock-devel
-BuildRequires: tensorflow-lite-devel
-BuildRequires: hdf5-devel
-BuildRequires: libaec-devel
-BuildRequires: zlib-devel
+BuildRequires:  cmake
+BuildRequires:  boost-devel
+BuildRequires:  gmock-devel
+BuildRequires:  tensorflow-lite-devel
+BuildRequires:  hdf5-devel
+BuildRequires:  libaec-devel
+BuildRequires:  zlib-devel
 
 %ifarch %{arm} aarch64
 # Require python for acl-ex library build pre-process
-BuildRequires: python
-BuildRequires: libarmcl-devel
+BuildRequires:  python
+BuildRequires:  libarmcl-devel
+Requires: libarmcl-release
 %endif
 
 Requires(post): /sbin/ldconfig
@@ -32,6 +33,7 @@ Requires(postun): /sbin/ldconfig
 %{!?test_build:     %define test_build      0}
 %{!?build_type:     %define build_type      Release}
 %{!?coverage_build: %define coverage_build  0}
+%{!?extra_option:   %define extra_option    %{nil}}
 
 %description
 nnfw is a high-performance, on-device neural network framework for Tizen
@@ -45,7 +47,9 @@ NNFW devel package.
 
 %package test
 Summary: NNFW Test
-Requires: nnfw
+Requires: libarmcl-release
+Requires: libhdf5-101
+Requires: libhdf5_cpp101
 
 %description test
 NNFW test rpm. It does not depends on nnfw rpm since it contains nnfw runtime.
@@ -60,23 +64,23 @@ NNFW test rpm. It does not depends on nnfw rpm since it contains nnfw runtime.
 %define target_arch aarch64
 %endif
 
-%define test_install_prefix /opt/usr/nnfw-test
-%define coverage_option COVERAGE_BUILD=0
-%define install_path INSTALL_PATH=%{buildroot}%{_prefix}
-%define extra_option OPTIONS=-DENVVAR_NEURUN_CONFIG=OFF
-%if %{test_build} == 1
-%define extra_option OPTIONS=-DENVVAR_NEURUN_CONFIG=ON
-%endif
+%define install_dir %{_prefix}
+%define install_path %{buildroot}%{install_dir}
+%define build_env NNFW_WORKSPACE=build
+%define build_options -DCMAKE_BUILD_TYPE=%{build_type} -DTARGET_ARCH=%{target_arch} -DTARGET_OS=tizen
+
+# Set option for test build (and coverage test build)
+%define test_install_home /opt/usr/nnfw-test
+%define test_install_dir %{test_install_home}/Product/out
+%define test_install_path %{buildroot}%{test_install_dir}
+%define coverage_option %{nil}
+%define test_suite_list infra/scripts tests/scripts tests/framework
 %if %{coverage_build} == 1
-%define coverage_option COVERAGE_BUILD=1
-%define install_path %{nil}
+%define coverage_option -DENABLE_COVERAGE=ON
 %define build_type Debug
-%define extra_option OPTIONS=-DENVVAR_NEURUN_CONFIG=ON
 %endif
-
-# TODO Set install path for public header
-#      Current build assume that %{_includedir} == %{_prefix}/include
-%define build_options %{coverage_option} BUILD_TYPE=%{build_type} %{install_path} TARGET_ARCH=%{target_arch} TARGET_OS=tizen %{extra_option}
+%define test_build_env NNFW_INSTALL_PREFIX=%{test_install_path} NNFW_WORKSPACE=build_for_test
+%define test_build_options %{coverage_option} -DCMAKE_BUILD_TYPE=%{build_type} -DTARGET_ARCH=%{target_arch} -DTARGET_OS=tizen -DENVVAR_NEURUN_CONFIG=ON
 
 %prep
 %setup -q
@@ -87,44 +91,41 @@ tar -xf %{SOURCE1002} -C ./tests/nnapi/src/
 
 %build
 %ifarch arm armv7l aarch64
-cp -v Makefile.template Makefile
-%{build_options} make %{?jobs:-j%jobs} all
+# runtime build
+%{build_env} ./nnfw configure %{build_options} %{extra_option}
+%{build_env} ./nnfw build
+# install in workspace
+# TODO Set install path
+%{build_env} ./nnfw install
+
+# test runtime
+# TODO remove duplicated build process
+%{test_build_env} ./nnfw configure %{test_build_options} %{extra_option}
+%{test_build_env} ./nnfw build
+%if %{coverage_build} == 1
+pwd | grep -o '/' | wc -l > tests/scripts/build_path_depth.txt
+%endif
+tar -zcf test-suite.tar.gz infra/scripts tests/scripts tests/framework
 %endif
 
 %install
 %ifarch arm armv7l aarch64
-%{build_options} make install
-
-%if %{coverage_build} == 0
-# nnfw-test rpm(like test-suite on cross build)
-## install Product
-mkdir -p %{buildroot}%{test_install_prefix}/Product/out
-mv %{buildroot}%{_prefix}/unittest %{buildroot}%{test_install_prefix}/Product/out
-mv %{buildroot}%{_prefix}/bin %{buildroot}%{test_install_prefix}/Product/out
-cp -rf %{buildroot}%{_libdir} %{buildroot}%{test_install_prefix}/Product/out
-## install tests
-mkdir -p %{buildroot}%{test_install_prefix}/tests
-cp -rf ./tests/framework %{buildroot}%{test_install_prefix}/tests
-## install tools
-mkdir -p %{buildroot}%{test_install_prefix}/tools
-cp -rf ./tests/scripts %{buildroot}%{test_install_prefix}/tests
-## install infra
-mkdir -p %{buildroot}%{test_install_prefix}/infra
-cp -rf ./infra/scripts/ %{buildroot}%{test_install_prefix}/infra
-%else
-%{build_options}  make build_coverage_suite
-mkdir -p %{buildroot}%{test_install_prefix}
-cp -rf Product/out/coverage-suite.tar.gz %{buildroot}%{test_install_prefix}/.
-tar -zxf %{buildroot}%{test_install_prefix}/coverage-suite.tar.gz -C %{buildroot}%{test_install_prefix}
-rm -rf %{buildroot}%{test_install_prefix}/coverage-suite.tar.gz
-%endif
 
+mkdir -p %{buildroot}%{_libdir}
+mkdir -p %{buildroot}%{_includedir}
+install -m 644 build/out/lib/*.so %{buildroot}%{_libdir}
+cp -r build/out/include/* %{buildroot}%{_includedir}/
+
+# For developer
 cp %{SOURCE2001} .
 sed -i 's:@libdir@:%{_libdir}:g
         s:@includedir@:%{_includedir}:g' ./nnfw.pc.in
 mkdir -p %{buildroot}%{_libdir}/pkgconfig
 install -m 0644 ./nnfw.pc.in %{buildroot}%{_libdir}/pkgconfig/nnfw.pc
 
+%{test_build_env} ./nnfw install
+tar -zxf test-suite.tar.gz -C %{buildroot}%{test_install_home}
+
 %endif
 
 %post -p /sbin/ldconfig
@@ -141,7 +142,8 @@ install -m 0644 ./nnfw.pc.in %{buildroot}%{_libdir}/pkgconfig/nnfw.pc
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
 %ifarch arm armv7l aarch64
-%{_includedir}/*
+%dir %{_includedir}/nnfw
+%{_includedir}/nnfw/*
 %{_libdir}/pkgconfig/nnfw.pc
 %endif
 
@@ -149,7 +151,8 @@ install -m 0644 ./nnfw.pc.in %{buildroot}%{_libdir}/pkgconfig/nnfw.pc
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
 %ifarch arm armv7l aarch64
-%{test_install_prefix}/*
+%dir %{test_install_home}
+%{test_install_home}/*
 %exclude %{_libdir}/debug
 %endif