[libgdata] Add GObject introspection support



commit a3ad67db38082514cc85891df305369b3ba7ed98
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Dec 3 14:26:42 2009 +0000

    Add GObject introspection support
    
    Add basic GObject introspection support for the library. None of the GIR file
    has been checked, and no annotations have been added yet.

 Makefile.am       |    3 +-
 configure.ac      |    2 +
 gdata/Makefile.am |   32 +++++++++++++++++++
 introspection.m4  |   88 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 124 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 3e42b6b..cc65072 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,7 +11,8 @@ EXTRA_DIST = \
 	HACKING			\
 	gtk-doc.make		\
 	libgdata.pc.in		\
-	libgdata.doap
+	libgdata.doap		\
+	introspection.m4
 
 CLEANFILES = gdata.pc
 
diff --git a/configure.ac b/configure.ac
index ab9a28c..30a0aa8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,6 +78,8 @@ GNOME_COMPILE_WARNINGS([maximum])
 GNOME_CXX_WARNINGS
 GNOME_MAINTAINER_MODE_DEFINES
 
+GOBJECT_INTROSPECTION_CHECK([0.6.3])
+
 AC_SUBST([AM_CPPFLAGS])
 AC_SUBST([AM_CFLAGS])
 AC_SUBST([AM_CXXFLAGS])
diff --git a/gdata/Makefile.am b/gdata/Makefile.am
index 467ad31..7393439 100644
--- a/gdata/Makefile.am
+++ b/gdata/Makefile.am
@@ -120,4 +120,36 @@ EXTRA_DIST = \
 	gdata.symbols	\
 	gdata-marshal.list
 
+# Introspection
+
+if HAVE_INTROSPECTION
+GData-$(GDATA_VERSION_MAJOR).$(GDATA_VERSION_MINOR).gir: $(INTROSPECTION_SCANNER) libgdata.la
+	$(QUIET_GEN)$(INTROSPECTION_SCANNER) -v						\
+	--namespace GData --nsversion=$(GDATA_VERSION_MAJOR).$(GDATA_VERSION_MINOR)	\
+	--strip-prefix=GData --add-include-path=$(srcdir) --add-include=path=.		\
+	--c-include="gdata/gdata.h" --include=libxml2-2.0 --include=Soup-2.4		\
+	--library=gdata --output $@ --pkg gobject-2.0					\
+	-I$(top_srcdir)									\
+	-I$(top_srcdir)/gdata								\
+	`find -name "*.[ch]" | grep -vE ".*/gdata-(youtube-control|media-group|youtube-group|georss-where|exif-tags)\.[ch]"`
+# The files listed above are excluded because they're currently private
+
+BUILT_GIRSOURCES = GData-$(GDATA_VERSION_MAJOR).$(GDATA_VERSION_MINOR).gir
+
+# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to
+# install anything - we need to install inside our prefix.
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(BUILT_GIRSOURCES)
+
+typelibsdir = $(libdir)/girepository-1.0/
+typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
+
+%.typelib: %.gir $(INTROSPECTION_COMPILER)
+	$(QUIET_GEN)$(DEBUG) $(INTROSPECTION_COMPILER)	\
+	--includedir=$(srcdir) --includedir=.		\
+	$(INTROSPECTION_COMPILER_OPTS) $< -o $(builddir)/$(@F)
+
+CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
+endif
+
 -include $(top_srcdir)/git.mk
diff --git a/introspection.m4 b/introspection.m4
new file mode 100644
index 0000000..f9ce49c
--- /dev/null
+++ b/introspection.m4
@@ -0,0 +1,88 @@
+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)"
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+
+    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]