[gnome-software] Ensure the correct plugin directory is used



commit c97171bc84be2cc02997f776febf966834133a9b
Author: Richard Hughes <richard hughsie com>
Date:   Wed Dec 7 11:36:46 2016 +0000

    Ensure the correct plugin directory is used
    
    Meson is doing this out-of-tree, and it would also be good to get the
    gnome-software binary using the locally built plugins rather than having to
    remember to 'install' the plugins before changes are picked up.

 meson.build            |    5 ++++-
 src/Makefile.am        |    1 +
 src/gs-application.c   |    3 ++-
 src/gs-cmd.c           |    3 ++-
 src/gs-plugin-loader.c |   18 ++++++------------
 src/gs-self-test.c     |    2 +-
 6 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/meson.build b/meson.build
index 1ee4935..d49d2d5 100644
--- a/meson.build
+++ b/meson.build
@@ -153,7 +153,10 @@ gnome = import('gnome')
 i18n = import('i18n')
 
 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
-conf.set_quoted('TESTDATADIR', '..')
+conf.set_quoted('TESTDATADIR', join_paths(meson.current_source_dir(), 'data'))
+conf.set_quoted('LOCALPLUGINDIR',
+                join_paths(meson.current_build_dir(),
+                           'src', 'plugins'))
 conf.set_quoted('LOCALEDIR',
                 join_paths(get_option('prefix'),
                            get_option('localedir')))
diff --git a/src/Makefile.am b/src/Makefile.am
index 73aa6b0..a366a21 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,6 +22,7 @@ AM_CPPFLAGS =                                         \
        -DLOCALEDIR=\""$(localedir)"\"                  \
        -DLOCALSTATEDIR=\""$(localstatedir)"\"          \
        -DTESTDATADIR=\""$(top_srcdir)/data"\"          \
+       -DLOCALPLUGINDIR=\""$(top_builddir)/plugins/.libs"\"    \
        -DGS_DATA=\"$(pkgdatadir)\"
 
 pkgconfigdir = $(libdir)/pkgconfig
diff --git a/src/gs-application.c b/src/gs-application.c
index 7d267d5..91adf6c 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -146,7 +146,8 @@ gs_application_initialize_plugins (GsApplication *app)
                plugin_whitelist = g_strsplit (tmp, ",", -1);
 
        app->plugin_loader = gs_plugin_loader_new ();
-       gs_plugin_loader_set_location (app->plugin_loader, NULL);
+       if (g_file_test (LOCALPLUGINDIR, G_FILE_TEST_EXISTS))
+               gs_plugin_loader_set_location (app->plugin_loader, LOCALPLUGINDIR);
        if (!gs_plugin_loader_setup (app->plugin_loader,
                                     plugin_whitelist,
                                     plugin_blacklist,
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index 072411e..8160407 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -268,7 +268,8 @@ main (int argc, char **argv)
        profile = gs_plugin_loader_get_profile (plugin_loader);
        ptask = as_profile_start_literal (profile, "GsCmd");
        g_assert (ptask != NULL);
-       gs_plugin_loader_set_location (plugin_loader, "./plugins/.libs");
+       if (g_file_test (LOCALPLUGINDIR, G_FILE_TEST_EXISTS))
+               gs_plugin_loader_set_location (plugin_loader, LOCALPLUGINDIR);
        if (plugin_whitelist_str != NULL)
                plugin_whitelist = g_strsplit (plugin_whitelist_str, ",", -1);
        if (plugin_blacklist_str != NULL)
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 779d2df..a29cbd9 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -3485,19 +3485,8 @@ void
 gs_plugin_loader_set_location (GsPluginLoader *plugin_loader, const gchar *location)
 {
        GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
-       g_autofree gchar *filename = NULL;
-
        g_free (priv->location);
-
-       /* something non-default specified */
-       if (location != NULL) {
-               priv->location = g_strdup (location);
-               return;
-       }
-
-       /* use the default, but this requires a 'make install' */
-       filename = g_strdup_printf ("gs-plugins-%s", GS_PLUGIN_API_VERSION);
-       priv->location = g_build_filename (LIBDIR, filename, NULL);
+       priv->location = g_strdup (location);
 }
 
 static gint
@@ -3995,6 +3984,7 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader)
        gchar *match;
        gchar **projects;
        guint i;
+       g_autofree gchar *filename = NULL;
 
        priv->scale = 1;
        priv->global_cache = gs_app_list_new ();
@@ -4059,6 +4049,10 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader)
        for (i = 0; projects[i] != NULL; i++)
                g_debug ("compatible-project: %s", projects[i]);
        priv->compatible_projects = projects;
+
+       /* use the default, but this requires a 'make install' */
+       filename = g_strdup_printf ("gs-plugins-%s", GS_PLUGIN_API_VERSION);
+       priv->location = g_build_filename (LIBDIR, filename, NULL);
 }
 
 /**
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 4cac23d..4f42873 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -1505,7 +1505,7 @@ main (int argc, char **argv)
        plugin_loader = gs_plugin_loader_new ();
        g_signal_connect (plugin_loader, "status-changed",
                          G_CALLBACK (gs_plugin_loader_status_changed_cb), NULL);
-       gs_plugin_loader_set_location (plugin_loader, "./plugins/.libs");
+       gs_plugin_loader_set_location (plugin_loader, LOCALPLUGINDIR);
        ret = gs_plugin_loader_setup (plugin_loader,
                                      (gchar**) whitelist,
                                      NULL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]