# Default features for Tizen release
# If you want to build RPM for other Linux distro, you may need to
# touch these values for your needs.
-%bcond_with tizen
-# Below features are used for unittest.
-# Do not add neural network dependency to ML-Agent.
-%define release_test 0
+# Create an option to build without tizen (`--without tizen`), thus default
+# building with it
+# https://rpm-software-management.github.io/rpm/manual/conditionalbuilds.html
+%bcond_without tizen
-# To generage gcov package, --define "gcov 1"
-%if 0%{?gcov:1}
-%define unit_test 1
-%define release_test 1
-%define testcoverage 1
-%endif
###########################################################################
-# Disable a few features for TV release
-%if "%{?profile}" == "tv"
-%endif
-
-# Disable a few features for DA release
-%if 0%{?_with_da_profile}
-%endif
+# Macros for building and testing option control
+%define builddir build
+%define source_root %{_builddir}/%{?buildsubdir}
+%define test_script %{source_root}/packaging/run_unittests.sh
+%define test_base_dir %{_bindir}/ml-agent-test
# Note that debug packages generate an additional build and storage cost.
# If you do not need debug packages, run '$ gbs build ... --define "_skip_debug_rpm 1"'.
%global debug_package %{nil}
%global __debug_install_post %{nil}
%endif
+
###########################################################################
-# Macros for building and testing option control
-%define builddir build
-%define source_root %{_builddir}/%{?buildsubdir}
-%define test_script %{source_root}/packaging/run_unittests.sh
+# Define build options
+
+# Below features are used for unittest.
+# Do not add neural network dependency to ML-Agent.
+%define enable_test -Denable-test=false
+%define install_test -Dinstall-test=false
+
+# To generage gcov package, --define "gcov 1"
+%if 0%{?gcov:1}
+%define unit_test 1
+%define release_test 1
+%define testcoverage 1
+%endif
+
+# To set prefix, use this line
+### define service_db_key_prefix -Dservice-db-key-prefix='some-prefix'
+%define service_db_key_prefix %{nil}
###########################################################################
# Package / sub-package definitions
Source0: machine-learning-agent-%{version}.tar
Source1001: machine-learning-agent.manifest
-## Define build requirements ##
+## Define runtime requirements ##
Requires: libmachine-learning-agent = %{version}-%{release}
+Requires: dbus-1
+## Define build requirements ##
BuildRequires: meson >= 0.50.0
-BuildRequires: glib2-devel
-BuildRequires: gstreamer-devel
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gstreamer-1.0)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(json-glib-1.0)
-BuildRequires: dbus
%if %{with tizen}
BuildRequires: pkgconfig(dlog)
# For test
%if 0%{?unit_test}
+# g_test_dbus_up requires dbus
+BuildRequires: dbus-1
BuildRequires: pkgconfig(gtest)
%if 0%{?testcoverage}
%description -n libmachine-learning-agent-devel
Development headers and static library for interfaces provided by Machine Learning Agent.
+%package test
+Summary: ML service agent for testing purposes
+Requires: dbus
+%description test
+ML agent binary for the testing purposes
+This package provides the ML agent (daemon) to the other packages that
+require testing with the ML Agent service.
+
%if 0%{?unit_test}
%if 0%{?release_test}
%package unittests
HTML pages of lcov results of Machine Learning Agent generated during rpm build.
%endif
%endif # unit_test
-###########################################################################
-# Define build options
-%define enable_tizen -Denable-tizen=false
-%define service_db_path ""
-%define service_db_key_prefix %{nil}
-
-# To set prefix, use this line
-### define service_db_key_prefix -Dservice-db-key-prefix='some-prefix'
-
-%if %{with tizen}
-%define enable_tizen -Denable-tizen=true
-%define service_db_path -Dservice-db-path=%{TZ_SYS_GLOBALUSER_DB}
-%endif # tizen
%prep
%setup -q
%if 0%{?release_test}
%define install_test -Dinstall-test=true
-%else
-%define install_test -Dinstall-test=false
-%endif
+%endif # release_test
%if 0%{?testcoverage}
# To test coverage, disable optimizations (and should unset _FORTIFY_SOURCE to use -O0)
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
-
-%else # unit_test
-%define enable_test -Denable-test=false
-%define install_test -Dinstall-test=false
-%define enable_test_coverage -Db_coverage=false
+%endif # testcoverage
%endif # unit_test
rm -rf %{builddir}
meson setup --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir=%{_libdir} \
--bindir=%{_bindir} --includedir=%{_includedir} \
- %{enable_test} %{install_test} %{enable_test_coverage} \
- %{enable_tizen} %{service_db_path} %{service_db_key_prefix} \
+ %{enable_test} %{install_test} %{?testcoverage:-Db_coverage=true} \
+ %{?with_tizen:-Denable-tizen=true} \
+ -Dservice-db-path=%{?with_tizen:%{TZ_SYS_GLOBALUSER_DB}}%{!?with_tizen:%{expand:%{?service_db_path}}%{?!service_db_path:.}} \
+ %{service_db_key_prefix} \
%{builddir}
meson compile -C %{builddir} %{?_smp_mflags}
%{_includedir}/ml-agent/ml-agent-interface.h
%{_libdir}/pkgconfig/ml-agent.pc
+%files test
+%manifest machine-learning-agent.manifest
+%license LICENSE
+%attr(0755,root,root) %{test_base_dir}/machine-learning-agent-test
+%attr(0755,root,root) %{test_base_dir}/services/org.tizen.machinelearning.service.service
+%{_libdir}/libml-agent-test.*
+
%if 0%{?unit_test}
%if 0%{?release_test}
%files unittests
%manifest machine-learning-agent.manifest
-%{_bindir}/unittest-ml
+%{test_base_dir}/unittests
%{_libdir}/libml-agent-test.a
%{_libdir}/libml-agent-test.so*
%if 0%{?gcov:1}
%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
-%endif
+%endif # gcov
%endif # release_test
%if 0%{?gcov:1}
%files gcov
%{_datadir}/gcov/obj/*
-%endif
+%endif # gcov
%if 0%{?testcoverage}
%files unittest-coverage
%{_datadir}/ml-agent/unittest/*
-%endif
-%endif #unit_test
+%endif # testcoverage
+%endif # unit_test
%changelog
* Mon Dec 11 2023 Sangjung Woo <sangjung.woo@samsung.com>
# Install path for unittest
-unittest_base_dir = join_paths(ml_agent_install_bindir, 'unittest-ml')
-unittest_install_dir = join_paths(unittest_base_dir,'tests')
-
-# Set dependency and test-env
-testenv = environment()
-testenv.set('MLAGENT_SOURCE_ROOT_PATH', meson.source_root())
-testenv.set('MLAGENT_BUILD_ROOT_PATH', meson.build_root())
+test_base_dir = join_paths(ml_agent_install_bindir, 'ml-agent-test')
+unittest_install_dir = join_paths(test_base_dir, 'unittests')
ml_agent_lib_objs = ml_agent_lib.extract_objects(ml_agent_lib_srcs)
ml_agent_test_both_lib = both_libraries('ml-agent-test',
dependencies: ml_agent_deps,
include_directories: ml_agent_incs,
- install: get_option('install-test'),
+ install: true,
install_dir: ml_agent_install_libdir,
cpp_args: ['-DDB_PATH="."', ml_agent_db_key_prefix_arg],
objects: ml_agent_lib_objs,
ml_agent_main_objs = ml_agent_executable.extract_objects(ml_agent_main_file)
executable('machine-learning-agent-test',
dependencies: ml_agent_test_dep,
- install: get_option('install-test'),
- install_dir: unittest_base_dir,
+ install: true,
+ install_dir: test_base_dir,
c_args: ['-DDB_PATH="."', ml_agent_db_key_prefix_arg],
objects: ml_agent_main_objs
)
subdir('services')
-subdir('daemon')
+# Run tests
+if get_option('enable-test')
+ gtest_dep = dependency('gtest', required: false)
+ if gtest_dep.found()
+ subdir('daemon')
+ else
+ warning('The enable-test option requires google-test.')
+ endif
+endif
configuration: builddir_cdata
)
-if get_option('install-test')
- installed_builddir_cdata = configuration_data()
- installed_builddir_cdata.set('build_dir', unittest_base_dir)
+installed_builddir_cdata = configuration_data()
+installed_builddir_cdata.set('build_dir', test_base_dir)
- test_service_file = configure_file(
- input: test_dbus_service_file + '.in',
- output: test_dbus_service_file + '.install',
- configuration: installed_builddir_cdata
- )
+test_service_file = configure_file(
+ input: test_dbus_service_file + '.in',
+ output: test_dbus_service_file + '.install',
+ configuration: installed_builddir_cdata
+)
- install_data(
- test_service_file,
- install_dir: join_paths(unittest_install_dir, 'services'),
- install_mode: 'rw-r--r--',
- rename: test_dbus_service_file
- )
-endif
+install_data(
+ test_service_file,
+ install_dir: join_paths(test_base_dir, 'services'),
+ install_mode: 'rw-r--r--',
+ rename: test_dbus_service_file
+)