Dist/Tizen: support selective framework and pkgconfig
authorParichay Kapoor <pk.kapoor@samsung.com>
Tue, 31 Dec 2019 10:29:38 +0000 (19:29 +0900)
committerInki Dae <inki.dae@samsung.com>
Thu, 4 Mar 2021 05:20:38 +0000 (14:20 +0900)
Add package config for armnn package
Add selective enabling of framework in build
Add flatc while building with flatbuffers
Add tflite header files

Change-Id: I77eecd22cf80eb4c5ccfb2a83399354869dac39b
Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
armnn.pc [new file with mode: 0644]
packaging/armnn.spec

diff --git a/armnn.pc b/armnn.pc
new file mode 100644 (file)
index 0000000..8274a98
--- /dev/null
+++ b/armnn.pc
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=${prefix}
+includedir=${prefix}/include
+libdir=${exec_prefix}/lib
+sharedlibdir=${prefix}/share
+
+Name: armnn
+Description: Arm Neural Network Library
+Version: 19.11
+Libs: -L${libdir} -larmnn CAFFE_SUPPORT TF_LITE_SUPPORT -lpthread
+Cflags: -I${includedir}
index 8807601..57659f5 100644 (file)
@@ -5,9 +5,17 @@ License:        MIT License
 Summary:        Arm Neural Networks library
 Group:          Machine Learning / ML Framework
 Source0:        %{name}-%{version}.tar.gz
-Source1001:    %name.manifest
+Source1001:     %{name}.manifest
 ExclusiveArch:  %arm aarch64
 
+%define OPEN_CL_SUPPORT 1
+%define CAFFE_SUPPORT 1
+%define TF_LITE_SUPPORT 1
+
+%if 0%{?OPEN_CL_SUPPORT} != 1
+  %define CAFFE_SUPPORT 0
+%endif
+
 BuildRequires: curl
 BuildRequires: cmake
 BuildRequires: libarmcl-devel
@@ -38,22 +46,27 @@ BuildRequires: boost-signals
 BuildRequires: boost-system
 BuildRequires: boost-test
 BuildRequires: boost-devel
+%if 0%{?TF_LITE_SUPPORT} == 1
 BuildRequires: tensorflow-lite-devel
-BuildRequires:libcaffeonacl-devel
+%endif
+%if 0%{?CAFFE_SUPPORT} == 1
+BuildRequires: libcaffeonacl-devel
+%endif
 
 %description
 Arm Neural Networks Library
 
 %package devel
-Summary:        Userspace interface to ARM Neural Network Library
-Requires:       armnn = %{version}-%{release}
+Summary:  Userspace interface to ARM Neural Network Library
+Provides: pkgconfig(rpm)
+Requires: %{name} = %{version}-%{release}
 
 %description devel
 Summary:        Userspace interface to ARM Neural Network Library
 
 %package tools
 Summary:       Sample application and benchmark binaries to test ARM Neural Network Library
-Requires:      armnn = %{version}-%{release}
+Requires:      %{name} = %{version}-%{release}
 
 %description tools
 Summary:       Sample application and benchmark binaries to test ARM Neural Network Library
@@ -62,6 +75,18 @@ Summary:     Sample application and benchmark binaries to test ARM Neural Network Li
 %setup -q
 cp %{SOURCE1001} .
 
+%if 0%{?CAFFE_SUPPORT} == 1
+sed -i 's/CAFFE_SUPPORT /-larmnnCaffeParser /g' armnn.pc
+%else # CAFFE_SUPPORT
+sed -i 's/CAFFE_SUPPORT //g' armnn.pc
+%endif # CAFFE_SUPPORT
+
+%if 0%{?TF_LITE_SUPPORT} == 1
+sed -i 's/TF_LITE_SUPPORT /-larmnnTfLiteParser /g' armnn.pc
+%else # TF_LITE_SUPPORT
+sed -i 's/TF_LITE_SUPPORT //g' armnn.pc
+%endif # TF_LITE_SUPPORT
+
 %build
 
 #compile proto files
@@ -75,38 +100,60 @@ cp %{SOURCE1001} .
 
 #build ArmNN
 cmake -DARMCOMPUTENEON=1                                       \
+%if 0%{?OPEN_CL_SUPPORT} == 1
       -DARMCOMPUTECL=1                                         \
+%endif # TF_LITE_SUPPORT
       -DSHARED_BOOST=1                                         \
       -DCMAKE_SKIP_RPATH=1                                     \
+%if 0%{?CAFFE_SUPPORT} == 1
       -DBUILD_CAFFE_PARSER=1                                   \
       -DCAFFE_GENERATED_SOURCES=/usr/include                   \
+%endif # CAFFE_SUPPORT
+%if 0%{?TF_LITE_SUPPORT} == 1
       -DBUILD_TF_LITE_PARSER=1                                 \
       -DTF_LITE_GENERATED_PATH=./tensorflow/contrib/lite/schema        \
+%endif # TF_LITE_SUPPORT
       -DFLATBUFFERS_INCLUDE_PATH=/usr/include/                 \
+      -DFLATC=/usr/bin/flatc      \
       -DBUILD_TESTS=1                                          \
 
-make
+make -j8
 
 %install
 mkdir -p %{buildroot}%{_libdir}
+mkdir -p %{buildroot}%{_libdir}/pkgconfig
 mkdir -p %{buildroot}%{_bindir}/armnn
 mkdir -p %{buildroot}%{_includedir}/armnn
-mkdir -p %{buildroot}%{_includedir}/armnnCaffeParser
+%if 0%{?CAFFE_SUPPORT} == 1
+  mkdir -p %{buildroot}%{_includedir}/armnnCaffeParser
+%endif # CAFFE_SUPPORT
 mkdir -p %{buildroot}%{_includedir}/armnnTfParser
+%if 0%{?TF_LITE_SUPPORT} == 1
+  mkdir -p %{buildroot}%{_includedir}/armnnTfLiteParser
+%endif # TF_LITE_SUPPORT
 
 #prepare stb
 mkdir -p %{buildroot}%{_includedir}
 cp -ar external/stb %{buildroot}%{_includedir}
 
+install armnn.pc %{buildroot}%{_libdir}/pkgconfig/
+
 install -m 0755 bin/*-Armnn %{buildroot}%{_bindir}/armnn/
 install -m 0755 bin/ExecuteNetwork %{buildroot}%{_bindir}/armnn/
-install -m 0755 bin/MultipleNetworksCifar10 %{buildroot}%{_bindir}/armnn/
+%if 0%{?CAFFE_SUPPORT} == 1
+  install -m 0755 bin/MultipleNetworksCifar10 %{buildroot}%{_bindir}/armnn/
+%endif # CAFFE_SUPPORT
 install -m 0755 UnitTests %{buildroot}%{_bindir}/armnn/
 
 install -m 0644 lib*.so %{buildroot}%{_libdir}/
 install -m 0644 include/armnn/* %{buildroot}%{_includedir}/armnn/
-install -m 0644 include/armnnCaffeParser/* %{buildroot}%{_includedir}/armnnCaffeParser/
+%if 0%{?CAFFE_SUPPORT} == 1
+  install -m 0644 include/armnnCaffeParser/* %{buildroot}%{_includedir}/armnnCaffeParser/
+%endif # CAFFE_SUPPORT
 install -m 0644 include/armnnTfParser/* %{buildroot}%{_includedir}/armnnTfParser/
+%if 0%{?TF_LITE_SUPPORT} == 1
+  install -m 0644 include/armnnTfLiteParser/* %{buildroot}%{_includedir}/armnnTfLiteParser/
+%endif # TF_LITE_SUPPORT
 
 %post -p /sbin/ldconfig
 %postun -p /sbin/ldconfig
@@ -117,6 +164,7 @@ install -m 0644 include/armnnTfParser/* %{buildroot}%{_includedir}/armnnTfParser
 
 %files devel
 %manifest %{name}.manifest
+%{_libdir}/pkgconfig/armnn.pc
 %{_includedir}/*
 
 %files tools