From fd6572bacebfcd040e541971d5cb911438ac7999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Sat, 5 May 2018 23:06:02 +0100 Subject: [PATCH] vala: Add Vala bindings --- configure.ac | 2 + m4/vapigen.m4 | 101 +++++++++++++++++++++++ src/polkit/Makefile.am | 12 +++ src/polkit/Polkit-1.0.metadata | 20 +++++ src/polkit/polkit-gobject-1.deps | 1 + src/polkitagent/Makefile.am | 12 +++ src/polkitagent/PolkitAgent-1.0.metadata | 1 + src/polkitagent/polkit-agent-1.deps | 2 + 8 files changed, 151 insertions(+) create mode 100644 m4/vapigen.m4 create mode 100644 src/polkit/Polkit-1.0.metadata create mode 100644 src/polkit/polkit-gobject-1.deps create mode 100644 src/polkitagent/PolkitAgent-1.0.metadata create mode 100644 src/polkitagent/polkit-agent-1.deps diff --git a/configure.ac b/configure.ac index a813e6b..6e6b9c9 100644 --- a/configure.ac +++ b/configure.ac @@ -507,6 +507,7 @@ case "$host_os" in esac GOBJECT_INTROSPECTION_CHECK([0.6.2]) +VAPIGEN_CHECK() AC_ARG_ENABLE([examples], AS_HELP_STRING([--enable-examples], [Build the example programs]),, @@ -573,6 +574,7 @@ echo " cppflags: ${CPPFLAGS} xsltproc: ${XSLTPROC} introspection: ${found_introspection} + vala: ${enable_vala} Distribution/OS: ${with_os_type} Authentication framework: ${POLKIT_AUTHFW} 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") +]) diff --git a/src/polkit/Makefile.am b/src/polkit/Makefile.am index ca36355..2111dc1 100644 --- a/src/polkit/Makefile.am +++ b/src/polkit/Makefile.am @@ -132,6 +132,18 @@ endif # HAVE_INTROSPECTION EXTRA_DIST = polkitenumtypes.h.template polkitenumtypes.c.template CLEANFILES = $(gir_DATA) $(typelibs_DATA) +if ENABLE_VAPIGEN +polkit-gobject-1.vapi: Polkit-1.0.gir polkit-gobject-1.deps Polkit-1.0.metadata + $(VAPIGEN) --metadatadir=$(top_srcdir)/src/polkit --pkg gio-2.0 --library=polkit-gobject-1 $^ + +vapidir=$(VAPIDIR) +vapi_DATA=polkit-gobject-1.vapi polkit-gobject-1.deps + +CLEANFILES += polkit-gobject-1.vapi +endif # ENABLE_VAPIGEN + +EXTRA_DIST += polkit-gobject-1.deps Polkit-1.0.metadata + dist-hook : (for i in $(polkit_built_sources) $(BUILT_SOURCES) ; do rm -f $(distdir)/$$i ; done) diff --git a/src/polkit/Polkit-1.0.metadata b/src/polkit/Polkit-1.0.metadata new file mode 100644 index 0000000..dd3c52c --- /dev/null +++ b/src/polkit/Polkit-1.0.metadata @@ -0,0 +1,20 @@ +*.*.cancellable#parameter nullable default=null + +SystemBusName + .new symbol_type="constructor" +UnixGroup + .new symbol_type="constructor" + .new_for_name symbol_type="constructor" +UnixNetgroup + .new symbol_type="constructor" +UnixProcess + .new symbol_type="constructor" + .new_for_owner symbol_type="constructor" + .new_full symbol_type="constructor" +UnixSession + .new symbol_type="constructor" + .new_for_process symbol_type="constructor" + .new_for_process_sync symbol_type="constructor" +UnixUser + .new symbol_type="constructor" + .new_for_name symbol_type="constructor" diff --git a/src/polkit/polkit-gobject-1.deps b/src/polkit/polkit-gobject-1.deps new file mode 100644 index 0000000..cd10dfd --- /dev/null +++ b/src/polkit/polkit-gobject-1.deps @@ -0,0 +1 @@ +gio-2.0 diff --git a/src/polkitagent/Makefile.am b/src/polkitagent/Makefile.am index 49720db..21eb109 100644 --- a/src/polkitagent/Makefile.am +++ b/src/polkitagent/Makefile.am @@ -153,6 +153,18 @@ install-data-hook: EXTRA_DIST = polkitagentmarshal.list polkitagentenumtypes.h.template polkitagentenumtypes.c.template CLEANFILES = $(gir_DATA) $(typelibs_DATA) +if ENABLE_VAPIGEN +polkit-agent-1.vapi: PolkitAgent-1.0.gir polkit-agent-1.deps PolkitAgent-1.0.metadata + $(VAPIGEN) --metadatadir=$(top_srcdir)/src/polkit --pkg gio-2.0 --library=polkit-agent-1 $^ + +vapidir=$(VAPIDIR) +vapi_DATA=polkit-agent-1.vapi polkit-agent-1.deps + +CLEANFILES += polkit-agent-1.vapi +endif # ENABLE_VAPIGEN + +EXTRA_DIST += polkit-agent-1.deps PolkitAgent-1.0.metadata + dist-hook : (for i in $(marshal_built_sources) $(BUILT_SOURCES) ; do rm -f $(distdir)/$$i ; done) diff --git a/src/polkitagent/PolkitAgent-1.0.metadata b/src/polkitagent/PolkitAgent-1.0.metadata new file mode 100644 index 0000000..8dc3e48 --- /dev/null +++ b/src/polkitagent/PolkitAgent-1.0.metadata @@ -0,0 +1 @@ +*.*.cancellable#parameter nullable default=null diff --git a/src/polkitagent/polkit-agent-1.deps b/src/polkitagent/polkit-agent-1.deps new file mode 100644 index 0000000..e092d1c --- /dev/null +++ b/src/polkitagent/polkit-agent-1.deps @@ -0,0 +1,2 @@ +gio-2.0 +polkit-gobject-1 -- 2.17.0