r21655 - gnucash/trunk/src/engine - [Testing] Provide for engine to load backends from build path

John Ralls jralls at code.gnucash.org
Fri Dec 2 16:59:56 EST 2011


Author: jralls
Date: 2011-12-02 16:59:56 -0500 (Fri, 02 Dec 2011)
New Revision: 21655
Trac: http://svn.gnucash.org/trac/changeset/21655

Modified:
   gnucash/trunk/src/engine/gnc-engine.c
Log:
[Testing] Provide for engine to load backends from build path

If two new environment variables (GNC_UNINSTALLED and GNC_BUILDDIR)are set, load the backends from GNC_BUILDDIR/src/backend.

GNC_UNINSTALLED is intended to be set via g_setenv() or (setenv) at the beginning of a test program. GNC_BUILDDIR is intended to be set with
GNC_BUILDDIR=`cd ${top_builddir} && pwd`
as part of the TESTS_ENVIRONMENT variable in test Makefiles.

Modified: gnucash/trunk/src/engine/gnc-engine.c
===================================================================
--- gnucash/trunk/src/engine/gnc-engine.c	2011-12-02 20:55:58 UTC (rev 21654)
+++ gnucash/trunk/src/engine/gnc-engine.c	2011-12-02 21:59:56 UTC (rev 21655)
@@ -69,35 +69,54 @@
 static void
 gnc_engine_init_part2()
 {
-    gchar *pkglibdir = gnc_path_get_pkglibdir ();
+    gchar *pkglibdir;
+    static gchar *builddir = g_getenv ("GNC_BUILDDIR");
+    gboolean uninstalled = (g_getenv ("GNC_UNINSTALLED") != NULL
+			    && builddir != NULL);
+
     static struct
     {
+	const gchar* subdir;
         const gchar* lib;
         gboolean required;
     } libs[] =
     {
 #if defined( HAVE_DBI_DBI_H )
-        { "gncmod-backend-dbi", TRUE },
+        { "dbi", "gncmod-backend-dbi", TRUE },
 #endif
-        { "gncmod-backend-xml", TRUE },
+        { "xml", "gncmod-backend-xml", TRUE },
         { NULL, FALSE }
     }, *lib;
 
+    if (uninstalled)
+	pkglibdir = g_build_path (G_DIR_SEPARATOR_S, builddir,
+				  "src", "backend", NULL);
+    else
+	pkglibdir = gnc_path_get_pkglibdir ();
+
     for (lib = libs; lib->lib ; lib++)
     {
-        if (qof_load_backend_library(pkglibdir, lib->lib))
+	gchar *libdir;
+	if (uninstalled)
+	    libdir = g_build_path (G_DIR_SEPARATOR_S, pkglibdir,
+				   lib->subdir, ".libs", NULL);
+	else
+	    libdir = pkglibdir;
+        if (qof_load_backend_library(libdir, lib->lib))
         {
             engine_is_initialized = 1;
         }
         else
         {
-            g_warning("failed to load %s from %s\n", lib->lib, pkglibdir);
+            g_warning("failed to load %s from %s\n", lib->lib, libdir);
             /* If this is a required library, stop now! */
             if (lib->required)
             {
                 g_critical("required library %s not found.\n", lib->lib);
             }
         }
+	if (uninstalled)
+	    g_free (libdir);
     }
     g_free (pkglibdir);
 }



More information about the gnucash-changes mailing list