Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / packaging / nnfw.spec
index 6f17cf9..a972af3 100644 (file)
@@ -1,6 +1,6 @@
 Name:    nnfw
 Summary: nnfw
-Version: 1.22.1
+Version: 1.25.0
 Release: 1
 Group:   Development
 License: Apache-2.0 and MIT and BSD-2-Clause and MPL-2.0
@@ -31,12 +31,16 @@ Source3018: XNNPACK.tar.gz
 Source3019: FLATBUFFERS-2.0.tar.gz
 
 %{!?build_type:     %define build_type      Release}
-%{!?npud_build:     %define npud_build      0}
+%{!?npud_build:     %define npud_build      1}
 %{!?trix_support:   %define trix_support    1}
+%{!?odc_build:      %define odc_build       1}
 %{!?coverage_build: %define coverage_build  0}
 %{!?test_build:     %define test_build      0}
 %{!?extra_option:   %define extra_option    %{nil}}
-%{!?config_support: %define config_support  0}
+%{!?config_support: %define config_support  1}
+# Define nproc on gbs build option if you want to set number of build threads manually (ex. CI/CD infra)
+%define build_jobs   %{?!nproc:%{?_smp_mflags}%{?!_smp_mflags:-j4}}%{?nproc:-j%nproc}
+%{!?nproc:          %define nproc           %{?!jobs:4}%{?jobs}}
 
 %if %{coverage_build} == 1
 # Coverage test requires debug build runtime
@@ -84,6 +88,14 @@ Requires: %{name}-devel = %{version}-%{release}
 %description plugin-devel
 NNFW development package for backend plugin developer
 
+%if %{odc_build} == 1
+%package odc
+Summary: NNFW On-Device Compilation Package
+
+%description odc
+NNFW package for on-device compilation
+%endif # odc_build
+
 %package minimal-app
 Summary: Minimal test binary for VD manual test
 
@@ -129,12 +141,15 @@ NPU daemon for optimal management of NPU hardware
 %define install_path %{buildroot}%{install_dir}
 %define nnfw_workspace build
 %define build_env NNFW_WORKSPACE=%{nnfw_workspace}
+%define nncc_workspace build/nncc
+%define nncc_env NNCC_WORKSPACE=%{nncc_workspace}
+%define overlay_path %{nnfw_workspace}/overlay
 
 # Path to install test bin and scripts (test script assumes path Product/out)
 # TODO Share path with release package
 %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 test_install_path %{buildroot}/%{test_install_dir}
 
 # Set option for test build (and coverage test build)
 %define option_test -DENABLE_TEST=OFF
@@ -148,22 +163,19 @@ NPU daemon for optimal management of NPU hardware
 
 # Set option for configuration
 %define option_config %{nil}
-%if %{npud_build} == 1
 %if %{config_support} == 1
+%if %{npud_build} == 1
 # ENVVAR_NPUD_CONFIG: Use environment variable for npud configuration and debug
-%define option_config -DBUILD_NPUD=ON -DENVVAR_NPUD_CONFIG=ON
-%else
-%define option_config -DBUILD_NPUD=ON -DENVVAR_NPUD_CONFIG=OFF
-%endif # config_support
-%else
-%define option_config -DBUILD_NPUD=OFF
+%define option_config -DENVVAR_NPUD_CONFIG=ON
 %endif # npud_build
+%endif # config_support
 
 %if %{coverage_build} == 1
 %define option_coverage -DENABLE_COVERAGE=ON
 %endif # coverage_build
 
-%define build_options -DCMAKE_BUILD_TYPE=%{build_type} -DTARGET_ARCH=%{target_arch} -DTARGET_OS=tizen -DBUILD_MINIMAL_SAMPLE=ON \\\
+%define build_options -DCMAKE_BUILD_TYPE=%{build_type} -DTARGET_ARCH=%{target_arch} -DTARGET_OS=tizen \\\
+        -DEXTERNALS_BUILD_THREAD=%{nproc} -DBUILD_MINIMAL_SAMPLE=ON -DNNFW_OVERLAY_DIR=$(pwd)/%{overlay_path} \\\
         %{option_test} %{option_coverage} %{option_config} %{extra_option}
 
 %prep
@@ -193,9 +205,24 @@ tar -xf %{SOURCE3019} -C ./externals
 
 %build
 %ifarch arm armv7l armv7hl aarch64 x86_64 %ix86
+# nncc build
+%if %{odc_build} == 1
+%{nncc_env} ./nncc configure -DBUILD_GTEST=OFF -DENABLE_TEST=OFF -DEXTERNALS_BUILD_THREADS=%{nproc} -DCMAKE_BUILD_TYPE=%{build_type} -DTARGET_OS=tizen \
+        -DCMAKE_INSTALL_PREFIX=$(pwd)/%{overlay_path} \
+       -DBUILD_WHITELIST="luci;foder;pepper-csv2vec;loco;locop;logo;logo-core;mio-circle06;luci-compute;oops;hermes;hermes-std;angkor;pp;pepper-strcast;pepper-str"
+%{nncc_env} ./nncc build %{build_jobs}
+cmake --install %{nncc_workspace}
+%endif # odc_build
+
+# install angkor TensorIndex and oops InternalExn header (TODO: Remove this)
+mkdir -p %{overlay_path}/include/nncc/core/ADT/tensor
+mkdir -p %{overlay_path}/include/oops
+cp compiler/angkor/include/nncc/core/ADT/tensor/Index.h %{overlay_path}/include/nncc/core/ADT/tensor
+cp compiler/oops/include/oops/InternalExn.h %{overlay_path}/include/oops
+
 # runtime build
 %{build_env} ./nnfw configure %{build_options}
-%{build_env} ./nnfw build -j4
+%{build_env} ./nnfw build %{build_jobs}
 # install in workspace
 # TODO Set install path
 %{build_env} ./nnfw install
@@ -258,6 +285,13 @@ install -m 0644 ./tests/scripts/build_path.txt %{buildroot}%{test_install_dir}/t
 %endif # coverage_build
 %endif # test_build
 
+%if %{odc_build} == 1
+mkdir -p %{buildroot}%{_libdir}/nnfw/odc
+install -m 644 %{overlay_path}/lib/libluci*.so %{buildroot}%{_libdir}/nnfw/odc
+install -m 644 %{overlay_path}/lib/libloco*.so %{buildroot}%{_libdir}/nnfw/odc
+install -m 644 build/out/lib/nnfw/odc/*.so %{buildroot}%{_libdir}/nnfw/odc
+%endif # odc_build
+
 %if %{npud_build} == 1
 install -m 755 build/out/bin/npud %{buildroot}%{_bindir}
 
@@ -325,6 +359,16 @@ install -m 755 build/out/npud-gtest/* %{test_install_path}/npud-gtest
 %endif # arm armv7l armv7hl aarch64 x86_64 %ix86
 %endif # npud_build
 
+%if %{odc_build} == 1
+%files odc
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%ifarch arm armv7l armv7hl aarch64 x86_64 %ix86
+%dir %{_libdir}/nnfw/odc
+%{_libdir}/nnfw/odc/*
+%endif # arm armv7l armv7hl aarch64 x86_64 %ix86
+%endif # odc_build
+
 %changelog
 * Thu Mar 15 2018 Chunseok Lee <chunseok.lee@samsung.com>
 - Initial spec file for nnfw