[gtksourceview/wip/vapi] Add Vala support



commit 978e3f7efcb34a63662ec47a6fe02bd2696d0a1d
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Jul 14 14:30:04 2014 +0200

    Add Vala support
    
    It is better to generate the vapi upstream (in gtksourceview itself)
    instead of generating it in the vala module. When new API is added, the
    vapi is directly updated.

 configure.ac                         |    5 +-
 gtksourceview/GtkSource-3.0.metadata |   16 +++++
 gtksourceview/Makefile.am            |   26 ++++++++-
 m4/vapigen.m4                        |  101 ++++++++++++++++++++++++++++++++++
 4 files changed, 145 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 93d3c88..a5747cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -167,6 +167,9 @@ GOBJECT_INTROSPECTION_CHECK([0.9.0])
 # Code coverage
 GNOME_CODE_COVERAGE
 
+# Vala
+VAPIGEN_CHECK
+
 # test-widget uses this to find lang files and gtksourcebuffer.c
 ABS_TOP_SRCDIR=`cd $srcdir && pwd`
 AC_SUBST(ABS_TOP_SRCDIR)
@@ -192,7 +195,6 @@ tests/Makefile
 
 AC_OUTPUT
 
-
 echo "
 
 Configuration:
@@ -202,4 +204,5 @@ Configuration:
        Completion Providers:   ${enable_providers}
        Glade Catalog:          ${glade_catalog}
        GObject introspection:  ${found_introspection}
+       Vala support:           ${enable_vala}
 "
diff --git a/gtksourceview/GtkSource-3.0.metadata b/gtksourceview/GtkSource-3.0.metadata
new file mode 100644
index 0000000..a02f4e0
--- /dev/null
+++ b/gtksourceview/GtkSource-3.0.metadata
@@ -0,0 +1,16 @@
+* name="(.+)/Source\\1"
+utils_* name="utils_(.+)" parent="Gtk.SourceUtils"
+GtkSource name="Gtk" cprefix="Gtk" lower_case_cprefix="gtk_"
+Completion
+        .show#method name="start"
+CompletionProvider
+        .*#virtual_method virtual
+        .get_icon nullable
+        .get_info_widget nullable
+CompletionProposal
+        .equal#virtual_method virtual
+        .get_icon#virtual_method virtual
+        .hash#virtual_method virtual
+SearchContext
+        .get_regex_error nullable
+        .regex_error type="GLib.Error?"
diff --git a/gtksourceview/Makefile.am b/gtksourceview/Makefile.am
index e14d736..c6d838d 100644
--- a/gtksourceview/Makefile.am
+++ b/gtksourceview/Makefile.am
@@ -214,7 +214,8 @@ stamp-gtksourceview-typebuiltins.h: Makefile.am $(libgtksourceview_headers)
 
 EXTRA_DIST =                           \
        gtksourceview.gresource.xml     \
-       gtksourcecompletion.ui
+       gtksourcecompletion.ui          \
+       GtkSource-3.0.metadata
 
 CLEANFILES =                                   \
        $(BUILT_SOURCES)                        \
@@ -257,6 +258,27 @@ typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
 CLEANFILES +=                  \
        $(gir_DATA)     \
        $(typelib_DATA)
-endif
+endif # HAVE_INTROSPECTION
+
+if ENABLE_VAPIGEN
+include $(VAPIGEN_MAKEFILE)
+
+gtksourceview-3.0.vapi: GtkSource-3.0.gir
+
+VAPIGEN_VAPIS = gtksourceview-3.0.vapi
+
+gtksourceview_3_0_vapi_DEPS = gtk+-3.0
+gtksourceview_3_0_vapi_METADATADIRS = $(srcdir)
+gtksourceview_3_0_vapi_FILES = GtkSource-3.0.gir
+
+vapidir = $(datadir)/vala/vapi
+vapi_DATA = $(VAPIGEN_VAPIS) gtksourceview-3.0.deps
+
+gtksourceview-3.0.deps:
+       $(AM_V_GEN) echo $(gtksourceview_3_0_vapi_DEPS) | tr ' ' '\n' > $@
+
+CLEANFILES += $(VAPIGEN_VAPIS) gtksourceview-3.0.deps
+
+endif # ENABLE_VAPIGEN
 
 -include $(top_srcdir)/git.mk
diff --git a/m4/vapigen.m4 b/m4/vapigen.m4
new file mode 100644
index 0000000..2c435e7
--- /dev/null
+++ b/m4/vapigen.m4
@@ -0,0 +1,101 @@
+dnl vapigen.m4
+dnl
+dnl Copyright 2012 Evan Nemerson
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+
+# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND_INTROSPECTION], [DEFAULT])
+# --------------------------------------
+# Check vapigen existence and version
+#
+# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
+AC_DEFUN([VAPIGEN_CHECK],
+[
+  AS_IF([test "x$3" != "xyes"], [
+      m4_provide_if([GOBJECT_INTROSPECTION_CHECK], [], [
+          m4_provide_if([GOBJECT_INTROSPECTION_REQUIRE], [], [
+              AC_MSG_ERROR([[You must call GOBJECT_INTROSPECTION_CHECK or GOBJECT_INTROSPECTION_REQUIRE 
before using VAPIGEN_CHECK unless using the FOUND_INTROSPECTION argument is "yes"]])
+            ])
+        ])
+    ])
+
+  AC_ARG_ENABLE([vala],
+    [AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings 
@<:@default=]ifelse($4,,auto,$4)[@:>@])],,[
+      AS_IF([test "x$4" = "x"], [
+          enable_vala=auto
+        ], [
+          enable_vala=$4
+        ])
+    ])
+
+  AS_CASE([$enable_vala], [no], [enable_vala=no],
+      [yes], [
+        AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+            AC_MSG_ERROR([Vala bindings require GObject Introspection])
+          ])
+      ], [auto], [
+        AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+            enable_vala=no
+          ])
+      ], [
+        AC_MSG_ERROR([Invalid argument passed to --enable-vala, should be one of @<:@no/auto/yes@:>@])
+      ])
+
+  AS_IF([test "x$2" = "x"], [
+      vapigen_pkg_name=vapigen
+    ], [
+      vapigen_pkg_name=vapigen-$2
+    ])
+  AS_IF([test "x$1" = "x"], [
+      vapigen_pkg="$vapigen_pkg_name"
+    ], [
+      vapigen_pkg="$vapigen_pkg_name >= $1"
+    ])
+
+  PKG_PROG_PKG_CONFIG
+
+  PKG_CHECK_EXISTS([$vapigen_pkg], [
+      AS_IF([test "$enable_vala" = "auto"], [
+          enable_vala=yes
+        ])
+    ], [
+      AS_CASE([$enable_vala], [yes], [
+          AC_MSG_ERROR([$vapigen_pkg not found])
+        ], [auto], [
+          enable_vala=no
+        ])
+    ])
+
+  AC_MSG_CHECKING([for vapigen])
+
+  AS_CASE([$enable_vala],
+    [yes], [
+      VAPIGEN=`$PKG_CONFIG --variable=vapigen $vapigen_pkg_name`
+      VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir $vapigen_pkg_name`/vala/Makefile.vapigen
+      AS_IF([test "x$2" = "x"], [
+          VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir $vapigen_pkg_name`
+        ], [
+          VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned $vapigen_pkg_name`
+        ])
+    ])
+
+  AC_MSG_RESULT([$enable_vala])
+
+  AC_SUBST([VAPIGEN])
+  AC_SUBST([VAPIGEN_VAPIDIR])
+  AC_SUBST([VAPIGEN_MAKEFILE])
+
+  AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$enable_vala" = "xyes")
+])


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