From 00d547fe765521e6e6b03c232ee00cd115960d2d Mon Sep 17 00:00:00 2001 From: Olivier Duchateau Date: Mon, 11 Feb 2019 19:28:05 +0100 Subject: [PATCH] Add support for GObject introspection and vala --- Makefile.am | 8 +++- configure.ac.in | 8 ++++ m4/introspection.m4 | 96 ++++++++++++++++++++++++++++++++++++++ m4/vapigen.m4 | 101 ++++++++++++++++++++++++++++++++++++++++ xfconf/Makefile.am | 50 ++++++++++++++++++++ xfconf/libxfconf-0.deps | 3 ++ xfconf/xfconf-channel.c | 1 + xfconf/xfconf.c | 2 +- xfconfd/xfconf-daemon.c | 4 +- 9 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 m4/introspection.m4 create mode 100644 m4/vapigen.m4 create mode 100644 xfconf/libxfconf-0.deps diff --git a/Makefile.am b/Makefile.am index 754067a..f0e0405 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,8 +29,12 @@ EXTRA_DIST = \ ChangeLog \ INSTALL \ NEWS \ - README + README \ + m4/introspection.m4 \ + m4/vapigen.m4 DISTCHECK_CONFIGURE_FLAGS = \ --enable-gtk-doc \ - --disable-perl-bindings + --disable-perl-bindings \ + --enable-introspection \ + --disable-vala diff --git a/configure.ac.in b/configure.ac.in index 18e66b5..04cf763 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -195,6 +195,12 @@ if test "x$ac_gsettings_backend"; then AC_SUBST(GIO_MODULE_DIR) fi +dnl check for GObject Introspection +GOBJECT_INTROSPECTION_CHECK([1.30.0]) + +dnl check for Vala support +VAPIGEN_CHECK() + dnl check for debugging support XDT_FEATURE_DEBUG([xfconf_default_debug]) dnl gtk-doc is broken @@ -268,6 +274,8 @@ echo echo "Build Configuration:" echo echo " * GSettings Backend: $ac_gsettings_backend" +echo " * GObject Introspection: $enable_introspection" +echo " * Vala support: $enable_vala" echo echo " * Debug: $enable_debug" echo diff --git a/m4/introspection.m4 b/m4/introspection.m4 new file mode 100644 index 0000000..aa7b3b4 --- /dev/null +++ b/m4/introspection.m4 @@ -0,0 +1,96 @@ +dnl -*- mode: autoconf -*- +dnl Copyright 2009 Johan Dahlin +dnl +dnl This file is free software; the author(s) gives unlimited +dnl permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl + +# serial 1 + +m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], +[ + AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([LT_INIT],[$0])dnl setup libtool first + + dnl enable/disable introspection + m4_if([$2], [require], + [dnl + enable_introspection=yes + ],[dnl + AC_ARG_ENABLE(introspection, + AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], + [Enable introspection for this build]),, + [enable_introspection=auto]) + ])dnl + + AC_MSG_CHECKING([for gobject-introspection]) + + dnl presence/version checking + AS_CASE([$enable_introspection], + [no], [dnl + found_introspection="no (disabled, use --enable-introspection to enable)" + ],dnl + [yes],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0],, + AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], + found_introspection=yes, + AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) + ],dnl + [auto],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) + dnl Canonicalize enable_introspection + enable_introspection=$found_introspection + ],dnl + [dnl + AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) + ])dnl + + AC_MSG_RESULT([$found_introspection]) + + INTROSPECTION_SCANNER= + INTROSPECTION_COMPILER= + INTROSPECTION_GENERATE= + INTROSPECTION_GIRDIR= + INTROSPECTION_TYPELIBDIR= + if test "x$found_introspection" = "xyes"; then + INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` + INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` + INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` + INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` + INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" + INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` + INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` + INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection + fi + AC_SUBST(INTROSPECTION_SCANNER) + AC_SUBST(INTROSPECTION_COMPILER) + AC_SUBST(INTROSPECTION_GENERATE) + AC_SUBST(INTROSPECTION_GIRDIR) + AC_SUBST(INTROSPECTION_TYPELIBDIR) + AC_SUBST(INTROSPECTION_CFLAGS) + AC_SUBST(INTROSPECTION_LIBS) + AC_SUBST(INTROSPECTION_MAKEFILE) + + AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") +]) + + +dnl Usage: +dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) + +AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) +]) + +dnl Usage: +dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) + + +AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) +]) 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/xfconf/Makefile.am b/xfconf/Makefile.am index 7cf962d..5ff56a2 100644 --- a/xfconf/Makefile.am +++ b/xfconf/Makefile.am @@ -59,6 +59,56 @@ EXTRA_DIST = \ # required for gtk-doc dist-hook: all +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ENV = CC="$(CC)" +INTROSPECTION_SCANNER_ARGS = \ + --add-include-path=$(srcdir) \ + --warn-all \ + -DLIBXFCONF_COMPILATION \ + --symbol-prefix=xfconf_g_ \ + --symbol-prefix=xfconf_ \ + --c-include=xfconf/xfconf.h +INTROSPECTION_COMPILER_ARGS = \ + --includedir=$(srcdir) \ + --includedir=. + +if HAVE_INTROSPECTION +introspection_sources = $(filter-out %cache.h %.c, $(libxfconf_0_la_SOURCES)) + +Xfconf-0.gir: libxfconf-0.la Makefile +Xfconf_0_gir_INCLUDES = GObject-2.0 GLib-2.0 Gio-2.0 +Xfconf_0_gir_CFLAGS = $(AM_CPPFLAGS) +Xfconf_0_gir_LIBS = libxfconf-0.la +Xfconf_0_gir_FILES = $(introspection_sources) +INTROSPECTION_GIRS += Xfconf-0.gir + +girdir = $(datadir)/gir-1.0 +gir_DATA = $(INTROSPECTION_GIRS) + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) + +DISTCLEANFILES = $(gir_DATA) $(typelib_DATA) +endif + +if ENABLE_VAPIGEN +-include $(VAPIGEN_MAKEFILE) + +libxfconf-0.vapi: Xfconf-0.gir libxfconf-0.deps + +VAPIGEN_VAPIS = libxfconf-0.vapi +VAPIGEN_GIRDIRS = $(prefix)/share/gir-1.0 + +libxfconf_0_vapi_DEPS = gobject-2.0 glib-2.0 gio-2.0 +libxfconf_0_vapi_FILES = Xfconf-0.gir + +vapidir = $(datadir)/vala/vapi +vapi_DATA = $(VAPIGEN_VAPIS) $(VAPIGEN_VAPIS:.vapi=.deps) + +DISTCLEANFILES = libxfconf-0.deps +endif + if HAVE_GNUC_VISIBILITY TESTS = abicheck.sh endif diff --git a/xfconf/libxfconf-0.deps b/xfconf/libxfconf-0.deps new file mode 100644 index 0000000..333a927 --- /dev/null +++ b/xfconf/libxfconf-0.deps @@ -0,0 +1,3 @@ +gobject-2.0 +glib-2.0 +gio-2.0 diff --git a/xfconf/xfconf-channel.c b/xfconf/xfconf-channel.c index 7b3a7a6..ce45f05 100644 --- a/xfconf/xfconf-channel.c +++ b/xfconf/xfconf-channel.c @@ -327,6 +327,7 @@ xfconf_channel_get_g_property(GObject *object, case PROP_IS_SINGLETON: g_value_set_boolean(value, channel->is_singleton); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); diff --git a/xfconf/xfconf.c b/xfconf/xfconf.c index fb2934d..228bdc3 100644 --- a/xfconf/xfconf.c +++ b/xfconf/xfconf.c @@ -224,7 +224,7 @@ xfconf_array_new(gint n_preallocs) /** * xfconf_array_free: - * @arr: A #GPtrArray of #GValues. + * @arr: (element-type GValue): A #GPtrArray of #GValues. * * Properly frees a #GPtrArray structure containing a list of * #GValues. This will also cause the contents of the diff --git a/xfconfd/xfconf-daemon.c b/xfconfd/xfconf-daemon.c index b96edfd..fbe5da3 100644 --- a/xfconfd/xfconf-daemon.c +++ b/xfconfd/xfconf-daemon.c @@ -132,8 +132,8 @@ xfconf_daemon_backend_property_changed(XfconfBackend *backend, gpointer user_data) { XfconfPropChangedData *pdata = g_slice_new0(XfconfPropChangedData); - pdata->xfconfd = g_object_ref(G_OBJECT(user_data)); - pdata->backend = g_object_ref(G_OBJECT(backend)); + pdata->xfconfd = g_object_ref(XFCONF_DAEMON(user_data)); + pdata->backend = g_object_ref(XFCONF_BACKEND(backend)); pdata->channel = g_strdup(channel); pdata->property = g_strdup(property); g_idle_add(xfconf_daemon_emit_property_changed_idled, pdata); -- 2.20.1