gplugin/gplugin

Merged in feature/vala (pull request #21)
develop
2019-07-22, Gary Kramlich
33bac0aeb596
Merged in feature/vala (pull request #21)

Vala Testing and vapi generation

Approved-by: Elliott Sales de Andrade
--- a/INSTALL Fri Jul 19 21:17:45 2019 +0000
+++ b/INSTALL Mon Jul 22 07:01:06 2019 +0000
@@ -12,7 +12,7 @@
gtk-3
python3-dev, python-gi-dev, python3-gi
liblua5.1-0-dev, lua-lgi
- xsltproc
+ valac
All of these packages and their development headers need to be installed
prior to building GPlugin.
--- a/gplugin/meson.build Fri Jul 19 21:17:45 2019 +0000
+++ b/gplugin/meson.build Mon Jul 22 07:01:06 2019 +0000
@@ -228,6 +228,7 @@
GPLUGIN_PUBLIC_BUILT_SOURCES +
GPLUGIN_PUBLIC_BUILT_HEADERS,
includes : ['GModule-2.0', 'GObject-2.0'],
+ header : 'gplugin.h',
namespace : 'GPlugin',
symbol_prefix : 'gplugin',
nsversion : '@0@.0'.format(GPLUGIN_MAJOR_VERSION),
--- a/meson.build Fri Jul 19 21:17:45 2019 +0000
+++ b/meson.build Mon Jul 22 07:01:06 2019 +0000
@@ -104,6 +104,7 @@
subdir('perl')
subdir('python')
subdir('tcc')
+subdir('vala')
###############################################################################
# Install stuff
--- a/meson_options.txt Fri Jul 19 21:17:45 2019 +0000
+++ b/meson_options.txt Mon Jul 22 07:01:06 2019 +0000
@@ -60,3 +60,9 @@
type : 'boolean', value : false,
description : 'Whether or not to build the TCC plugin loader'
)
+
+option(
+ 'vapi',
+ type : 'boolean', value : true,
+ description : 'Whether or not to build vapi files for gplugin'
+)
--- a/packaging/debian/control Fri Jul 19 21:17:45 2019 +0000
+++ b/packaging/debian/control Mon Jul 22 07:01:06 2019 +0000
@@ -7,7 +7,8 @@
gettext, help2man,
gobject-introspection, libgirepository1.0-dev,
liblua5.1-0-dev, lua-lgi,
- python3-dev, python-gi-dev, python3-gi
+ python3-dev, python-gi-dev, python3-gi,
+ valac
Homepage: https://bitbucket.org/gplugin/gplugin
Vcs-Browser: https://bitbucket.org/gplugin/gplugin/src
Vcs-Hg: https://bitbucket.org/gplugin/gplugin
--- a/packaging/debian/libgplugin-dev.install Fri Jul 19 21:17:45 2019 +0000
+++ b/packaging/debian/libgplugin-dev.install Mon Jul 22 07:01:06 2019 +0000
@@ -3,3 +3,6 @@
debian/tmp/usr/include/gplugin-1.0/gplugin-native.h
debian/tmp/usr/lib/*/libgplugin.so
debian/tmp/usr/lib/*/pkgconfig/gplugin.pc
+debian/tmp/usr/share/vala/vapi/gplugin.deps
+debian/tmp/usr/share/vala/vapi/gplugin.vapi
+
--- a/packaging/debian/libgplugin-gtk-dev.install Fri Jul 19 21:17:45 2019 +0000
+++ b/packaging/debian/libgplugin-gtk-dev.install Mon Jul 22 07:01:06 2019 +0000
@@ -2,3 +2,5 @@
usr/include/gplugin-1.0/gplugin-gtk.h
debian/tmp/usr/lib/*/libgplugin-gtk.so
debian/tmp/usr/lib/*/pkgconfig/gplugin-gtk.pc
+debian/tmp/usr/share/vala/vapi/gplugin-gtk.deps
+debian/tmp/usr/share/vala/vapi/gplugin-gtk.vapi
--- a/packaging/gplugin.spec.in Fri Jul 19 21:17:45 2019 +0000
+++ b/packaging/gplugin.spec.in Mon Jul 22 07:01:06 2019 +0000
@@ -22,6 +22,7 @@
BuildRequires: lua-lgi
BuildRequires: python3-devel
BuildRequires: python3-gobject
+BuildRequires: vala
BuildRequires: /usr/lib64/pkgconfig/pygobject-3.0.pc
%package -n libgplugin0
@@ -43,6 +44,12 @@
Requires: %{name}-gtk3%{?_isa} = %{version}-%{release}
Requires: %{name}-devel%{?_isa} = %{version}-%{release}
+%package gtk3-vala
+Summary: A GObject based library that implements a reusable plugin system
+Group: Development/Libraries
+Requires: %{name}-gtk3%{?_isa} = %{version}-%{release}
+Requires: %{name}-devel%{?_isa} = %{version}-%{release}
+
%package lua
Summary: A GObject based library that implements a reusable plugin system
Group: Development/Libraries
@@ -51,6 +58,10 @@
Summary: A GObject based library that implements a reusable plugin system
Group: Development/Libraries
+%package vala
+Summary: A GObject based library that implements a reusable plugin system
+Group: Development/Libraries
+Requires: %{name}-devel%{?_isa} = %{version}-%{release}
%description
GPlugin is a GObject based library that implements a reusable plugin system
@@ -110,6 +121,19 @@
This package contains all necessary include files and libraries needed
to develop GTK3 applications that require these.
+%description gtk3-vala
+GPlugin is a GObject based library that implements a reusable plugin system
+that supports loading plugins in other languages via loaders. GPlugin also
+implements dependencies among the plugins.
+
+It was started due to the infamous "Plugin Problem" for Guifications 3, which
+was that I needed plugins that could depend on each other, be able to be
+written in other languages, have plugins that are loaded before the main load
+phase, and allow plugins to register types into the GObject type system.
+
+This package contains the vapi bindings allowing GPluginGtk to be used from
+vala.
+
%description lua
GPlugin is a GObject based library that implements a reusable plugin system
that supports loading plugins in other languages via loaders. GPlugin also
@@ -134,6 +158,17 @@
This package contains Python 3 loader for %{name} library.
+%description vala
+GPlugin is a GObject based library that implements a reusable plugin system
+that supports loading plugins in other languages via loaders. GPlugin also
+implements dependencies among the plugins.
+
+It was started due to the infamous "Plugin Problem" for Guifications 3, which
+was that I needed plugins that could depend on each other, be able to be
+written in other languages, have plugins that are loaded before the main load
+phase, and allow plugins to register types into the GObject type system.
+
+This package contains the vapi bindings allowing GPlugin to be used from vala.
%build
mkdir -p build
@@ -219,6 +254,19 @@
%doc README
%{_libdir}/gplugin/gplugin-python.so
+%files vala
+%defattr(-,root,root)
+%doc README
+%license COPYING
+${_datadir}/vala/vapi/gplugin.vapi
+${_datadir}/vala/vapi/gplugin.deps
+
+%files gtk3-vala
+%defattr(-,root,root)
+%doc README
+%license COPYING
+${_datadir}/vala/vapi/gplugin-gtk.vapi
+${_datadir}/vala/vapi/gplugin-gtk.deps
%changelog
* Sun May 15 2016 Gary Kramlich <grim@reaperworld.com>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/meson.build Mon Jul 22 07:01:06 2019 +0000
@@ -0,0 +1,24 @@
+if get_option('vapi')
+ if not get_option('gobject-introspection')
+ error('Vala generation requires GObject Introspection.')
+ endif
+
+ add_languages('vala')
+
+ gplugin_vapi = gnome.generate_vapi('gplugin',
+ sources : gplugin_gir[0],
+ install : true,
+ gir_dirs : join_paths(meson.build_root(), 'gplugin'),
+ )
+
+ if get_option('gtk3')
+ gplugin_gtk_vapi = gnome.generate_vapi('gplugin-gtk',
+ sources : gplugin_gtk_gir[0],
+ packages : [ 'gtk+-3.0' ],
+ install : true,
+ gir_dirs : join_paths(meson.build_root(), 'gplugin'),
+ )
+ endif
+
+ subdir('tests')
+endif # vala
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/meson.build Mon Jul 22 07:01:06 2019 +0000
@@ -0,0 +1,14 @@
+if get_option('vapi')
+
+e = executable('test-vala-loading', 'test-vala-loading.c',
+ include_directories : include_directories('.'),
+ c_args : [
+ '-DVALA_PLUGIN_DIR="@0@/plugins"'.format(meson.current_build_dir()),
+ ],
+ link_with : gplugin_loader_tests,
+ dependencies : [GLIB, GOBJECT, gplugin_dep])
+test('Vala loading', e)
+
+subdir('plugins')
+
+endif # vapi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/basic.vala Mon Jul 22 07:01:06 2019 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011-2019 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 <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class BasicPluginInfo : GPlugin.PluginInfo {
+ public BasicPluginInfo() {
+ string[] authors = {"author1"};
+
+ Object(
+ id: "gplugin/vala-basic-plugin",
+ abi_version: 0x01020304,
+ name: "basic plugin",
+ authors: authors,
+ category: "test",
+ version: "version",
+ license_id: "license",
+ summary: "summary",
+ website: "website",
+ description: "description"
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ error = null;
+
+ return new BasicPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ error = null;
+
+ return true;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ error = null;
+
+ return true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/dependent.vala Mon Jul 22 07:01:06 2019 +0000
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011-2019 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 <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class DependentPluginInfo : GPlugin.PluginInfo {
+ public DependentPluginInfo() {
+ string[] dependencies = {"dependency1", "dependency2"};
+
+ Object(
+ id: "gplugin/vala-dependent-plugin",
+ dependencies: dependencies
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ error = null;
+
+ return new DependentPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ error = null;
+
+ return true;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ error = null;
+
+ return false;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/load-exception.vala Mon Jul 22 07:01:06 2019 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011-2019 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 <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class LoadExceptionPluginInfo : GPlugin.PluginInfo {
+ public LoadExceptionPluginInfo() {
+ Object(
+ id: "gplugin/vala-load-exception"
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ error = null;
+
+ return new LoadExceptionPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ error = new Error(Quark.from_string("gplugin"), 0, "explode");
+
+ return false;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ error = null;
+
+ return true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/load-failed.vala Mon Jul 22 07:01:06 2019 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011-2019 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 <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class LoadFailedPluginInfo : GPlugin.PluginInfo {
+ public LoadFailedPluginInfo() {
+ Object(
+ id: "gplugin/vala-load-failed"
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ error = null;
+
+ return new LoadFailedPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ error = null;
+
+ return false;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ error = null;
+
+ return true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/meson.build Mon Jul 22 07:01:06 2019 +0000
@@ -0,0 +1,17 @@
+if get_option('vapi')
+ shared_library('vala-basic-plugin', 'basic.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('vala-dependent-plugin', 'dependent.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('vala-load-exception', 'load-exception.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('vala-load-failed', 'load-failed.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('vala-unload-failed', 'unload-failed.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+endif # vapi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/unload-failed.vala Mon Jul 22 07:01:06 2019 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011-2019 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 <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class UnloadFailedPluginInfo : GPlugin.PluginInfo {
+ public UnloadFailedPluginInfo() {
+ Object(
+ id: "gplugin/vala-unload-failed"
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ error = null;
+
+ return new UnloadFailedPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ error = null;
+
+ return true;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ error = null;
+
+ return false;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/test-vala-loading.c Mon Jul 22 07:01:06 2019 +0000
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011-2019 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 <http://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, VALA_PLUGIN_DIR, "vala");
+
+ return g_test_run();
+}
+