[gnome-builder/gnome-builder-3-18] build: generate .vapi from generated .gir



commit 347205b12cc6c506dcb3b5b9439458bf2ffe3b63
Author: Christian Hergert <christian hergert me>
Date:   Tue Sep 22 00:58:14 2015 -0700

    build: generate .vapi from generated .gir
    
    This is a pretty rough first step at getting vapi files generated from
    our gir output. Of course, this simply won't be enough. Vala doesn't seem
    to understand how interface properties work very well.

 build/autotools/vala.m4    |  135 ++++++++++++++++++++++++++++++++++++++++++++
 build/autotools/vapigen.m4 |  101 +++++++++++++++++++++++++++++++++
 configure.ac               |   25 ++------
 libide/Makefile.am         |   26 ++++++++-
 src/Makefile.am            |   27 +++++++++-
 5 files changed, 293 insertions(+), 21 deletions(-)
---
diff --git a/build/autotools/vala.m4 b/build/autotools/vala.m4
new file mode 100644
index 0000000..4393866
--- /dev/null
+++ b/build/autotools/vala.m4
@@ -0,0 +1,135 @@
+dnl vala.m4
+dnl
+dnl Copyright 2010 Marc-Andre Lureau
+dnl Copyright 2011 Rodney Dawes <dobey pwns gmail com>
+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
+
+# _VALA_CHECK_COMPILE_WITH_ARGS(ARGS, [ACTION-IF-TRUE],
+#   [ACTION-IF-FALSE])
+# --------------------------------------
+# Check that Vala compile with ARGS.
+#
+AC_DEFUN([_VALA_CHECK_COMPILE_WITH_ARGS],
+[AC_REQUIRE([AM_PROG_VALAC])[]dnl
+
+  cat <<_ACEOF >conftest.vala
+void main(){}
+_ACEOF
+
+  AS_IF([vala_error=`$VALAC $1 -q --cc="${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" -o conftest$ac_exeext 
conftest.vala 2>&1`],
+        [$2], [$3])
+])
+
+])# _VALA_CHECK_COMPILE_WITH_ARGS
+
+# VALA_CHECK_PACKAGES(PKGS, [ACTION-IF-FOUND],
+#   [ACTION-IF-NOT-FOUND])
+# --------------------------------------
+# Check that PKGS Vala bindings are installed and usable.
+#
+AC_DEFUN([VALA_CHECK_PACKAGES],
+[
+  unset vala_pkgs
+  unset vala_bindings
+  ac_save_ifs="$IFS"; unset IFS
+  for vala_pkg in $(echo "$1"); do
+      vala_pkgs="${vala_pkgs:+$vala_pkgs }--pkg $vala_pkg"
+      vala_bindings="${vala_bindings:+$vala_bindings }$vala_pkg"
+  done
+  IFS="$ac_save_ifs"
+  AC_MSG_CHECKING([for $vala_bindings vala bindings])
+  _VALA_CHECK_COMPILE_WITH_ARGS([$vala_pkgs],
+    [vala_pkg_exists=yes],
+    [vala_pkg_exists=no])
+
+AS_IF([test x${vala_pkg_exists} = xno],[
+  ifelse([$3], , [AC_MSG_ERROR([]dnl
+[Package requirements were not met: $1
+
+$vala_error
+
+Consider adjusting the XDG_DATA_DIRS environment variable if you
+installed bindings in a non-standard prefix.
+])],
+  [AC_MSG_RESULT([no])
+$3])],[
+  AC_MSG_RESULT([yes])
+  ifelse([$2], , :, [$2])[]dnl
+])
+
+])# VALA_CHECK_PACKAGES
+
+
+# Check for Vala bindings for a package, as well as the pkg-config
+# CFLAGS and LIBS for the package. The arguments here work the
+# same as those for PKG_CHECK_MODULES, which is called internally.
+# As a result, the _CFLAGS, _LIBS, and _VALAFLAGS variables will
+# all be declared, rather than only _VALAFLAGS.
+#
+# VALA_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+# --------------------------------------------------------------
+AC_DEFUN([VALA_CHECK_MODULES],
+[
+               AC_REQUIRE([AM_PROG_VALAC])dnl
+               AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+        AC_REQUIRE([_VALA_CHECK_COMPILE_WITH_ARGS])dnl
+               AC_ARG_VAR([$1][_VALAFLAGS], [Vala compiler flags for $1])dnl
+
+        VALA_MODULES="`echo $2 | sed -e 's/ [[=<>]]\+ [[0-9.]]\+//g'`"
+        for MODULE in $VALA_MODULES; do
+            $1[]_VALAFLAGS="$[]$1[]_VALAFLAGS --pkg $MODULE"
+        done
+
+        PKG_CHECK_MODULES([$1], [$2], [$3], [$4])
+
+        pkg_failed=no
+               AC_MSG_CHECKING([for $1 vala modules])
+
+        _VALA_CHECK_COMPILE_WITH_ARGS([$1][_VALAFLAGS],
+                                      [pkg_failed=yes],
+                                      [pkg_failed=no])
+
+               if test $pkg_failed = yes; then
+                  AC_MSG_RESULT([no])
+                  m4_default([$4], [AC_MSG_ERROR(
+                                                       [Package requirements ($2) were not met.])dnl
+                  ])
+               else
+                       AC_MSG_RESULT([yes])
+                       m4_default([$3], [:])
+               fi[]dnl
+])
+
+# Check whether the Vala API Generator exists in `PATH'. If it is found,
+# the variable VAPIGEN is set. Optionally a minimum release number of the
+# generator can be requested.
+#
+# VALA_PROG_VAPIGEN([MINIMUM-VERSION])
+# ------------------------------------
+AC_DEFUN([VALA_PROG_VAPIGEN],
+[AC_PATH_PROG([VAPIGEN], [vapigen], [])
+  AS_IF([test -z "$VAPIGEN"],
+    [AC_MSG_WARN([No Vala API Generator found. You will not be able to generate .vapi files.])],
+    [AS_IF([test -n "$1"],
+        [AC_MSG_CHECKING([$VAPIGEN is at least version $1])
+         am__vapigen_version=`$VAPIGEN --version | sed 's/Vala API Generator  *//'`
+         AS_VERSION_COMPARE([$1], ["$am__vapigen_version"],
+           [AC_MSG_RESULT([yes])],
+           [AC_MSG_RESULT([yes])],
+           [AC_MSG_RESULT([no])
+            AC_MSG_ERROR([Vala API Generator $1 not found.])])])])
+])
diff --git a/build/autotools/vapigen.m4 b/build/autotools/vapigen.m4
new file mode 100644
index 0000000..2c435e7
--- /dev/null
+++ b/build/autotools/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")
+])
diff --git a/configure.ac b/configure.ac
index 4212df3..a2d0f0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,13 +63,18 @@ dnl Check for Required Programs
 dnl ***********************************************************************
 AC_PROG_CC
 AM_PROG_CC_C_O
-AC_PROG_INSTALL
 AC_PROG_CXX
+AM_PROG_VALAC
+AC_PROG_INSTALL
 AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
 AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
 AC_PATH_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
 AC_HEADER_STDC
 PKG_PROG_PKG_CONFIG([0.22])
+GOBJECT_INTROSPECTION_CHECK([1.42.0])
+VAPIGEN_CHECK
+GLIB_GSETTINGS
+APPSTREAM_XML
 
 
 dnl ***********************************************************************
@@ -320,18 +325,6 @@ AC_C_CONST
 
 
 dnl ***********************************************************************
-dnl Desktop Settings Support
-dnl ***********************************************************************
-GLIB_GSETTINGS
-
-
-dnl ***********************************************************************
-dnl Setup Introspection
-dnl ***********************************************************************
-GOBJECT_INTROSPECTION_CHECK([1.42.0])
-
-
-dnl ***********************************************************************
 dnl Always build tests
 dnl ***********************************************************************
 AC_ARG_ENABLE([tests],
@@ -356,12 +349,6 @@ AM_CONDITIONAL(ENABLE_DOC_CROSS_REFERENCES, test x$enable_doc_cross_references !
 
 
 dnl ***********************************************************************
-dnl Rules for Generating AppStream Information
-dnl ***********************************************************************
-APPSTREAM_XML
-
-
-dnl ***********************************************************************
 dnl Setup Various Compiler Optimizations
 dnl ***********************************************************************
 AC_MSG_CHECKING([whether to enable optimized builds])
diff --git a/libide/Makefile.am b/libide/Makefile.am
index 80c4934..ca4e6ab 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -353,13 +353,13 @@ nodist_libide_1_0_la_SOURCES = \
        $(NULL)
 
 
+if HAVE_INTROSPECTION
 -include $(INTROSPECTION_MAKEFILE)
 
 INTROSPECTION_GIRS =
 INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all
 INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
 
-if HAVE_INTROSPECTION
 introspection_sources = \
        $(libide_1_0_la_public_sources) \
        $(NULL)
@@ -386,4 +386,28 @@ typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
 CLEANFILES += $(dist_gir_DATA) $(typelib_DATA)
 endif
 
+
+if ENABLE_VAPIGEN
+-include $(VAPIGEN_MAKEFILE)
+
+libide-1.0.vapi: Ide-1.0.gir
+
+VAPIGEN_VAPIS = libide-1.0.vapi
+
+libide_1_0_vapi_DEPS = gio-2.0 gtk+-3.0 gtksourceview-3.0 ggit-1.0 libpeas-1.0
+libide_1_0_vapi_METADATADIRS = $(srcdir)
+libide_1_0_vapi_FILES = Ide-1.0.gir
+
+libide-1.0.deps: Makefile
+       $(AM_V_GEN) echo $(libide_1_0_vapi_DEPS) | tr ' ' '\n' > $@
+
+vapidir = $(VAPIGEN_VAPIDIR)
+vapi_DATA = $(VAPIGEN_VAPIS) $(VAPIGEN_VAPIS:.vapi=.deps)
+
+EXTRA_DIST += Ide-1.0.metadata libide-1.0.deps
+
+DISTCLEANFILES += $(vapi_DATA)
+endif
+
+
 -include $(top_srcdir)/git.mk
diff --git a/src/Makefile.am b/src/Makefile.am
index d65c75e..9ebd0c9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -277,6 +277,7 @@ glib_resources_namespace = gb
 include $(top_srcdir)/build/autotools/Makefile.am.gresources
 
 
+if HAVE_INTROSPECTION
 -include $(INTROSPECTION_MAKEFILE)
 
 INTROSPECTION_GIRS =
@@ -285,7 +286,6 @@ INTROSPECTION_COMPILER_ARGS = \
        --includedir=$(srcdir) \
        --includedir=$(top_srcdir)/libide
 
-if HAVE_INTROSPECTION
 introspection_sources = \
        $(libgnome_builder_public_sources) \
        $(NULL)
@@ -316,4 +316,29 @@ typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
 CLEANFILES += $(dist_gir_DATA) $(typelib_DATA)
 endif
 
+
+if ENABLE_VAPIGEN
+-include $(VAPIGEN_MAKEFILE)
+
+gnome-builder-1.0.vapi: Builder-1.0.gir
+
+VAPIGEN_VAPIS = gnome-builder-1.0.vapi
+
+gnome_builder_1_0_vapi_DEPS = libide-1.0 gio-2.0 gtk+-3.0 gtksourceview-3.0
+gnome_builder_1_0_vapi_VAPIDIRS = $(top_builddir)/libide
+gnome_builder_1_0_vapi_METADATADIRS = $(srcdir)
+gnome_builder_1_0_vapi_FILES = Builder-1.0.gir
+
+gnome-builder-1.0.deps: Makefile
+       $(AM_V_GEN) echo $(gnome_builder_1_0_vapi_DEPS) | tr ' ' '\n' > $@
+
+vapidir = $(VAPIGEN_VAPIDIR)
+vapi_DATA = $(VAPIGEN_VAPIS) $(VAPIGEN_VAPIS:.vapi=.deps)
+
+EXTRA_DIST += Builder-1.0.metadata gnome-builder-1.0.deps
+
+DISTCLEANFILES += $(vapi_DATA)
+endif
+
+
 -include $(top_srcdir)/git.mk


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