[grilo] vala: modernize bindings generation



commit 689bf702cb3d264cca9b1a689d6237f611ad3407
Author: Marc-André Lureau <marcandre lureau gmail com>
Date:   Sat Nov 15 19:36:47 2014 +0100

    vala: modernize bindings generation
    
    Use GIR and modern autotools helpers.  This binding allows to build
    simple plugin, it hasn't been tested for applications.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740186

 bindings/Makefile.am                             |    6 +--
 bindings/vala/Grl-0.2.metadata                   |   15 ++++
 bindings/vala/GrlNet-0.2.metadata                |    3 +
 bindings/vala/Makefile.am                        |   83 +++++-----------------
 bindings/vala/grilo-0.2-custom.vala              |   17 +----
 bindings/vala/grilo-0.2.metadata                 |   58 ---------------
 bindings/vala/grilo-net-0.2.metadata             |    6 --
 bindings/vala/grilo-net-uninstalled.files.in     |    2 -
 bindings/vala/grilo-net-uninstalled.namespace.in |    1 -
 bindings/vala/grilo-uninstalled.defines          |    1 -
 bindings/vala/grilo-uninstalled.files.in         |   13 ----
 bindings/vala/grilo-uninstalled.namespace.in     |    1 -
 configure.ac                                     |   49 ++-----------
 13 files changed, 44 insertions(+), 211 deletions(-)
---
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
index 50c92aa..86de8f0 100644
--- a/bindings/Makefile.am
+++ b/bindings/Makefile.am
@@ -1,7 +1,3 @@
-SUBDIRS =
-
-if HAVE_VALA
-SUBDIRS += vala
-endif
+SUBDIRS = vala
 
 -include $(top_srcdir)/git.mk
diff --git a/bindings/vala/Grl-0.2.metadata b/bindings/vala/Grl-0.2.metadata
new file mode 100644
index 0000000..c59ffd8
--- /dev/null
+++ b/bindings/vala/Grl-0.2.metadata
@@ -0,0 +1,15 @@
+// vapigen has issues with the callbacks
+PluginDescriptor skip=true
+
+Source.browse#method name="do_browse"
+Source.query#method name="do_query"
+Source.remove#method name="do_remove"
+Source.resolve#method name="do_resolve"
+Source.search#method name="do_search"
+Source.store#method name="do_store"
+Source.store_metadata#method name="do_store_metadata"
+Source.supported_operations#method name="get_supported_operations"
+*.callback delegate_target_cname="user_data"
+
+
+SourceStoreSpec.user_data type="string"
\ No newline at end of file
diff --git a/bindings/vala/GrlNet-0.2.metadata b/bindings/vala/GrlNet-0.2.metadata
new file mode 100644
index 0000000..73465ad
--- /dev/null
+++ b/bindings/vala/GrlNet-0.2.metadata
@@ -0,0 +1,3 @@
+Wc.request_with_headers_hash_async finish_name="grl_net_wc_request_finish"
+Wc.request_with_headers_async skip=false
+Wc.request_with_headers_async finish_name="grl_net_wc_request_finish"
diff --git a/bindings/vala/Makefile.am b/bindings/vala/Makefile.am
index 8c0fffe..77947ac 100644
--- a/bindings/vala/Makefile.am
+++ b/bindings/vala/Makefile.am
@@ -1,78 +1,29 @@
-# This Makefile is a tad convoluted. I've tried to make it so that the vapi
-# can be built at the same time as the library in the hope that this will make
-# it easier to keep it up-to-date.
-#
-# The vapi is generated in 2 steps:
-#
-#   vala-gen-introspect looks at headers and libs and generates a gidl for the
-#   library. It takes a .files file containing paths to these. It also takes a
-#   .namespace file containing the Vala namespace corresponding to this
-#   library. Both these files are expected to be in the directory where you run
-#   vala-gen-introspect.
-#
-#   vapigen takes the gidl, a .deps file containing the list of libs needed
-#   to link this library, and a .metadata file containing annotations to the
-#   gidl (e.g. foo() is the free function for object X).
-#
-# vala-gen-introspect runs with the -uninstalled .pc file. The .files is
-# generated so that it has links to the headers and libraries from the source
-# and build trees. The .namespace file is generated, though it doesn't need
-# to be, so that it exists in the build tree where vala-gen-introspect is run
-# (because this may not be the same as the source tree). Since we're working
-# with the -uninstalled files, and vala-gen-introspect assumes filenames are
-# named as <package>.<extension>, all the associated file names have an
-# -uninstalled suffix.
-#
-# Running vapigen is simpler. It generates a the .vapi file using the gidl
-# file from vala-gen-introspect. Since we want the final files to be in the
-# form <libname>-<version>.*, we use the same convention for naming the files
-# associated with this step (contrast with the -uninstalled suffix for the
-# vala-gen-introspect step). The only file implicitly used by vapigen is the
-# .deps file, so to make the build independent of a split source/build tree,
-# I've put the deps on the vapigen command-line (it's redundant, but helps
-# with distcheck).
-#
+EXTRA_DIST =
 
-targets = grilo- GRL_MAJORMINOR@
+if ENABLE_VAPIGEN
+-include $(VAPIGEN_MAKEFILE)
 
-if BUILD_GRILO_NET
-targets += grilo-net- GRL_MAJORMINOR@
-endif
-
-targets_u = $(foreach target,$(targets),$(subst @GRL_MAJORMINOR@,uninstalled,$(target)))
+VAPIGEN_VAPIS = grilo- GRL_MAJORMINOR@.vapi grilo-net- GRL_MAJORMINOR@.vapi
 
-# "source" files for vala-gen-introspect
-filesfiles_src = $(foreach target,$(targets_u),$(target).files.in)
-filesfiles = $(foreach target,$(targets_u),$(target).files)
-nsfiles_src = $(foreach target,$(targets_u),$(target).namespace.in)
-nsfiles = $(foreach target,$(targets_u),$(target).namespace)
+grilo- GRL_MAJORMINOR@.vapi: $(top_builddir)/src/Grl- GRL_MAJORMINOR@.gir grilo- GRL_MAJORMINOR@-custom.vala 
grilo- GRL_MAJORMINOR@.deps Grl- GRL_MAJORMINOR@.metadata
 
-# "source" files for vapigen
-depsfiles = $(foreach target,$(targets),$(target).deps)
-gifiles = $(foreach target,$(targets),$(target).gi)
-metadatafiles = $(foreach target,$(targets),$(target).metadata)
+grilo_ GRL_MAJORMINOR_NORM@_vapi_DEPS =
+grilo_ GRL_MAJORMINOR_NORM@_vapi_METADATADIRS = $(srcdir)
+grilo_ GRL_MAJORMINOR_NORM@_vapi_FILES = grilo- GRL_MAJORMINOR@-custom.vala $(top_builddir)/src/Grl- 
GRL_MAJORMINOR@.gir
 
-vapidir = $(datadir)/vala/vapi
+EXTRA_DIST += grilo- GRL_MAJORMINOR@.metadata grilo- GRL_MAJORMINOR@.deps grilo- GRL_MAJORMINOR@-custom.vala
 
-if HAVE_VALA
-vapifiles = $(foreach target,$(targets),$(target).vapi)
-vapi_DATA = $(depsfiles) $(vapifiles)
-endif
+grilo-net- GRL_MAJORMINOR@.vapi:  $(top_builddir)/libs/net/GrlNet- GRL_MAJORMINOR@.gir grilo-net- 
GRL_MAJORMINOR@-custom.vala grilo-net- GRL_MAJORMINOR@.deps GrlNet- GRL_MAJORMINOR@.metadata
 
-%- GRL_MAJORMINOR@.gi: %-uninstalled.files %-uninstalled.namespace
-       PKG_CONFIG_PATH=$(top_builddir)/:${PKG_CONFIG_PATH} \
-               $(VALA_GEN_INTROSPECT) $*-uninstalled .
-       @mv $*-uninstalled.gi $*- GRL_MAJORMINOR@.gi
+grilo_net_ GRL_MAJORMINOR_NORM@_vapi_DEPS =
+grilo_net_ GRL_MAJORMINOR_NORM@_vapi_METADATADIRS = $(srcdir)
+grilo_net_ GRL_MAJORMINOR_NORM@_vapi_FILES = grilo-net- GRL_MAJORMINOR@-custom.vala 
$(top_builddir)/libs/net/GrlNet- GRL_MAJORMINOR@.gir
 
-%.vapi: %.gi %.metadata %-custom.vala
-       $(VAPIGEN) --library $* \
-               $(top_srcdir)/bindings/vala/$*.metadata $*.gi \
-               $*-custom.vala
+EXTRA_DIST += GrlNet- GRL_MAJORMINOR@.metadata grilo-net- GRL_MAJORMINOR@.deps grilo-net- 
GRL_MAJORMINOR@-custom.vala
 
-all: $(vapifiles)
+vapidir = $(datadir)/vala/vapi
+vapi_DATA = $(VAPIGEN_VAPIS) $(VAPIGEN_VAPIS:.vapi=.deps)
 
-EXTRA_DIST = $(depsfiles) $(filesfiles_src) $(nsfiles_src) $(metadatafiles) $(vapifiles)
-CLEANFILES = $(gifiles)
-DISTCLEANFILES = $(vapifiles) $(filesfiles) $(nsfiles)
+endif
 
 -include $(top_srcdir)/git.mk
diff --git a/bindings/vala/grilo-0.2-custom.vala b/bindings/vala/grilo-0.2-custom.vala
index dea3824..a27e78a 100644
--- a/bindings/vala/grilo-0.2-custom.vala
+++ b/bindings/vala/grilo-0.2-custom.vala
@@ -1,19 +1,6 @@
 namespace Grl {
-       [CCode (instance_pos = 3.1)]
-       public delegate void SourceResolveCb (Grl.Source source, uint operation_id, Grl.Media? media, 
GLib.Error error);
-       [CCode (instance_pos = 2.1)]
-       public delegate void SourceRemoveCb (Grl.Source source, Grl.Media? media, GLib.Error error);
-       [CCode (instance_pos = 4.1)]
-       public delegate void SourceResultCb (Grl.Source source, uint operation_id, Grl.Media? media, uint 
remaining, GLib.Error? error);
-       [CCode (instance_pos = 3.1)]
-       public delegate void SourceStoreCb (Grl.Source source, Grl.MediaBox? parent, Grl.Media? media, 
GLib.Error? error);
 
-       [SimpleType]
-       public struct KeyID {
-       }
-
-       [Compact]
-       public class MetadataKey {
+       public struct MetadataKey {
                [CCode (cname ="GRL_METADATA_KEY_INVALID")]
                public static Grl.KeyID INVALID;
                [CCode (cname ="GRL_METADATA_KEY_ALBUM")]
@@ -119,6 +106,6 @@ namespace Grl {
                [CCode (cname ="GRL_METADATA_KEY_MB_ARTIST_ID")]
                public static Grl.KeyID MB_ARTIST_ID;
 
-               public static unowned GLib.List list_new (Grl.KeyID p, ...);
+               public static GLib.List list_new (Grl.KeyID p, ...);
        }
 }
diff --git a/configure.ac b/configure.ac
index 37b6b9a..8024971 100644
--- a/configure.ac
+++ b/configure.ac
@@ -238,45 +238,6 @@ AC_ARG_ENABLE([tests],
 AM_CONDITIONAL(ENABLE_TESTS, test "enable_tests" = "xyes")
 
 # ----------------------------------------------------------
-# VALA BINDINGS
-# ----------------------------------------------------------
-
-AC_PATH_PROG([VALAC], [valac])
-AC_PATH_PROG([VALA_GEN_INTROSPECT], [vala-gen-introspect])
-AC_PATH_PROG([VAPIGEN], [vapigen])
-
-AC_ARG_ENABLE([vala],
-        AS_HELP_STRING([--enable-vala],
-                [Enable Vala plugin support (default: auto)]),
-        [
-                case "$enableval" in
-                     yes)
-                        if test "x$VALAC" = "x"; then
-                           AC_MSG_ERROR([valac not found, install it or use --disable-vala])
-                        fi
-                        if test "x$VALA_GEN_INTROSPECT" = "x"; then
-                           AC_MSG_ERROR([vala-gen-introspect not found, install it or use --disable-vala])
-                        fi
-                        if test "x$VAPIGEN" = "x"; then
-                           AC_MSG_ERROR([vapigen not found, install it or use --disable-vala])
-                        fi
-                        ;;
-                     no)
-                        enable_vala=no
-                        ;;
-                esac
-        ],
-        [
-                if test "x$VALAC" != "x" -a "x$VALA_GEN_INTROSPECT" != "x" -a "x$VAPIGEN" != "x"; then
-                   enable_vala=yes
-                else
-                   enable_vala=no
-                fi
-        ])
-
-AM_CONDITIONAL([HAVE_VALA], [test "x$enable_vala" = "xyes"])
-
-# ----------------------------------------------------------
 # GTK-DOC
 # ----------------------------------------------------------
 
@@ -289,6 +250,12 @@ GTK_DOC_CHECK([1.10],[--flavour no-tmpl])
 GOBJECT_INTROSPECTION_CHECK([0.9])
 
 # ----------------------------------------------------------
+# VALA BINDINGS
+# ----------------------------------------------------------
+
+VAPIGEN_CHECK([0.26])
+
+# ----------------------------------------------------------
 # GETTEXT/INTLTOOL
 # ----------------------------------------------------------
 
@@ -335,10 +302,6 @@ AC_CONFIG_FILES([
   tools/grilo-launch/Makefile
   bindings/Makefile
   bindings/vala/Makefile
-  bindings/vala/grilo-uninstalled.files
-  bindings/vala/grilo-uninstalled.namespace
-  bindings/vala/grilo-net-uninstalled.files
-  bindings/vala/grilo-net-uninstalled.namespace
   doc/Makefile
   doc/grilo/Makefile
   examples/Makefile


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