aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Van Assche <me@dylanvanassche.be>2022-07-25 09:18:29 +0200
committerDylan Van Assche <me@dylanvanassche.be>2022-07-25 11:01:51 +0200
commitba96ccc61587b7b6c31b94826ee7a3c44d795364 (patch)
tree6924ba6a4cd89c8500a9e7826074df5b23616b65
parent041f53af8b138fda6242ad1381fd3cd1c2ff6c81 (diff)
build: make tests optional
Add a meson option -Dtests and --without-tests automake option to disable the compilation of all available testcases. This is useful for compiling projects with Flatpak such as GNOME Control Center which disables all possible integrations since they only need the DBus part of ModemManager. Contributes to https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/1392
-rw-r--r--Makefile.am5
-rw-r--r--configure.ac17
-rw-r--r--data/Makefile.am9
-rw-r--r--data/meson.build4
-rw-r--r--introspection/meson.build4
-rw-r--r--libmm-glib/meson.build4
-rw-r--r--meson.build18
-rw-r--r--meson_options.txt2
-rw-r--r--src/meson.build4
9 files changed, 57 insertions, 10 deletions
diff --git a/Makefile.am b/Makefile.am
index 4dd7ad63..4263061c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,12 +12,15 @@ SUBDIRS = \
cli \
vapi \
introspection \
- test \
tools \
examples \
docs \
$(NULL)
+if WITH_TESTS
+SUBDIRS += test
+endif
+
ChangeLog:
$(AM_V_GEN) if test -d "$(srcdir)/.git"; then \
(GIT_DIR=$(top_srcdir)/.git $(top_srcdir)/missing --run git log --stat) | fmt --split-only > $@.tmp \
diff --git a/configure.ac b/configure.ac
index d4580a31..bb8a75fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,6 +252,21 @@ case $with_udev in
esac
dnl-----------------------------------------------------------------------------
+dnl build with tests (enabled by default)
+dnl
+
+AC_ARG_WITH(tests, AS_HELP_STRING([--without-tests], [Build without testcases]), [], [with_tests=yes])
+AM_CONDITIONAL(WITH_TESTS, test "x$with_tests" = "xyes")
+case $with_tests in
+ yes)
+ AC_DEFINE(WITH_TESTS, 1, [Define if you want to build all testcases])
+ ;;
+ *)
+ with_tests=no
+ ;;
+esac
+
+dnl-----------------------------------------------------------------------------
dnl Suspend/resume support
dnl
@@ -629,6 +644,7 @@ examples/sms-python/Makefile
examples/network-scan-python/Makefile
examples/sms-c/Makefile
])
+
AC_OUTPUT
echo "
@@ -643,6 +659,7 @@ echo "
warn ldflags: ${WARN_LDFLAGS}
maintainer mode: ${USE_MAINTAINER_MODE}
release: ${ax_is_release}
+ tests: ${with_tests}
System paths:
prefix: ${prefix}
diff --git a/data/Makefile.am b/data/Makefile.am
index 12330e27..640d2b24 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,12 @@
-SUBDIRS = . dispatcher-connection dispatcher-fcc-unlock tests
+SUBDIRS = \
+ . \
+ dispatcher-connection \
+ dispatcher-fcc-unlock
+
+if WITH_TESTS
+SUBDIRS += tests
+endif
edit = @sed \
-e 's|@sbindir[@]|$(sbindir)|g' \
diff --git a/data/meson.build b/data/meson.build
index d2a36b7e..7063d00e 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,7 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2021 IƱigo Martinez <inigomartinez@gmail.com>
-subdir('tests')
+if enable_tests
+ subdir('tests')
+endif
service_conf = {
'sbindir': mm_prefix / mm_sbindir,
diff --git a/introspection/meson.build b/introspection/meson.build
index b1da7ee5..6f45c185 100644
--- a/introspection/meson.build
+++ b/introspection/meson.build
@@ -3,7 +3,9 @@
# DBus Introspection files
mm_ifaces_all = files('all.xml')
-mm_ifaces_test = files('tests/org.freedesktop.ModemManager1.Test.xml')
+if enable_tests
+ mm_ifaces_test = files('tests/org.freedesktop.ModemManager1.Test.xml')
+endif
mm_ifaces = files('org.freedesktop.ModemManager1.xml')
diff --git a/libmm-glib/meson.build b/libmm-glib/meson.build
index 64518439..42f8ac61 100644
--- a/libmm-glib/meson.build
+++ b/libmm-glib/meson.build
@@ -196,4 +196,6 @@ if enable_gir
endif
endif
-subdir('tests')
+if enable_tests
+ subdir('tests')
+endif
diff --git a/meson.build b/meson.build
index f656d357..0f6ae409 100644
--- a/meson.build
+++ b/meson.build
@@ -88,6 +88,9 @@ cc_args = cc.get_supported_arguments([
'-Wno-missing-field-initializers',
])
+# tests are enabled by default
+enable_tests = get_option('tests')
+
# strict flags to use in debug builds
if get_option('buildtype').contains('debug')
cc_args += cc.get_supported_arguments([
@@ -266,7 +269,9 @@ if dist_version != ''
config_h.set('MM_DIST_VERSION', dist_version)
endif
-util_dep = cc.find_library('util')
+if enable_tests
+ util_dep = cc.find_library('util')
+endif
# introspection support
enable_gir = get_option('introspection')
@@ -376,14 +381,19 @@ subdir('introspection')
subdir('include')
subdir('libqcdm/src')
-subdir('libqcdm/tests')
+if enable_tests
+ subdir('libqcdm/tests')
+endif
subdir('libmm-glib')
subdir('src')
subdir('plugins')
subdir('cli')
-subdir('test')
-subdir('tools/tests')
+
+if enable_tests
+ subdir('test')
+ subdir('tools/tests')
+endif
subdir('examples/sms-c')
diff --git a/meson_options.txt b/meson_options.txt
index fa8d209e..da105e1d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,6 +4,8 @@
option('udev', type: 'boolean', value: true, description: 'enable udev support')
option('udevdir', type: 'string', value: '', description: 'udev base directory')
+option('tests', type: 'boolean', value: true, description: 'enable tests')
+
option('dbus_policy_dir', type: 'string', value: '', description: 'd-bus system policy directory')
option('systemdsystemunitdir', type: 'string', value: '', description: 'systemd system units directory')
diff --git a/src/meson.build b/src/meson.build
index 2d1faed7..fdcfdebd 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -329,4 +329,6 @@ install_data(
install_dir: udev_rulesdir,
)
-subdir('tests')
+if enable_tests
+ subdir('tests')
+endif