gplugin/gplugin

f14783ee151b
Parents b7c659d32d7a
Children 36017e212411
Initial scaffolding for the rust bindings and tests

This is a small portion of GPLUGIN-133 to add rust bindings and test that we can load plugins written in rust. The rust portion of this is going to be done by a friend of mine, so to save them time we split it up so that I'm handling the build system side.

Testing Done:
ran with `meson -Drs=true` and verified it failed the unit tests as expected.

Bugs closed: GPLUGIN-136

Reviewed at https://reviews.imfreedom.org/r/628/
--- a/meson.build Wed Apr 28 04:09:45 2021 -0500
+++ b/meson.build Wed Apr 28 04:30:29 2021 -0500
@@ -93,6 +93,7 @@
subdir('lua')
subdir('perl5')
subdir('python3')
+subdir('rust')
subdir('tcc')
subdir('vala')
--- a/meson_options.txt Wed Apr 28 04:09:45 2021 -0500
+++ b/meson_options.txt Wed Apr 28 04:30:29 2021 -0500
@@ -59,6 +59,12 @@
)
option(
+ 'rs',
+ type : 'boolean', value : false,
+ description : 'Whether or not to create the rust bindings.'
+)
+
+option(
'tcc',
type : 'boolean', value : false,
description : 'Whether or not to build the TCC plugin loader'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/meson.build Wed Apr 28 04:30:29 2021 -0500
@@ -0,0 +1,6 @@
+if get_option('rs')
+ add_languages('rust')
+
+ subdir('tests')
+endif # rs
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/tests/meson.build Wed Apr 28 04:30:29 2021 -0500
@@ -0,0 +1,15 @@
+if get_option('rs')
+
+e = executable('test-rust-loading', 'test-rust-loading.c',
+ include_directories : include_directories('.'),
+ c_args: [
+ '-DRUST_PLUGIN_DIR="@0@/plugins"'.format(meson.current_build_dir()),
+ ],
+ link_with : gplugin_loader_tests,
+ dependencies : [GLIB, GOBJECT, gplugin_dep])
+test('Rust loading', e)
+
+subdir('plugins')
+
+endif # rs
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/tests/plugins/meson.build Wed Apr 28 04:30:29 2021 -0500
@@ -0,0 +1,3 @@
+if get_option('rs')
+
+endif # rs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/tests/test-rust-loading.c Wed Apr 28 04:30:29 2021 -0500
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011-2021 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+
+#include <gplugin.h>
+#include <gplugin/gplugin-loader-tests.h>
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+gint
+main(gint argc, gchar **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ gplugin_loader_tests_main(NULL, RUST_PLUGIN_DIR, "rust");
+
+ return g_test_run();
+}