[libsocialweb/vala: 6/9] vala: Generate Vala binding



commit 08966bb84f563ea7427745d5cb8914265b500cc4
Author: Marco Barisione <marco barisione org>
Date:   Wed Oct 27 12:09:24 2010 +0100

    vala: Generate Vala binding
    
    Vala bindings are generated from gobject-introspection data if
    --enable-vala-bindings is passed to the configure script.

 .gitignore                                         |    2 +
 Makefile.am                                        |    6 +++
 configure.ac                                       |   32 ++++++++++++++++++
 libsocialweb-client/Makefile.am                    |   26 ++++++++++++++-
 .../libsocialweb-client-hack-for-vala.h.footer.in  |    4 ++
 .../libsocialweb-client-hack-for-vala.h.header.in  |   30 +++++++++++++++++
 vala/Makefile.am                                   |   34 ++++++++++++++++++++
 vala/libsocialweb-client.deps                      |    2 +
 8 files changed, 134 insertions(+), 2 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index f0f9b37..79e3be1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,12 +25,14 @@ src/libsocialweb-core
 libsocialweb-keystore/test-suite
 libsocialweb/sw-enum-types.[ch]
 libsocialweb/stamp-enum-types
+libsocialweb-client/libsocialweb-client-hack-for-vala.h
 tests/test-online
 tests/test-client-online
 tests/test-download
 tests/test-download-async
 tests/test-upload
 interfaces/*-ginterface.[ch]
+vala/libsocialweb-client.vapi
 *-bindings.h
 *-marshals.[ch]
 *.gir
diff --git a/Makefile.am b/Makefile.am
index f0ad05b..31934a5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,12 @@ ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = interfaces libsocialweb libsocialweb-keyfob libsocialweb-keystore libsocialweb-client src services examples tests tools po docs
 
+if HAVE_INTROSPECTION
+if HAVE_VALA
+SUBDIRS += vala
+endif
+endif
+
 pkgconfig_DATA = libsocialweb-client.pc libsocialweb-module.pc libsocialweb-keyfob.pc libsocialweb-keystore.pc
 pkgconfigdir   = $(libdir)/pkgconfig
 
diff --git a/configure.ac b/configure.ac
index 60de2cf..e4dbb4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -141,6 +141,37 @@ servicesdatadir='${datadir}'/libsocialweb/services
 AC_SUBST(servicesdatadir)
 
 
+AC_ARG_ENABLE(vala-bindings,
+  AC_HELP_STRING([--enable-vala-bindings],
+                 [build the EXPERIMENTAL Vala bindings]),
+                  enable_vala_bindings=$enableval,
+                  enable_vala_bindings=no )
+
+if test x$enable_vala_bindings = xyes; then
+  if test "x$INTROSPECTION_SCANNER" = x; then
+    AC_MSG_ERROR([GObject-Introspection must be enabled for Vala bindings])
+  fi
+
+  AM_PROG_VALAC([0.10.0])
+  have_vala=yes
+
+  AC_PATH_PROG(VALAC, valac, valac)
+  AC_SUBST(VALAC)
+  AC_SUBST(VALAFLAGS)
+
+  AC_PATH_PROG([VAPIGEN], [vapigen], [false])
+
+  if test "x$VAPIGEN" = "xfalse"; then
+    AC_MSG_ERROR([vapigen not found. Was vala compiled with --enable-vapigen?])
+  fi
+
+  AC_SUBST(VAPIGEN)
+fi
+
+AM_CONDITIONAL([HAVE_VALA], [test "x$have_vala" = "xyes"])
+AC_SUBST(HAVE_VALA)
+
+
 dnl === Coverage report =======================================================
 AC_PATH_PROG([GCOV], [lcov], [enable_gcov=no])
 
@@ -199,4 +230,5 @@ AC_OUTPUT([
         libsocialweb-module.pc
         libsocialweb-keyfob.pc
         libsocialweb-keystore.pc
+        vala/Makefile
 ])
diff --git a/libsocialweb-client/Makefile.am b/libsocialweb-client/Makefile.am
index c0c76d1..4634976 100644
--- a/libsocialweb-client/Makefile.am
+++ b/libsocialweb-client/Makefile.am
@@ -6,9 +6,10 @@ libsocialweb_client_ladir = $(includedir)/libsocialweb/libsocialweb-client
 libsocialweb_client_la_CFLAGS = -I$(top_srcdir) $(DBUS_GLIB_CFLAGS) $(GIO_CFLAGS) -DDATADIR="\"$(datadir)\""
 libsocialweb_client_la_LIBADD = $(DBUS_GLIB_LIBS) $(GIO_LIBS) $(top_builddir)/interfaces/libsocialweb-bindings.la
 libsocialweb_client_la_LDFLAGS = -version-info $(LIBSOCIALWEB_CLIENT_CURRENT):$(LIBSOCIALWEB_CLIENT_REVISION):$(LIBSOCIALWEB_CLIENT_AGE)
-libsocialweb_client_la_HEADERS = sw-client.h \
+HANDWRITTED_H_SOURCES = sw-client.h \
 			      sw-item.h sw-client-service.h \
 			      sw-client-lastfm.h sw-client-item-view.h
+libsocialweb_client_la_HEADERS = $(HANDWRITTED_H_SOURCES)
 HANDWRITTED_C_SOURCES = sw-client.c \
 			      sw-item.c sw-client-service.c \
 			      sw-client-lastfm.c \
@@ -21,8 +22,25 @@ libsocialweb_client_la_SOURCES = $(HANDWRITTED_C_SOURCES) \
 
 if HAVE_INTROSPECTION
 
+if HAVE_VALA
+
+libsocialweb_client_la_HEADERS += libsocialweb-client-hack-for-vala.h
+
+libsocialweb-client-hack-for-vala.h: $(HANDWRITTED_H_SOURCES) \
+    libsocialweb-client-hack-for-vala.h.header.in \
+    libsocialweb-client-hack-for-vala.h.footer.in
+	$(AM_V_GEN)( \
+	    cat libsocialweb-client-hack-for-vala.h.header.in; \
+	    for include in $(HANDWRITTED_H_SOURCES); do \
+		echo "#include <libsocialweb-client/$$include>"; \
+	    done; \
+	    cat libsocialweb-client-hack-for-vala.h.footer.in \
+	) > $@
+
+endif # if HAVE_VALA
+
 INTROSPECTION_FILES = $(HANDWRITTED_C_SOURCES) \
-		      $(libsocialweb_client_la_HEADERS)
+		      $(HANDWRITTED_H_SOURCES)
 
 SocialWebClient-0.25.gir: $(INTROSPECTION_SCANNER) \
 		$(INTROSPECTION_FILES) \
@@ -62,3 +80,7 @@ CLEANFILES += \
     $(typelibs_DATA)
 
 endif # if HAVE_INTROSPECTION
+
+EXTRA_DIST = \
+	     libsocialweb-client-hack-for-vala.h.header.in \
+	     libsocialweb-client-hack-for-vala.h.footer.in
diff --git a/libsocialweb-client/libsocialweb-client-hack-for-vala.h.footer.in b/libsocialweb-client/libsocialweb-client-hack-for-vala.h.footer.in
new file mode 100644
index 0000000..774f5f4
--- /dev/null
+++ b/libsocialweb-client/libsocialweb-client-hack-for-vala.h.footer.in
@@ -0,0 +1,4 @@
+
+#undef IN_VALA_INCLUDE
+
+#endif /* _SW_CLIENT_HACK_FOR_VALA */
diff --git a/libsocialweb-client/libsocialweb-client-hack-for-vala.h.header.in b/libsocialweb-client/libsocialweb-client-hack-for-vala.h.header.in
new file mode 100644
index 0000000..34a2394
--- /dev/null
+++ b/libsocialweb-client/libsocialweb-client-hack-for-vala.h.header.in
@@ -0,0 +1,30 @@
+/*
+ * libsocialweb - social data store
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _SW_CLIENT_HACK_FOR_VALA
+#define _SW_CLIENT_HACK_FOR_VALA
+
+/* When you generate a .gir file the information about the header where
+ * definitions come from is lost, so when you generate a .vapi file there
+ * is no way to know which header to include.
+ * This autogenerated header file is used as single include file for
+ * libsocialweb-client and is supposed to be used only by Vala.
+ */
+
+#define IN_VALA_INCLUDE
+
diff --git a/vala/Makefile.am b/vala/Makefile.am
new file mode 100644
index 0000000..a417d6c
--- /dev/null
+++ b/vala/Makefile.am
@@ -0,0 +1,34 @@
+vapidir = $(datarootdir)/vala/vapi
+vapi_DATA = \
+	libsocialweb-client.vapi \
+	$(NULL)
+dist_vapi_DATA = \
+	libsocialweb-client.deps \
+	$(NULL)
+
+BUILT_SOURCES = \
+	$(vapi_DATA) \
+	$(NULL)
+
+pkgconfigdir = ${libdir}/pkgconfig
+
+libsocialweb-client.vapi: $(top_builddir)/libsocialweb-client/SocialWebClient-0.25.gir
+	$(VAPIGEN_V)$(VAPIGEN) \
+		--library libsocialweb-client \
+		--pkg gio-2.0 \
+		$< \
+		$(NULL)
+	@mv $@ libsocialweb-client.vapi.tmp
+	$(AM_V_GEN)sed -e \
+		's/SocialWebClient-0.25.h/libsocialweb-client\/libsocialweb-client-hack-for-vala.h/' \
+		< libsocialweb-client.vapi.tmp > $@
+	@rm libsocialweb-client.vapi.tmp
+
+CLEANFILES = \
+	$(BUILT_SOURCES) \
+	$(NULL)
+
+# set up the verbosity rules to avoid some build noise
+VAPIGEN_V = $(VAPIGEN_V_$(V))
+VAPIGEN_V_ = $(VAPIGEN_V_$(AM_DEFAULT_VERBOSITY))
+VAPIGEN_V_0 = @echo "  VAPIG " $^;
diff --git a/vala/libsocialweb-client.deps b/vala/libsocialweb-client.deps
new file mode 100644
index 0000000..d4db059
--- /dev/null
+++ b/vala/libsocialweb-client.deps
@@ -0,0 +1,2 @@
+gobject-2.0
+gio-2.0



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