File nnstreamer.spec of Package nnstreamer
# Prefer version 2.x of Tensorflow
%bcond_with tensorflow_support
%bcond_with tensorflow_lite_support
%ifarch %{arm}
# No TF2 on 32-bit Arm
%bcond_with tensorflow2_support
%else
%bcond_without tensorflow2_support
%endif
%bcond_without tensorflow2_lite_support
%bcond_with flatbuf_support
%bcond_without protobuf_support
%bcond_with grpc_support
%bcond_with pytorch_support
%bcond_with caffe2_support
%bcond_without check_test
%bcond_with enable_tizen_privilege
%bcond_with enable_tizen_feature
%bcond_with release_test
%bcond_with enable_tizen_privilege
%bcond_with tizen
%bcond_without python3_support
%bcond_with tizen_sensor_support
%bcond_with mvncsdk2_support
%bcond_with openvino_support
# Disable e-TPU
%bcond_with edgetpu_support
%ifarch %arm aarch64
# Disable for now due to https://github.com/ARM-software/armnn/issues/514
%bcond_with armnn_support
%else
%bcond_with armnn_support
%endif
# No nnfw package yet
%bcond_with nnfw_support
# Disable Unit tests - No ssat package yet - https://github.com/myungjoo/SSAT/issues/18
%bcond_with unit_test
%define gstpostfix gstreamer-1.0
%define gstlibdir %{_libdir}/%{gstpostfix}
%define nnstbindir /usr/lib/nnstreamer/bin
Name: nnstreamer
Summary: gstreamer plugins for neural networks
Version: 2.0.0
Release: 0
License: LGPL-2.1
Url: https://github.com/nnstreamer/nnstreamer
Source0: https://github.com/nnstreamer/nnstreamer/archive/v%{version}.tar.gz#/nnstreamer-%{version}.tar.gz
# PATCH-FIX-UPSTREAM - https://github.com/nnstreamer/nnstreamer/issues/3218#issuecomment-977885118
Patch1: nnstreamer-fix-glib-2.68.patch
# PATCH-FIX-UPSTREAM - https://github.com/nnstreamer/nnstreamer/pull/3580
Patch2: nnstreamer-3580.patch
## Define build requirements ##
BuildRequires: bison
BuildRequires: flex
BuildRequires: gcc-c++
Requires: gstreamer >= 1.8.0
BuildRequires: gstreamer-devel
BuildRequires: gstreamer-plugins-base-devel
BuildRequires: gstreamer-plugins-bad-devel
BuildRequires: glib2-devel
BuildRequires: meson >= 0.50.0
BuildRequires: cmake
BuildRequires: pkgconfig
# To run test cases, we need gst plugins
BuildRequires: gstreamer-plugins-good
BuildRequires: gstreamer-plugins-good-extra
BuildRequires: gstreamer-plugins-base
# and gtest
BuildRequires: gtest
# for python3 custom filters
BuildRequires: python3-devel
BuildRequires: python3-numpy-devel
# Testcase requires bmp2png, which requires libpng
BuildRequires: pkgconfig(libpng)
%if %{with flatbuf_support}
# for flatbuffers
BuildRequires: flatbuffers-devel
%endif
%if %{with tensorflow_lite_support}
# for tensorflow-lite
BuildRequires: tensorflow-lite-devel
%endif
%if %{with tensorflow2_lite_support}
# for tensorflow2-lite
BuildRequires: flatbuffers-devel
BuildRequires: tensorflow2-lite-devel
%endif
# custom_example_opencv filter requires opencv-devel
BuildRequires: opencv-devel
# For './testAll.sh' time limit.
BuildRequires: procps
# for protobuf
%if %{with protobuf_support}
BuildRequires: protobuf-devel >= 3.6.1
%endif
# for tensorflow
%if %{with tensorflow_support}
BuildRequires: tensorflow-devel
%endif
%if %{with tensorflow2_support}
BuildRequires: tensorflow2-devel
%endif
# for armnn
%if %{with armnn_support}
BuildRequires: armnn-devel
BuildRequires: ComputeLibrary-devel
%endif
%if %{with edgetpu_support}
BuildRequires: libedgetpu
%endif
%if %{with testcoverage}
# to be compatible with gcc-9, lcov should have a higher version than 1.14.1
BuildRequires: lcov
# BuildRequires: taos-ci-unittest-coverage-assessment
%endif
%if %{with mvncsdk2_support}
BuildRequires: pkgconfig(libmvnc)
%endif
%if %{with openvino_support}
BuildRequires: pkgconfig(openvino)
%endif
%if %{with grpc_support}
BuildRequires: grpc-devel
%endif
%if %{with tizen}
%if %{with enable_tizen_privilege}
BuildRequires: pkgconfig(dpm)
BuildRequires: pkgconfig(capi-privacy-privilege-manager)
BuildRequires: pkgconfig(mm-camcorder)
%if %{with tizen_version_major} >= 5
BuildRequires: pkgconfig(mm-resource-manager)
%endif
%endif
BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(dlog)
# For tizen sensor support
BuildRequires: pkgconfig(sensor)
BuildRequires: capi-system-sensor-devel
%endif # tizen
%if %{with nnfw_support}
BuildRequires: json-glib-devel
BuildRequires: nnfw-devel
%ifarch %arm aarch64
BuildRequires: ComputeLibrary-devel
%endif
%endif
%if %{with pytorch_support}
BuildRequires: pytorch-devel
%endif
# Caffe2 is merged to pytorch
%if %{with caffe2_support}
BuildRequires: pytorch-devel
%endif
# Unit Testing Uses SSAT (hhtps://github.com/myungjoo/SSAT.git)
%if %{with unit_test}
BuildRequires: ssat >= 1.1.0
%endif
# For ORC (Oil Runtime Compiler)
BuildRequires: pkgconfig(orc-0.4)
# Build only where Tensorflow (or TF-lite) is available
ExclusiveArch: aarch64 %{arm} x86_64
## Define Packages ##
%description
NNStreamer is a set of gstreamer plugins to support general neural networks
and their plugins in a gstreamer stream.
%if %{with tensorflow_support}
%package tensorflow
Summary: NNStreamer TensorFlow Support
Requires: nnstreamer = %{version}-%{release}
Requires: tensorflow
%description tensorflow
NNStreamer's tensor_fliter subplugin of TensorFlow.
It uses C-API of tensorflow, which is not yet stable as of 1.1x.
Thus, the user needs to check the version of Tensorflow with the
Tensorflow used for building this package.
%endif
%if %{with tensorflow_lite_support}
%package tensorflow-lite
Summary: NNStreamer TensorFlow Lite Support
Requires: nnstreamer = %{version}-%{release}
%description tensorflow-lite
NNStreamer's tensor_fliter subplugin of TensorFlow Lite.
%endif
%if %{with tensorflow2_support}
%package tensorflow2
Summary: NNStreamer TensorFlow2 Support
Requires: nnstreamer = %{version}-%{release}
%description tensorflow2
NNStreamer's tensor_fliter subplugin of TensorFlow.
It uses C-API of tensorflow, which is not yet stable as of 1.1x.
Thus, the user needs to check the version of Tensorflow with the
Tensorflow used for building this package.
%endif
%if %{with tensorflow2_lite_support}
%package tensorflow2-lite
Summary: NNStreamer TensorFlow2 Lite Support
Requires: nnstreamer = %{version}-%{release}
%description tensorflow2-lite
NNStreamer's tensor_fliter subplugin of TensorFlow2 Lite.
%endif
%if %{with python3_support}
%package python3
Summary: NNStreamer Python3 Custom Filter Support
Requires: nnstreamer = %{version}-%{release}
%description python3
NNStreamer's tensor_filter subplugin of Python3.
%endif
%if %{with armnn_support}
%package armnn
Summary: NNStreamer Arm NN support
Requires: armnn
%description armnn
NNStreamer's tensor_filter subplugin of Arm NN Inference Engine.
%endif
%if %{with protobuf_support}
%package protobuf
Summary: NNStreamer Protobuf Support
Requires: nnstreamer = %{version}-%{release}
%description protobuf
NNStreamer's tensor_converter and decoder subplugin of Protobuf.
%endif
%if %{with flatbuf_support}
%package flatbuf
Summary: NNStreamer Flatbuf Support
Requires: nnstreamer = %{version}-%{release}
%description flatbuf
NNStreamer's tensor_converter and decoder subplugin of flatbuf.
%endif
%if %{with pytorch_support}
%package pytorch
Summary: NNStreamer PyTorch Support
Requires: nnstreamer = %{version}-%{release}
%description pytorch
NNStreamer's tensor_fliter subplugin of pytorch
%endif
%if %{with caffe2_support}
%package caffe2
Summary: NNStreamer caffe2 Support
Requires: nnstreamer = %{version}-%{release}
%description caffe2
NNStreamer's tensor_fliter subplugin of caffe2
%endif
%package devel
Summary: Development package for custom tensor operator developers (tensor_filter/custom)
Requires: nnstreamer = %{version}-%{release}
Requires: glib2-devel
Requires: gstreamer-devel
%description devel
Development package for custom tensor operator developers (tensor_filter/custom).
This contains corresponding header files and .pc pkgconfig file.
%package devel-internal
Summary: Development package to access internal functions of NNStreamer
Requires: devel = %{version}-%{release}
%description devel-internal
Development package to access internal functions of NNStreamer.
This may be used by API packages.
In most cases, custom-filter or subplugin authors do not need this internal devel package; however, if they want to access more internal functions, they may need this.
%package devel-static
Summary: Static library for nnstreamer-devel package
Requires: devel = %{version}-%{release}
%description devel-static
Static library package of nnstreamer-devel.
%if %{with testcoverage}
%package unittest-coverage
Summary: NNStreamer UnitTest Coverage Analysis Result
%description unittest-coverage
HTML pages of lcov results of NNStreamer generated during rpmbuild
%endif
%package -n capi-nnstreamer
Summary: Tizen Native API for NNStreamer
Group: Multimedia/Framework
Requires: %{name} = %{version}-%{release}
Requires: %{name}-misc = %{version}-%{release}
%description -n capi-nnstreamer
Tizen Native API wrapper for NNStreamer.
You can construct a data stream pipeline with neural networks easily.
%post -n capi-nnstreamer -p /sbin/ldconfig
%postun -n capi-nnstreamer -p /sbin/ldconfig
%if %{with nnfw_support}
%package nnfw
Summary: NNStreamer nnfw runtime support
%description nnfw
NNStreamer's tensor_filter subplugin of NNFW Runtime
%endif
%package -n capi-nnstreamer-devel
Summary: Tizen Native API Devel Kit for NNStreamer
Group: Multimedia/Framework
Requires: capi-nnstreamer = %{version}-%{release}
Requires: capi-ml-common-devel
%description -n capi-nnstreamer-devel
Developmental kit for Tizen Native NNStreamer API.
%package -n capi-nnstreamer-devel-static
Summary: Static library for Tizen Native API
Group: Multimedia/Framework
Requires: capi-nnstreamer-devel = %{version}-%{release}
%description -n capi-nnstreamer-devel-static
Static library of capi-nnstreamer-devel package.
%package -n capi-ml-common-devel
Summary: Common headers for Tizen Machine Learning API set.
Group: Multimedia/Framework
%description -n capi-ml-common-devel
Common headers for Tizen Machine Learning API set.
%package -n nnstreamer-tizen-internal-capi-devel
Summary: Tizen internal API to construct the pipeline
Group: Multimedia/Framework
Requires: capi-nnstreamer-devel = %{version}-%{release}
%description -n nnstreamer-tizen-internal-capi-devel
Tizen internal API to construct the pipeline without the permissions.
%if %{with mvncsdk2_support}
%package ncsdk2
Summary: NNStreamer Intel Movidius NCSDK2 support
Group: Multimedia/Framework
%description ncsdk2
NNStreamer's tensor_fliter subplugin of Intel Movidius Neural Compute stick SDK2.
%endif
%if %{with openvino_support}
%package openvino
Summary: NNStreamer OpenVino support
Requires: nnstreamer = %{version}-%{release}
Requires: openvino
Group: Multimedia/Framework
%description openvino
NNStreamer's tensor_fliter subplugin for OpenVino support.
%endif
# Add Tizen's sensor framework API integration
%if %{with tizen_sensor_support}
%package tizen-sensor
Summary: NNStreamer integration of tizen sensor framework (tensor_src_tizensensor)
Requires: nnstreamer = %{version}-%{release}
Requires: capi-system-sensor
%description tizen-sensor
You can include Tizen sensor framework nodes as source elements of GStreamer/NNStreamer pipelines with this package.
%endif
%if %{with grpc_support}
%package grpc
Summary: NNStreamer gRPC support
Requires: nnstreamer = %{version}-%{release}
%if %{with tizen}
Recommends: nnstreamer-grpc-protobuf = %{version}-%{release}
Recommends: nnstreamer-grpc-flatbuf = %{version}-%{release}
%endif
%description grpc
NNStreamer's tensor_source/sink plugins for gRPC support.
%if %{with protobuf_support}
%package grpc-protobuf
Summary: NNStreamer gRPC/Protobuf support
Requires: nnstreamer-grpc = %{version}-%{release}
Requires: nnstreamer-protobuf = %{version}-%{release}
%description grpc-protobuf
NNStreamer's gRPC IDL support for protobuf
%endif
%if %{with flatbuf_support}
%package grpc-flatbuf
Summary: NNStreamer gRPC/Flatbuf support
Requires: nnstreamer-grpc = %{version}-%{release}
Requires: nnstreamer-flatbuf = %{version}-%{release}
%description grpc-flatbuf
NNStreamer's gRPC IDL support for flatbuf
%endif
%endif
%if %{with edgetpu_support}
%package edgetpu
Summary: NNStreamer plugin for Google-Coral Edge TPU
Requires: nnstreamer = %{version}-%{release}
%description edgetpu
You may enable this package to use Google Edge TPU with NNStreamer and Tizen ML APIs.
%endif
%if %{with release_test}
%package unittests
Summary: NNStreamer unittests for core, API and plugins
Requires: nnstreamer = %{version}-%{release}
%description unittests
Various unit test cases and custom subplugin examples for NNStreamer.
%endif
%package util
Summary: NNStreamer developer utilities
%description util
NNStreamer developer utilities include nnstreamer configuration checker.
%package misc
Summary: NNStreamer extra packages
%description misc
Provides additional gstreamer plugins for nnstreamer pipelines
## Define build options ##
%define enable_vivante -Denable-vivante=false
%define enable_tizen -Denable-tizen=false
%define enable_tizen_sensor -Denable-tizen-sensor=false
%define enable_api -Denable-capi=true
%define enable_mvncsdk2 -Dmvncsdk2-support=disabled
%define enable_openvino -Denable-openvino=false
%define enable_nnfw_runtime -Dnnfw-runtime-support=disabled
%define element_restriction -Denable-element-restriction=false
%define enable_tizen_privilege_check -Denable-tizen-privilege-check=true
%define enable_tizen_feature_check -Denable-tizen-feature-check=true
%define enable_test -Denable-test=true
%define install_test -Dinstall-test=false
%if %{with mvncsdk2_support}
%define enable_mvncsdk2 -Dmvncsdk2-support=enabled
%endif
%if %{with openvino_support}
%define enable_openvino -Denable-openvino=true
%endif
%if %{with nnfw_support}
%define enable_nnfw_runtime -Dnnfw-runtime-support=enabled
%endif # nnfw_support
%if %{with tizen_sensor_support}
%define enable_tizen_sensor -Denable-tizen-sensor=true
%endif
%if !%{with check_test}
%define enable_test -Denable-test=false
%endif
%if %{with release_test}
%define install_test -Dinstall-test=true
%endif
%if !%{with enable_tizen_privilege}
%define enable_tizen_privilege_check -Denable-tizen-privilege-check=false
%endif
%if !%{with enable_tizen_feature}
%define enable_tizen_feature_check -Denable-tizen-feature-check=false
%endif
%if %{with tizen}
%define enable_tizen -Denable-tizen=true -Dtizen-version-major=%{with tizen_version_major}
%define enable_api -Denable-capi=true
# Element restriction in Tizen
%define restricted_element 'capsfilter input-selector output-selector queue tee valve appsink appsrc audioconvert audiorate audioresample audiomixer videoconvert videocrop videorate videoscale videoflip videomixer compositor fakesrc fakesink filesrc filesink audiotestsrc videotestsrc jpegparse jpegenc jpegdec pngenc pngdec tcpclientsink tcpclientsrc tcpserversink tcpserversrc udpsink udpsrc xvimagesink ximagesink evasimagesink evaspixmapsink glimagesink theoraenc lame vorbisenc wavenc volume oggmux avimux matroskamux v4l2src avsysvideosrc camerasrc tvcamerasrc pulsesrc fimcconvert tizenwlsink gdppay gdpdepay join'
%define element_restriction -Denable-element-restriction=true -Drestricted-elements=%{restricted_element}
%endif #if tizen
# Support tensorflow
%if %{with tensorflow_support} || %{with tensorflow2_support}
%define enable_tf -Dtf-support=enabled
%else
%define enable_tf -Dtf-support=disabled
%endif
# Support tensorflow-lite
%if %{with tensorflow_lite_support}
%define enable_tf_lite -Dtflite-support=enabled
%else
%define enable_tf_lite -Dtflite-support=disabled
%endif
# Support tensorflow2-lite
%if %{with tensorflow2_lite_support}
%define enable_tf2_lite -Dtflite2-support=enabled -Dtflite2-gpu-delegate-support=false
%else
%define enable_tf2_lite -Dtflite2-support=disabled
%endif
# Support pytorch
%if %{with pytorch_support}
%define enable_pytorch -Dpytorch-support=enabled
%else
%define enable_pytorch -Dpytorch-support=disabled
%endif
# Support caffe2
%if %{with caffe2_support}
%define enable_caffe2 -Dcaffe2-support=enabled
%else
%define enable_caffe2 -Dcaffe2-support=disabled
%endif
# Support ArmNN
%if %{with armnn_support}
%define enable_armnn -Darmnn-support=enabled
%else
%define enable_armnn -Darmnn-support=disabled
%endif
# Support python
%if %{with python3_support}
%define enable_python3 -Dpython3-support=enabled
%else
%define enable_python3 -Dpython3-support=disabled
%endif
# Support edgetpu
%if %{with edgetpu_support}
%define enable_edgetpu -Denable-edgetpu=true
%else
%define enable_edgetpu -Denable-edgetpu=false
%endif
# Support flatbuffer
%if %{with flatbuf_support}
%define enable_flatbuf -Dflatbuf-support=enabled
%else
%define enable_flatbuf -Dflatbuf-support=disabled
%endif
%prep
rm -rf ./build
%setup -q
%autopatch -p1
%build
%if %{with testcoverage}
# To test coverage, disable optimizations (and should unset _FORTIFY_SOURCE to use -O0)
CFLAGS=`echo $CFLAGS | sed -e "s|-O[1-9]|-O0|g"`
CFLAGS=`echo $CFLAGS | sed -e "s|-Wp,-D_FORTIFY_SOURCE=[1-9]||g"`
CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-O[1-9]|-O0|g"`
CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-Wp,-D_FORTIFY_SOURCE=[1-9]||g"`
# also, use the meson's base option, -Db_coverage, instead of --coverage/-fprofile-arcs and -ftest-coverage
%define enable_test_coverage -Db_coverage=true
%else
%define enable_test_coverage -Db_coverage=false
%endif
mkdir -p build
meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir=%{_libdir} \
--bindir=%{nnstbindir} --includedir=%{_includedir} \
%{enable_api} %{enable_tizen} %{element_restriction} -Denable-env-var=false -Denable-symbolic-link=false \
%{enable_tf_lite} %{enable_tf2_lite} %{enable_tf} %{enable_pytorch} %{enable_caffe2} %{enable_python3} \
%{enable_nnfw_runtime} %{enable_mvncsdk2} %{enable_openvino} %{enable_armnn} %{enable_edgetpu} %{enable_vivante} %{enable_flatbuf} \
%{enable_tizen_privilege_check} %{enable_tizen_feature_check} %{enable_tizen_sensor} %{enable_test} %{enable_test_coverage} %{install_test} \
build
ninja -C build %{?_smp_mflags}
%install
DESTDIR=%{buildroot} ninja -C build %{?_smp_mflags} install
pushd %{buildroot}%{_libdir}
ln -sf %{gstlibdir}/libnnstreamer.so libnnstreamer.so
popd
mkdir -p %{buildroot}%{_bindir}
pushd %{buildroot}%{_bindir}
ln -sf %{nnstbindir}/nnstreamer-check nnstreamer-check
popd
%if %{with python3_support}
mkdir -p %{buildroot}%{python3_sitelib}
pushd %{buildroot}%{python3_sitelib}
ln -sf %{_prefix}/lib/nnstreamer/extra/nnstreamer_python3.so nnstreamer_python.so
popd
%endif
# Drop static libs
rm -f %{buildroot}%{_libdir}/*.a
%check
export NNSTREAMER_SOURCE_ROOT_PATH=$(pwd)
export NNSTREAMER_BUILD_ROOT_PATH=$(pwd)/build
export GST_PLUGIN_PATH=${NNSTREAMER_BUILD_ROOT_PATH}/gst:${NNSTREAMER_BUILD_ROOT_PATH}/ext
export NNSTREAMER_CONF=${NNSTREAMER_BUILD_ROOT_PATH}/nnstreamer-test.ini
export NNSTREAMER_FILTERS=${NNSTREAMER_BUILD_ROOT_PATH}/ext/nnstreamer/tensor_filter
export NNSTREAMER_DECODERS=${NNSTREAMER_BUILD_ROOT_PATH}/ext/nnstreamer/tensor_decoder
export NNSTREAMER_CONVERTERS=${NNSTREAMER_BUILD_ROOT_PATH}/ext/nnstreamer/tensor_converter
%define test_script $(pwd)/packaging/run_unittests_binaries.sh
%if %{with tizen}
bash %{test_script} ./tests/tizen_nnfw_runtime/unittest_nnfw_runtime_raw
bash %{test_script} ./tests/tizen_nnfw_runtime/unittest_nnfw_runtime_api
bash %{test_script} ./tests/tizen_capi/unittest_tizen_sensor
%endif #if tizen
%if %{with unit_test}
bash %{test_script} ./tests
bash %{test_script} ./tests/tizen_capi/unittest_tizen_capi
bash %{test_script} ./tests/cpp_methods
bash %{test_script} ./tests/nnstreamer_filter_extensions_common
LD_LIBRARY_PATH=${NNSTREAMER_BUILD_ROOT_PATH}/tests/nnstreamer_filter_mvncsdk2:. bash %{test_script} ./tests/nnstreamer_filter_mvncsdk2/unittest_filter_mvncsdk2
%ifarch aarch64 x86_64
LD_LIBRARY_PATH=${NNSTREAMER_BUILD_ROOT_PATH}/tests/nnstreamer_filter_edgetpu:. bash %{test_script} ./tests/nnstreamer_filter_edgetpu/unittest_edgetpu
%endif #ifarch 64
pushd tests
ssat -n -p=1 --summary summary.txt -cn _n
popd
python3 tools/development/count_test_cases.py build test/summary.txt
%endif #if unit_test
%if %{with testcoverage}
##
# The included directories are:
#
# api: nnstreamer api
# gst: the nnstreamer elements
# nnstreamer_example: custom plugin examples
# common: common libraries for gst (elements)
# include: common library headers and headers for external code (packaged as "devel")
#
# Intentionally excluded directories are:
#
# tests: We are not going to show testcoverage of the test code itself or example applications
%if %{with tizen}
%define testtarget $(pwd)/api/capi
%else
%define testtarget
%endif
# 'lcov' generates the date format with UTC time zone by default. Let's replace UTC with KST.
# If you ccan get a root privilege, run ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
TZ='Asia/Seoul'; export TZ
# Get commit info
VCS=`cat ${RPM_SOURCE_DIR}/nnstreamer.spec | grep "^VCS:" | sed "s|VCS:\\W*\\(.*\\)|\\1|"`
# Create human readable unit test coverage report web page.
# Create null gcda files if gcov didn't create it because there is completely no unit test for them.
find . -name "*.gcno" -exec sh -c 'touch -a "${1%.gcno}.gcda"' _ {} \;
# Remove gcda for meaningless file (CMake's autogenerated)
find . -name "CMakeCCompilerId*.gcda" -delete
find . -name "CMakeCXXCompilerId*.gcda" -delete
#find . -path "/build/*.j
# Generate report
lcov -t 'NNStreamer Unit Test Coverage' -o unittest.info -c -d . -b $(pwd) --no-external
# Exclude generated files (e.g., Orc, Protobuf) and device-dependent filters.
lcov -r unittest.info "*/*-orc.*" "*/tests/*" "*/meson*/*" "*/*@sha/*" "*/*_openvino*" "*/*_edgetpu*" "*/*_movidius_ncsdk2*" "*/*.so.p/*" -o unittest-filtered.info
# Visualize the report
genhtml -o result unittest-filtered.info -t "nnstreamer %{version}-%{release} ${VCS}" --ignore-errors source -p ${RPM_BUILD_DIR}
mkdir -p %{buildroot}%{_datadir}/nnstreamer/unittest/
cp -r result %{buildroot}%{_datadir}/nnstreamer/unittest/
%endif # test coverage
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%license LICENSE
%dir %{_prefix}/lib/nnstreamer
%dir %{_prefix}/lib/nnstreamer/converters
%dir %{_prefix}/lib/nnstreamer/decoders
%dir %{_prefix}/lib/nnstreamer/filters
%dir %{_prefix}/lib/nnstreamer/extra
%{_prefix}/lib/nnstreamer/decoders/libnnstreamer_decoder_bounding_boxes.so
%{_prefix}/lib/nnstreamer/decoders/libnnstreamer_decoder_pose_estimation.so
%{_prefix}/lib/nnstreamer/decoders/libnnstreamer_decoder_image_segment.so
%{_prefix}/lib/nnstreamer/decoders/libnnstreamer_decoder_image_labeling.so
%{_prefix}/lib/nnstreamer/decoders/libnnstreamer_decoder_direct_video.so
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_cpp.so
%{gstlibdir}/libnnstreamer.so
%{_libdir}/libnnstreamer.so
%{_sysconfdir}/nnstreamer.ini
# for tensorflow
%if %{with tensorflow_support}
%files tensorflow
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_tensorflow.so
%endif
%if %{with tensorflow_lite_support}
%files tensorflow-lite
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_tensorflow1-lite.so
%endif
%if %{with tensorflow2_support}
%files tensorflow2
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_tensorflow.so
%endif
# for tensorflow2-lite
%if %{with tensorflow2_lite_support}
%files tensorflow2-lite
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_tensorflow2-lite.so
%endif
%if %{with python3_support}
%files python3
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_python3.so
%{_prefix}/lib/nnstreamer/extra/nnstreamer_python3.so
%{python3_sitelib}/nnstreamer_python.so
%{_prefix}/lib/nnstreamer/converters/libnnstreamer_converter_python3.so
%{_prefix}/lib/nnstreamer/decoders/libnnstreamer_decoder_python3.so
%endif
%if %{with protobuf_support}
%files protobuf
%defattr(-,root,root,-)
%{_libdir}/libnnstreamer_protobuf.so
%{_prefix}/lib/nnstreamer/decoders/libnnstreamer_decoder_protobuf.so
%{_prefix}/lib/nnstreamer/converters/libnnstreamer_converter_protobuf.so
%endif
%if %{with flatbuf_support}
%files flatbuf
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/decoders/libnnstreamer_decoder_flatbuf.so
%{_prefix}/lib/nnstreamer/converters/libnnstreamer_converter_flatbuf.so
%endif
# for pytorch
%if %{with pytorch_support}
%files pytorch
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_pytorch.so
%endif
# for caffe2
%if %{with caffe2_support}
%files caffe2
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_caffe2.so
%endif
%files devel
%dir %{_includedir}/nnstreamer
%{_includedir}/nnstreamer/*.h*
%{_libdir}/pkgconfig/nnstreamer.pc
%{_libdir}/pkgconfig/nnstreamer-cpp.pc
%{_libdir}/pkgconfig/nnstreamer-internal.pc
#%%files devel-internal
#%%{_includedir}/nnstreamer/nnstreamer_internal.h
#%%{_includedir}/nnstreamer/nnstreamer_log.h
#%%{_includedir}/nnstreamer/tensor_filter_single.h
#%%files devel-static
#%%{_libdir}/*.a
#%%exclude %{_libdir}/libcapi*.a
%if %{with testcoverage}
%files unittest-coverage
%{_datadir}/nnstreamer/unittest/*
%endif
%if %{with nnfw_support}
%files nnfw
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_nnfw.so
%endif
%if %{with armnn_support}
%files armnn
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_armnn.so
%endif
%if %{with mvncsdk2_support}
%files -n nnstreamer-ncsdk2
%defattr(-,root,root,-)
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_movidius-ncsdk2.so
%endif # mvncsdk2_support
%if %{with tizen_sensor_support}
%files tizen-sensor
%{gstlibdir}/libnnstreamer-tizen-sensor.so
%endif # tizen_sensor_support
%if %{with grpc_support}
%files grpc
%defattr(-,root,root,-)
%license LICENSE
%{gstlibdir}/libnnstreamer-grpc.so
%if %{with protobuf_support}
%files grpc-protobuf
%defattr(-,root,root,-)
%license LICENSE
%{_libdir}/libnnstreamer_grpc_protobuf.so
%endif
%if %{with flatbuf_support}
%files grpc-flatbuf
%defattr(-,root,root,-)
%license LICENSE
%{_libdir}/libnnstreamer_grpc_flatbuf.so
%endif
%endif # grpc_support
%if %{with edgetpu_support}
%files edgetpu
%license LICENSE
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_edgetpu.so
%endif
%if %{with release_test}
%files unittests
%{_libdir}/libnnstreamer_unittest_util.so
%dir %{_prefix}/lib/nnstreamer/customfilters
%{_prefix}/lib/nnstreamer/customfilters/*.so
%{_prefix}/lib/nnstreamer/unittest
%endif
%if %{with openvino_support}
%files openvino
%license LICENSE
%{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_openvino.so
%endif
%files util
%{_bindir}/nnstreamer-check
%dir %{nnstbindir}
%{nnstbindir}/*
%files misc
%{gstlibdir}/libgstjoin.so
%changelog