[gobject-introspection] Make g-ir-compiler find files installed by make install



commit db214ed923cfe9fc75432d5338e8a3b0d9c83d25
Author: Holger Hans Peter Freyther <zecke selfish org>
Date:   Mon Jun 1 09:18:43 2009 +0200

    Make g-ir-compiler find files installed by make install
    
    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             |    9 +++++++++
 gir/Makefile.am          |    2 +-
 girepository/girparser.c |   10 ++++++++--
 giscanner/config.py.in   |    2 ++
 giscanner/transformer.py |    5 +++--
 5 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c342930..2567702 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
diff --git a/gir/Makefile.am b/gir/Makefile.am
index f3b1dba..010839d 100644
--- a/gir/Makefile.am
+++ b/gir/Makefile.am
@@ -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)
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 2e8890e..0a06aa0 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -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)			        \
diff --git a/giscanner/config.py.in b/giscanner/config.py.in
index 8d57130..9de1f48 100644
--- a/giscanner/config.py.in
+++ b/giscanner/config.py.in
@@ -21,3 +21,5 @@
 DATADIR = "@datarootdir@"
 DATADIR = DATADIR.replace(
     "${prefix}", "@prefix@")
+GIR_DIR = "@GIR_DIR@"
+GIR_SUFFIX = "@GIR_SUFFIX@"
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 88cbc15..cc9e0b5 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -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:



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