Make g-ir-compiler find files installed by make install
authorHolger Hans Peter Freyther <zecke@selfish.org>
Mon, 1 Jun 2009 07:18:43 +0000 (09:18 +0200)
committerColin Walters <walters@verbum.org>
Thu, 11 Jun 2009 17:53:01 +0000 (13:53 -0400)
When ./configure --prefix $HOME/some/where is used gobject-introspection
will happily install the files into $HOME/some/where/data/gir-1.0 but
it will refuse to find them. Apply the same trick as in
girepository/girepository.c:init_globals to find the gir files.

Unifiy the name gir-1.0 in GIR_SUFFIX and use it throughout the
project, introduce GIR_DIR which holds the path to the gir files and
update girparser and transformer.py to look into this path.

configure.ac
gir/Makefile.am
girepository/girparser.c
giscanner/config.py.in
giscanner/transformer.py

index c342930..2567702 100644 (file)
@@ -108,6 +108,15 @@ GOBJECT_INTROSPECTION_LIBDIR="$EXPANDED_LIBDIR"
 AC_SUBST(GOBJECT_INTROSPECTION_LIBDIR)
 AC_DEFINE_UNQUOTED(GOBJECT_INTROSPECTION_LIBDIR,"$GOBJECT_INTROSPECTION_LIBDIR", [Directory prefix for typelib installation])
 
+#### Directory to install the gir files
+GIR_SUFFIX="gir-1.0"
+AC_SUBST(GIR_SUFFIX)
+AC_DEFINE_UNQUOTED(GIR_SUFFIX, "$GIR_SUFFIX", [Name of the gir directory])
+
+GIR_DIR="$EXPANDED_DATADIR/$GIR_SUFFIX"
+AC_SUBST(GIR_DIR)
+AC_DEFINE_UNQUOTED(GIR_DIR, "$GIR_DIR", [Director prefix for gir installation])
+
 PKG_CHECK_MODULES(GOBJECT, [gobject-2.0 gio-2.0])
 PKG_CHECK_MODULES(GTHREAD, [gthread-2.0])
 PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0], have_gio_unix=true, have_gio_unix=false)
index f3b1dba..010839d 100644 (file)
@@ -201,7 +201,7 @@ GIRSOURCES =                        \
        $(BASE_GIRSOURCES)      \
        $(BUILT_GIRSOURCES)
 
-girdir = $(datadir)/gir-1.0
+girdir = $(GIR_DIR)
 dist_gir_DATA = $(GIRSOURCES)
 
 %.typelib: %.gir $(top_builddir)/tools/g-ir-compiler$(EXEEXT)
index 2e8890e..0a06aa0 100644 (file)
@@ -27,6 +27,7 @@
 #include "girmodule.h"
 #include "girnode.h"
 #include "gtypelib.h"
+#include "config.h"
 
 struct _GIrParser
 {
@@ -245,13 +246,18 @@ locate_gir (GIrParser  *parser,
     }
   for (dir = datadirs; *dir; dir++) 
     {
-      path = g_build_filename (*dir, "gir-1.0", girname, NULL);
+      path = g_build_filename (*dir, GIR_SUFFIX, girname, NULL);
       if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
        return path;
       g_free (path);
       path = NULL;
     }
-  return path;
+
+  path = g_build_filename (GIR_DIR, girname, NULL);
+  if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))
+    return path;
+  g_free (path);
+  return NULL;
 }
 
 #define MISSING_ATTRIBUTE(ctx,error,element,attribute)                         \
index 8d57130..9de1f48 100644 (file)
@@ -21,3 +21,5 @@
 DATADIR = "@datarootdir@"
 DATADIR = DATADIR.replace(
     "${prefix}", "@prefix@")
+GIR_DIR = "@GIR_DIR@"
+GIR_SUFFIX = "@GIR_SUFFIX@"
index 88cbc15..cc9e0b5 100644 (file)
@@ -25,7 +25,7 @@ from .ast import (Bitfield, Callback, Enum, Function, Namespace, Member,
                   Type, Array, Alias, Interface, Class, Node, Union,
                   Varargs, Constant, type_name_from_ctype,
                   type_names, TYPE_STRING, BASIC_GIR_TYPES)
-from .config import DATADIR
+from .config import DATADIR, GIR_DIR, GIR_SUFFIX
 from .glibast import GLibBoxed
 from .girparser import GIRParser
 from .odict import odict
@@ -117,7 +117,8 @@ class Transformer(object):
     def _find_include(self, include):
         searchdirs = self._includepaths[:]
         for path in _xdg_data_dirs:
-            searchdirs.append(os.path.join(path, 'gir-1.0'))
+            searchdirs.append(os.path.join(path, GIR_SUFFIX))
+        searchdirs.append(GIR_DIR)
 
         girname = '%s-%s.gir' % (include.name, include.version)
         for d in searchdirs: