build: fix building without tests support

This commit is contained in:
Aleksander Morgado
2022-10-27 21:41:59 +00:00
parent 30d77d378a
commit 7ea2452b1e
3 changed files with 46 additions and 34 deletions

View File

@@ -124,4 +124,6 @@ libmm_generated_dep = declare_dependency(
link_whole: libmm_generated, link_whole: libmm_generated,
) )
if enable_tests
subdir('tests') subdir('tests')
endif

View File

@@ -5,6 +5,8 @@ symbol_map = plugins_dir / 'symbol.map'
ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map)) ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map))
# common service test support # common service test support
plugins_common_test_dep = []
if enable_tests
sources = files( sources = files(
'tests/test-fixture.c', 'tests/test-fixture.c',
'tests/test-helpers.c', 'tests/test-helpers.c',
@@ -13,7 +15,7 @@ sources = files(
deps = [ deps = [
libhelpers_dep, libhelpers_dep,
libmm_test_generated_dep, libmm_test_generated_dep
] ]
libmm_test_common = shared_library( libmm_test_common = shared_library(
@@ -30,6 +32,9 @@ libmm_test_common_dep = declare_dependency(
link_with: libmm_test_common, link_with: libmm_test_common,
) )
plugins_common_test_dep += [ libmm_test_common_dep ]
endif
# plugins # plugins
plugins = {} plugins = {}
plugins_data = [] plugins_data = []
@@ -205,7 +210,7 @@ if plugins_shared['telit']
'plugin': false, 'plugin': false,
'helper': {'sources': files('telit/mm-modem-helpers-telit.c'), 'include_directories': plugins_incs, 'c_args': common_c_args}, 'helper': {'sources': files('telit/mm-modem-helpers-telit.c'), 'include_directories': plugins_incs, 'c_args': common_c_args},
'module': {'sources': sources + daemon_enums_sources, 'include_directories': plugins_incs + [telit_inc], 'c_args': common_c_args}, 'module': {'sources': sources + daemon_enums_sources, 'include_directories': plugins_incs + [telit_inc], 'c_args': common_c_args},
'test': {'sources': files('telit/tests/test-mm-modem-helpers-telit.c'), 'include_directories': telit_inc, 'dependencies': libmm_test_common_dep}, 'test': {'sources': files('telit/tests/test-mm-modem-helpers-telit.c'), 'include_directories': telit_inc, 'dependencies': plugins_common_test_dep},
}} }}
endif endif
@@ -400,7 +405,7 @@ if plugins_options['generic']
plugins += {'plugin-generic': { plugins += {'plugin-generic': {
'plugin': true, 'plugin': true,
'module': {'sources': files('generic/mm-plugin-generic.c'), 'include_directories': plugins_incs, 'c_args': '-DMM_MODULE_NAME="generic"'}, 'module': {'sources': files('generic/mm-plugin-generic.c'), 'include_directories': plugins_incs, 'c_args': '-DMM_MODULE_NAME="generic"'},
'test': {'sources': files('generic/tests/test-service-generic.c'), 'include_directories': include_directories('generic'), 'dependencies': libmm_test_common_dep, 'c_args': '-DCOMMON_GSM_PORT_CONF="@0@"'.format(plugins_dir / 'tests/gsm-port.conf')}, 'test': {'sources': files('generic/tests/test-service-generic.c'), 'include_directories': include_directories('generic'), 'dependencies': plugins_common_test_dep, 'c_args': '-DCOMMON_GSM_PORT_CONF="@0@"'.format(plugins_dir / 'tests/gsm-port.conf')},
}} }}
endif endif
@@ -881,7 +886,7 @@ if plugins_options['ublox']
'plugin': true, 'plugin': true,
'helper': {'sources': files('ublox/mm-modem-helpers-ublox.c'), 'include_directories': plugins_incs, 'c_args': common_c_args}, 'helper': {'sources': files('ublox/mm-modem-helpers-ublox.c'), 'include_directories': plugins_incs, 'c_args': common_c_args},
'module': {'sources': sources + daemon_enums_sources, 'include_directories': plugins_incs + [ublox_inc], 'c_args': common_c_args}, 'module': {'sources': sources + daemon_enums_sources, 'include_directories': plugins_incs + [ublox_inc], 'c_args': common_c_args},
'test': {'sources': files('ublox/tests/test-modem-helpers-ublox.c'), 'include_directories': ublox_inc, 'dependencies': libmm_test_common_dep}, 'test': {'sources': files('ublox/tests/test-modem-helpers-ublox.c'), 'include_directories': ublox_inc, 'dependencies': plugins_common_test_dep},
}} }}
plugins_udev_rules += files('ublox/77-mm-ublox-port-types.rules') plugins_udev_rules += files('ublox/77-mm-ublox-port-types.rules')
@@ -978,6 +983,7 @@ foreach plugin_name, plugin_data: plugins
install_dir: mm_pkglibdir, install_dir: mm_pkglibdir,
) )
if enable_tests
if plugin_data.has_key('test') if plugin_data.has_key('test')
test_unit = 'test-' + plugin_name test_unit = 'test-' + plugin_name
@@ -989,6 +995,7 @@ foreach plugin_name, plugin_data: plugins
test(test_unit, exe) test(test_unit, exe)
endif endif
endif
endforeach endforeach
install_data( install_data(

View File

@@ -247,11 +247,14 @@ daemon_enums_sources += gnome.mkenums(
deps = [ deps = [
gmodule_dep, gmodule_dep,
libmm_test_generated_dep,
libport_dep, libport_dep,
libqcdm_dep, libqcdm_dep,
] ]
if enable_tests
deps += [libmm_test_generated_dep]
endif
c_args = [ c_args = [
'-DMM_COMPILATION', '-DMM_COMPILATION',
'-DPLUGINDIR="@0@"'.format(mm_prefix / mm_pkglibdir), '-DPLUGINDIR="@0@"'.format(mm_prefix / mm_pkglibdir),