Initial support for dynamic loadable modules with GModule

This commit is contained in:
Kleis Auke Wolthuizen 2021-02-13 14:15:27 +01:00
parent 3841e2e49c
commit a63d37fc9b
5 changed files with 69 additions and 5 deletions

View File

@ -399,8 +399,8 @@ AC_CHECK_LIB(m,hypot,[AC_DEFINE(HAVE_HYPOT,1,[have hypot() in libm.])])
AC_CHECK_LIB(m,atan2,[AC_DEFINE(HAVE_ATAN2,1,[have atan2() in libm.])])
# have to have these parts of glib ... we need glib 2.15 for gio
PKG_CHECK_MODULES(REQUIRED, glib-2.0 >= 2.40 gmodule-2.0 gobject-2.0 gio-2.0)
PACKAGES_USED="$PACKAGES_USED glib-2.0 gmodule-2.0 gobject-2.0 gio-2.0"
PKG_CHECK_MODULES(REQUIRED, glib-2.0 >= 2.40 gmodule-no-export-2.0 gobject-2.0 gio-2.0)
PACKAGES_USED="$PACKAGES_USED glib-2.0 gmodule-no-export-2.0 gobject-2.0 gio-2.0"
# from 2.62 we have datetime
PKG_CHECK_MODULES(DATE_TIME_FORMAT_ISO8601, glib-2.0 >= 2.62,
@ -437,6 +437,30 @@ PKG_CHECK_MODULES(HAVE_CHECKED_MUL, glib-2.0 >= 2.48,
]
)
AC_MSG_CHECKING([whether to build dynamic modules])
AC_ARG_ENABLE([modules],
AS_HELP_STRING([--disable-modules], [disable dynamic modules (default: enabled)]))
gmodule_supported_bool=false
gmodule_supported_flag=no
gmodule_with_flag=yes
if test x"$enable_modules" = x"no"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(whether dynamic modules work)
gmodule_supported_bool=`$PKG_CONFIG gmodule-no-export-2.0 --variable gmodule_supported`
if $gmodule_supported_bool; then
gmodule_supported_flag=yes
gmodule_with_flag='module'
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
# check for gtk-doc
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
@ -1334,6 +1358,7 @@ VIPS_LIBS="$VIPS_LIBS $REQUIRED_LIBS -lm"
VIPS_CONFIG="\
enable debug: $enable_debug, \
enable deprecated library components: $enable_deprecated, \
enable modules: $gmodule_supported_flag, \
enable docs with gtkdoc: $enable_gtk_doc, \
gobject introspection: $found_introspection, \
RAD load/save: $with_radiance, \
@ -1434,6 +1459,7 @@ AC_MSG_RESULT([dnl
## Build options
enable debug: $enable_debug
enable deprecated library components: $enable_deprecated
enable modules: $gmodule_supported_flag
enable docs with gtkdoc: $enable_gtk_doc
gobject introspection: $found_introspection
RAD load/save: $with_radiance

View File

@ -61,6 +61,7 @@ libvips_la_LDFLAGS = \
-version-info @LIBRARY_CURRENT@:@LIBRARY_REVISION@:@LIBRARY_AGE@
EXTRA_DIST = \
module \
$(OPTIONAL_DIST_DIR)
CLEANFILES =
@ -72,6 +73,35 @@ install-exec-hook:
cp soname.h $(DESTDIR)$(pkgincludedir) && \
rm soname.h
# Modules
module_LTLIBRARIES =
# All modules within the $VIPSHOME/lib/vips-modules-MAJOR.MINOR
# directory are automatically loaded on vips_init.
moduledir = @VIPS_LIBDIR@/vips-modules-@VIPS_MAJOR_VERSION@.@VIPS_MINOR_VERSION@
MODULE_CPPFLAGS = \
-I${top_srcdir}/libvips/include \
$(REQUIRED_CFLAGS)
MODULE_LDFLAGS = \
-no-undefined \
-shared \
-module \
-avoid-version
MODULE_LIBADD = \
libvips.la \
$(REQUIRED_LIBS)
# Note that only the GObject part should be included in a
# dynamically loadable module. The C definitions are always
# included in the main library.
# Introspection
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)

View File

@ -72,6 +72,9 @@ libforeign_la_SOURCES = \
webpload.c \
webpsave.c
# We still need to include the GObject part of a loader/saver
# if it is not built as a dynamically loadable module.
EXTRA_DIST = libnsgif
AM_CPPFLAGS = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@

View File

@ -510,13 +510,18 @@ vips_init( const char *argv0 )
vips_mosaicing_operation_init();
vips_g_input_stream_get_type();
/* Load any vips8 plugins from the vips libdir. Keep going, even if
* some plugins fail to load.
/* Load any vips8 modules from the vips libdir. Keep going, even if
* some modules fail to load.
*/
(void) vips_load_plugins( "%s/vips-modules-%d.%d",
libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION );
#if ENABLE_DEPRECATED
/* Load any vips8 plugins from the vips libdir.
*/
(void) vips_load_plugins( "%s/vips-plugins-%d.%d",
libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION );
#if ENABLE_DEPRECATED
/* Load up any vips7 plugins in the vips libdir. We don't error on
* failure, it's too annoying to have VIPS refuse to start because of
* a broken plugin.

0
libvips/module/.gitkeep Normal file
View File