[gegl] Add Gobject Introspection to build.



commit 90857cbccd8702578a0334bbb6a4dee17153fae5
Author: Jon Nordby <jononor gmail com>
Date:   Mon Mar 21 20:41:00 2011 +0000

    Add Gobject Introspection to build.
    
    Includes a trivial example using PyGObject

 Makefile.am               |    5 ++-
 configure.ac              |    4 ++
 examples/introspection.py |   18 +++++++++
 gegl/.gitignore           |    2 +
 gegl/Makefile.am          |   54 ++++++++++++++++++++++---
 gegl/gegl-matrix.h        |    5 ++
 m4/introspection.m4       |   94 +++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 174 insertions(+), 8 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index a84dcc1..8654122 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,7 +28,10 @@ EXTRA_DIST = 			\
 	$(built_dist_files)     \
 	autogen.sh		\
 	gegl-uninstalled.pc.in	\
-	gegl.pc.in
+	gegl.pc.in \
+	m4/introspection.m4
+
+DISTCHECK_CONFIGURE_FLAGS = --enable-introspection
 
 DISTCLEANFILES = \
 	$(built_dist_files)
diff --git a/configure.ac b/configure.ac
index fce2246..9f5d9e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -394,6 +394,10 @@ fi
 
 CFLAGS="$CFLAGS $MMX_EXTRA_CFLAGS $SSE_EXTRA_CFLAGS"
 
+########################
+# Check GObject Introspection
+########################
+GOBJECT_INTROSPECTION_CHECK([0.6.7])
 
 ###############################
 # Checks for required libraries
diff --git a/examples/introspection.py b/examples/introspection.py
new file mode 100755
index 0000000..b383cc8
--- /dev/null
+++ b/examples/introspection.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+# This file is a part of GEGL, and is licensed under the same conditions
+
+"""Example script showing how GEGL can be used from Python using
+GObject introspection."""
+
+# Requires PyGObject 2.26 or later
+# To use a typelib from a non-standard location, set the env var
+# GI_TYPELIB_PATH to the directory with your Gegl-$apiversion-.typelib
+
+import gi
+from gi.repository import Gegl
+
+if __name__ == '__main__':
+    # Right now just a sanity check
+    node = Gegl.Node.new()
+    print dir(node)
diff --git a/gegl/.gitignore b/gegl/.gitignore
index 80078eb..ac5bfd3 100644
--- a/gegl/.gitignore
+++ b/gegl/.gitignore
@@ -6,3 +6,5 @@
 /gegl-version.h
 /Makefile
 /Makefile.in
+/*.gir
+/*.typelib
diff --git a/gegl/Makefile.am b/gegl/Makefile.am
index c9acc5a..45224a4 100644
--- a/gegl/Makefile.am
+++ b/gegl/Makefile.am
@@ -1,9 +1,18 @@
+
+### GObject introspection
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)
+INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
+
 if PLATFORM_WIN32
 no_undefined = -no-undefined
 endif
 
 SUBDIRS = buffer graph module operation process property-types
 
+CLEANFILES =
+
 AM_CPPFLAGS = \
 	-I$(top_srcdir) \
 	-I$(top_builddir)/gegl/buffer \
@@ -25,12 +34,10 @@ LIBS = \
 
 GEGL_publicdir = $(includedir)/gegl-$(GEGL_API_VERSION)
 
-GEGL_public_HEADERS =	\
+GEGL_introspectable_headers =	\
     gegl.h				\
     gegl-types.h			\
     gegl-utils.h			\
-    gegl-matrix.h			\
-    gegl-chant.h			\
     gegl-lookup.h			\
     gegl-plugin.h			\
     gegl-version.h			\
@@ -45,7 +52,12 @@ GEGL_public_HEADERS =	\
     property-types/gegl-path.h		\
     property-types/gegl-curve.h
 
-GEGL_sources = \
+GEGL_public_HEADERS = \
+	$(GEGL_introspectable_headers) \
+    gegl-matrix.h			\
+    gegl-chant.h
+
+GEGL_introspectable_sources = \
 	gegl-c.c			\
 	gegl-config.c			\
 	gegl-cpuaccel.c			\
@@ -55,10 +67,8 @@ GEGL_sources = \
 	gegl-instrument.c		\
 	gegl-utils.c			\
 	gegl-lookup.c			\
-	gegl-matrix.c			\
 	gegl-xml.c			\
 	\
-	gegl-chant.h			\
 	gegl-lookup.h			\
 	gegl-config.h			\
 	gegl-cpuaccel.h			\
@@ -68,11 +78,17 @@ GEGL_sources = \
 	gegl-init.h			\
 	gegl-instrument.h		\
 	gegl-module.h			\
-	gegl-matrix.h			\
 	gegl-plugin.h			\
 	gegl-types-internal.h		\
 	gegl-xml.h
 
+GEGL_sources = \
+	$(GEGL_introspectable_sources) \
+	gegl-matrix.c \
+	\
+	gegl-chant.h \
+	gegl-matrix.h
+
 lib_LTLIBRARIES = libgegl- GEGL_API_VERSION@.la
 
 libgegl_ GEGL_API_VERSION@_la_SOURCES = $(GEGL_sources) $(GEGL_public_HEADERS)
@@ -84,3 +100,27 @@ libgegl_ GEGL_API_VERSION@_la_LIBADD = \
 	$(top_builddir)/gegl/process/libprocess.la		\
 	$(top_builddir)/gegl/property-types/libpropertytypes.la
 
+
+if HAVE_INTROSPECTION
+introspection_sources = \
+	$(GEGL_instrospectable_sources) \
+	$(GEGL_introspectable_headers)
+
+INCLUDES = $(AM_CFLAGS) $(AM_CPPFLAGS)
+
+Gegl- GEGL_API_VERSION@.gir: libgegl- GEGL_API_VERSION@.la Makefile
+Gegl_0_1_gir_INCLUDES = GObject-2.0
+Gegl_0_1_gir_CFLAGS = $(INCLUDES)
+Gegl_0_1_gir_LIBS = libgegl- GEGL_API_VERSION@.la
+Gegl_0_1_gir_FILES = $(introspection_sources)
+INTROSPECTION_GIRS += Gegl- GEGL_API_VERSION@.gir
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
+endif
+
diff --git a/gegl/gegl-matrix.h b/gegl/gegl-matrix.h
index cb8fb77..214ec9c 100644
--- a/gegl/gegl-matrix.h
+++ b/gegl/gegl-matrix.h
@@ -16,6 +16,11 @@ G_BEGIN_DECLS
  * typedef gdouble GeglMatrix3 [3][3];
  */
 
+/* FIXME: Multi-dimensional arrays are not introspectable, so this
+ * header has to be excluded from the GI scan, and therefore not available to
+ * GI-based bindings.
+ * See https://bugzilla.gnome.org/show_bug.cgi?id=645817 */
+
 typedef gdouble GeglMatrix3 [3][3];
 typedef gdouble GeglMatrix2 [2][2];
 
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644
index 0000000..589721c
--- /dev/null
+++ b/m4/introspection.m4
@@ -0,0 +1,94 @@
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+    dnl enable/disable introspection
+    m4_if([$2], [require],
+    [dnl
+        enable_introspection=yes
+    ],[dnl
+        AC_ARG_ENABLE(introspection,
+                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+                                 [Enable introspection for this build]),, 
+                                 [enable_introspection=auto])
+    ])dnl
+
+    AC_MSG_CHECKING([for gobject-introspection])
+
+    dnl presence/version checking
+    AS_CASE([$enable_introspection],
+    [no], [dnl
+        found_introspection="no (disabled, use --enable-introspection to enable)"
+    ],dnl
+    [yes],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+                         found_introspection=yes,
+                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
+    ],dnl
+    [auto],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+    ],dnl
+    [dnl	
+        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
+    ])dnl
+
+    AC_MSG_RESULT([$found_introspection])
+
+    INTROSPECTION_SCANNER=
+    INTROSPECTION_COMPILER=
+    INTROSPECTION_GENERATE=
+    INTROSPECTION_GIRDIR=
+    INTROSPECTION_TYPELIBDIR=
+    if test "x$found_introspection" = "xyes"; then
+       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+    AC_SUBST(INTROSPECTION_CFLAGS)
+    AC_SUBST(INTROSPECTION_LIBS)
+    AC_SUBST(INTROSPECTION_MAKEFILE)
+
+    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])



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