]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
gitlab-ci: build libdbus as subproject
authorDaniel Wagner <dwagner@suse.de>
Fri, 13 Jan 2023 12:29:06 +0000 (13:29 +0100)
committerDaniel Wagner <dwagner@suse.de>
Tue, 7 Feb 2023 08:07:32 +0000 (09:07 +0100)
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>
.gitlab-ci.yml
test/use-as-subproject/.gitignore [new file with mode: 0644]
test/use-as-subproject/config.h [new file with mode: 0644]
test/use-as-subproject/dummy-config.h.in [new file with mode: 0644]
test/use-as-subproject/meson.build [new file with mode: 0644]
test/use-as-subproject/use-libdbus.c [new file with mode: 0644]

index 64f4f569fbcb9caa185652be0437aae80df90e76..f20b0ee5a014cda1cf8dc30e7672422080242dd5 100644 (file)
@@ -206,6 +206,15 @@ debian meson clang debug:
     ci_buildsys: "meson-dist"
     ci_compiler: "clang"
     ci_variant: "debug"
+  script:
+    - ./tools/ci-build.sh
+    # Also test that we can be used as a subproject:
+    # https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/388
+    - mkdir -p test/use-as-subproject/subprojects/dbus
+    - tar --strip-components=1 -C test/use-as-subproject/subprojects/dbus -xf ci-build-dist/*.tar.xz
+    - meson setup --wrap-mode=forcefallback test/use-as-subproject/_build test/use-as-subproject
+    - meson compile -C test/use-as-subproject/_build
+    - meson test -C test/use-as-subproject/_build
 
 debian mingw32 autotools debug:
   extends: .debian-build
diff --git a/test/use-as-subproject/.gitignore b/test/use-as-subproject/.gitignore
new file mode 100644 (file)
index 0000000..2c32b03
--- /dev/null
@@ -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 (file)
index 0000000..e5e5c74
--- /dev/null
@@ -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 (file)
index 0000000..e5e5c74
--- /dev/null
@@ -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 (file)
index 0000000..8111e9e
--- /dev/null
@@ -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 (file)
index 0000000..3acbde1
--- /dev/null
@@ -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;
+}