summaryrefslogtreecommitdiff
path: root/test/use-as-subproject
diff options
context:
space:
mode:
authorDaniel Wagner <dwagner@suse.de>2023-01-13 13:29:06 +0100
committerDaniel Wagner <dwagner@suse.de>2023-02-07 09:07:32 +0100
commitb1e8793e8d950c2bcc09ed708b474d412cad8cb5 (patch)
tree404e29497f53c6656c8025cb51e85d353bf498d8 /test/use-as-subproject
parentcd1a9bb09a4e9330f8669fb6d385b1e095f97fc2 (diff)
downloaddbus-b1e8793e8d950c2bcc09ed708b474d412cad8cb5.tar.gz
gitlab-ci: build libdbus as subproject
Test it's possible to consume libdbus as a subproject. Suggested-by: Simon McVittie <smcv@collabora.com> Signed-off-by: Daniel Wagner <dwagner@suse.de>
Diffstat (limited to 'test/use-as-subproject')
-rw-r--r--test/use-as-subproject/.gitignore5
-rw-r--r--test/use-as-subproject/config.h6
-rw-r--r--test/use-as-subproject/dummy-config.h.in6
-rw-r--r--test/use-as-subproject/meson.build38
-rw-r--r--test/use-as-subproject/use-libdbus.c17
5 files changed, 72 insertions, 0 deletions
diff --git a/test/use-as-subproject/.gitignore b/test/use-as-subproject/.gitignore
new file mode 100644
index 00000000..2c32b030
--- /dev/null
+++ b/test/use-as-subproject/.gitignore
@@ -0,0 +1,5 @@
+# Copyright 2023 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+/_build/
+/subproject/
diff --git a/test/use-as-subproject/config.h b/test/use-as-subproject/config.h
new file mode 100644
index 00000000..e5e5c74e
--- /dev/null
+++ b/test/use-as-subproject/config.h
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ */
+
+#error Should not use superproject generated config.h to compile libdbus
diff --git a/test/use-as-subproject/dummy-config.h.in b/test/use-as-subproject/dummy-config.h.in
new file mode 100644
index 00000000..e5e5c74e
--- /dev/null
+++ b/test/use-as-subproject/dummy-config.h.in
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ */
+
+#error Should not use superproject generated config.h to compile libdbus
diff --git a/test/use-as-subproject/meson.build b/test/use-as-subproject/meson.build
new file mode 100644
index 00000000..8111e9ee
--- /dev/null
+++ b/test/use-as-subproject/meson.build
@@ -0,0 +1,38 @@
+# Copyright 2023 Collabora Ltd.
+# Copyright (c) 2023 SUSE LLC
+# SPDX-License-Identifier: MIT
+
+project(
+ 'use-libdbus-as-subproject',
+ 'c',
+ version : '0',
+ meson_version : '>=0.49.0'
+)
+add_project_arguments('-D_GNU_SOURCE', language : 'c')
+
+configure_file(
+ copy : true,
+ input : 'dummy-config.h.in',
+ output : 'config.h',
+)
+
+libdbus_dep = dependency(
+ 'dbus-1',
+ required: true,
+ fallback: ['dbus', 'libdbus_dep'],
+ default_options: [
+ 'default_library=static',
+ 'embedded_tests=false',
+ 'message_bus=false',
+ 'modular_tests=disabled',
+ 'tools=false',
+ ],
+)
+
+executable(
+ 'use-libdbus',
+ 'use-libdbus.c',
+ dependencies : [
+ libdbus_dep
+ ]
+)
diff --git a/test/use-as-subproject/use-libdbus.c b/test/use-as-subproject/use-libdbus.c
new file mode 100644
index 00000000..3acbde1c
--- /dev/null
+++ b/test/use-as-subproject/use-libdbus.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2023 SUSE LLC
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <assert.h>
+#include <dbus/dbus.h>
+
+int main(void)
+{
+ DBusMessage *m = NULL;
+
+ m = dbus_message_new_signal ("/", "com.example.Interface", "Signal");
+ assert (m != NULL);
+ dbus_message_unref (m);
+ return 0;
+}