gplugin/gplugin

Parents 3880a5d25cf2
Children c631d0391343
Setup meson devenv and port gplugin-gtk3-viewer to use the gplugin option group

Testing Done:
Ran the unit tests, and verified that `gplugin-query` and `gplugin-gtk3-viewer` show all of the test plugins.

Reviewed at https://reviews.imfreedom.org/r/988/
--- a/gplugin-gtk3-viewer/gplugin-gtk-viewer.c Sun Oct 03 00:05:29 2021 -0500
+++ b/gplugin-gtk3-viewer/gplugin-gtk-viewer.c Sun Oct 03 01:44:30 2021 -0500
@@ -27,8 +27,7 @@
* Globals
*****************************************************************************/
static gboolean show_internal = FALSE;
-static gboolean add_default_paths = TRUE, version_only = FALSE;
-static gchar **paths = NULL;
+static gboolean version_only = FALSE;
/******************************************************************************
* Callbacks
@@ -80,18 +79,6 @@
}
static gboolean
-no_default_cb(
- G_GNUC_UNUSED const gchar *n,
- G_GNUC_UNUSED const gchar *v,
- G_GNUC_UNUSED gpointer d,
- G_GNUC_UNUSED GError **e)
-{
- add_default_paths = FALSE;
-
- return TRUE;
-}
-
-static gboolean
version_cb(
G_GNUC_UNUSED const gchar *n,
G_GNUC_UNUSED const gchar *v,
@@ -161,14 +148,6 @@
internal_cb, "Show internal plugins",
NULL,
}, {
- "no-default-paths", 'D', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- no_default_cb, "Do not search the default plugin paths",
- NULL,
- }, {
- "path", 'p', 0, G_OPTION_ARG_STRING_ARRAY,
- &paths, "Additional paths to look for plugins",
- "PATH",
- }, {
"version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
version_cb, "Display the version and exit",
NULL,
@@ -185,10 +164,12 @@
GError *error = NULL;
GOptionContext *ctx = NULL;
GtkWidget *window = NULL;
+ const gchar *env_paths = NULL;
ctx = g_option_context_new("");
g_option_context_add_main_entries(ctx, entries, NULL);
g_option_context_add_group(ctx, gtk_get_option_group(TRUE));
+ g_option_context_add_group(ctx, gplugin_get_option_group());
g_option_context_parse(ctx, &argc, &argv, &error);
g_option_context_free(ctx);
@@ -212,15 +193,16 @@
manager = gplugin_manager_get_default();
- if(add_default_paths)
- gplugin_manager_add_default_paths(manager);
-
- if(paths) {
+ env_paths = g_getenv("GPLUGIN_PLUGIN_PATH");
+ if(env_paths != NULL) {
+ gchar **paths = g_strsplit(env_paths, G_SEARCHPATH_SEPARATOR_S, 0);
gint i;
- for(i = 0; paths[i]; i++) {
+ for(i = 0; paths[i] != NULL; i++) {
gplugin_manager_prepend_path(manager, paths[i]);
}
+
+ g_strfreev(paths);
}
gplugin_manager_refresh(manager);
--- a/gplugin-query/gplugin-query.c Sun Oct 03 00:05:29 2021 -0500
+++ b/gplugin-query/gplugin-query.c Sun Oct 03 01:44:30 2021 -0500
@@ -298,6 +298,7 @@
GError *error = NULL;
GOptionContext *ctx = NULL;
GOptionGroup *group = NULL;
+ const gchar *env_paths = NULL;
gint i = 0, ret = 0;
ctx = g_option_context_new("PLUGIN-ID...");
@@ -328,6 +329,18 @@
manager = gplugin_manager_get_default();
+ env_paths = g_getenv("GPLUGIN_PLUGIN_PATH");
+ if(env_paths != NULL) {
+ gchar **paths = g_strsplit(env_paths, G_SEARCHPATH_SEPARATOR_S, 0);
+ gint i;
+
+ for(i = 0; paths[i] != NULL; i++) {
+ gplugin_manager_prepend_path(manager, paths[i]);
+ }
+
+ g_strfreev(paths);
+ }
+
if(output_paths) {
GList *path = NULL;
--- a/gplugin/tests/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/gplugin/tests/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -16,6 +16,9 @@
# Tests
###############################################################################
+# Add the normal plugins to the plugin path envvar
+devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir() / 'plugins')
+
#######################################
# Simple Tests (single file)
#######################################
--- a/lua/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/lua/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -57,6 +57,9 @@
install : true,
install_dir : get_option('libdir') / 'gplugin'
)
+
+ # Add the loader's path to our environment variable
+ devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
endif # lua
subdir('tests')
--- a/lua/tests/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/lua/tests/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -10,4 +10,7 @@
dependencies : [GLIB, GOBJECT, LUA, gplugin_dep])
test('Lua Loader', e)
+# Add the test plugins path to our environment variable
+devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_source_dir() / 'plugins')
+
endif # lua
--- a/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -47,6 +47,26 @@
)
###############################################################################
+# devenv
+#
+# This sets up the meson devenv stuff. See
+# https://mesonbuild.com/Commands.html#devenv for more information.
+###############################################################################
+devenv = environment()
+
+if meson.version().version_compare('>=0.58.0')
+ config_home = get_option('devenv-config-dir')
+
+ if config_home == ''
+ config_home = meson.build_root() / 'config'
+ endif
+
+ devenv.set('XDG_CONFIG_HOME', config_home)
+
+ meson.add_devenv(devenv)
+endif
+
+###############################################################################
# NLS
###############################################################################
GETTEXT_PACKAGE = 'gplugin'
--- a/meson_options.txt Sun Oct 03 00:05:29 2021 -0500
+++ b/meson_options.txt Sun Oct 03 01:44:30 2021 -0500
@@ -11,6 +11,12 @@
)
option(
+ 'devenv-config-dir',
+ type : 'string',
+ description : 'config directory for running a devenv (defaults to a subdirectory of buildroot)'
+)
+
+option(
'gtk3',
type : 'boolean', value : true,
description : 'Whether or not to build the gtk3 library'
--- a/perl5/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/perl5/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -71,6 +71,9 @@
install : true,
install_dir : get_option('libdir') / 'gplugin'
)
+
+ # Add the loader's path to our environment variable
+ devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
endif # perl5
subdir('tests')
--- a/perl5/tests/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/perl5/tests/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -9,4 +9,7 @@
dependencies : [GLIB, GOBJECT, gplugin_dep, perl_dep])
test('Perl5 Loader', e)
+# Add the test plugins path to our environment variable
+devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_source_dir() / 'plugins')
+
endif # perl5
--- a/python3/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/python3/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -83,6 +83,9 @@
include_directories : gplugin_python3_inc,
link_with : gplugin_python3_static,
)
+
+ # Add the loader's path to our environment variable
+ devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
endif # python3
subdir('tests')
--- a/python3/tests/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/python3/tests/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -19,4 +19,7 @@
gplugin_python3_static_dep])
test('Python3 utils', e)
+# Add the test plugins path to our environment variable
+devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_source_dir() / 'plugins')
+
endif # python3
--- a/tcc/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/tcc/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -26,6 +26,9 @@
install : true,
install_dir : get_option('libdir') / 'gplugin'
)
+
+ # Add the loader's path to our environment variable
+ devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
endif # tcc
subdir('tests')
--- a/vala/tests/genie-plugins/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/vala/tests/genie-plugins/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -17,4 +17,7 @@
shared_library('unload-failed-plugin', 'unload-failed.gs',
name_prefix : '',
dependencies : [gplugin_dep, gplugin_vapi])
+
+ # Add the test plugins path to our environment variable
+ devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
endif # vapi
--- a/vala/tests/plugins/meson.build Sun Oct 03 00:05:29 2021 -0500
+++ b/vala/tests/plugins/meson.build Sun Oct 03 01:44:30 2021 -0500
@@ -17,4 +17,7 @@
shared_library('vala-unload-shutdown', 'unload-shutdown.vala',
name_prefix : '',
dependencies : [gplugin_dep, gplugin_vapi])
+
+ # Add the test plugins path to our environment variable
+ devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
endif # vapi