Build and install introspection information

Build a XML gir file and binary typelib file for the interfaces that
we are installing for plugin use. They are installed into $(pkglibdir)
since they are private to the application.

http://bugzilla.gnome.org/show_bug.cgi?id=580041
This commit is contained in:
Owen W. Taylor 2008-11-01 13:40:29 -04:00 committed by Owen W. Taylor
parent 96dfeea412
commit 76a3f9d402
3 changed files with 141 additions and 31 deletions

View File

@ -164,6 +164,11 @@ AC_ARG_WITH(clutter,
[Use clutter for compositing]),, [Use clutter for compositing]),,
with_clutter=auto) with_clutter=auto)
AC_ARG_WITH(introspection,
AC_HELP_STRING([--with-introspection],
[Use GObject introspection]),,
with_introspection=auto)
AC_ARG_ENABLE(xsync, AC_ARG_ENABLE(xsync,
AC_HELP_STRING([--disable-xsync], AC_HELP_STRING([--disable-xsync],
[disable metacity's use of the XSync extension]),, [disable metacity's use of the XSync extension]),,
@ -324,6 +329,25 @@ if test x$have_clutter = xyes; then
fi fi
fi fi
if test x$with_introspection != xno; then
PKG_CHECK_MODULES(INTROSPECTION, gobject-introspection-1.0, have_introspection=yes, have_introspection=no)
if test x$have_introspection=xyes; then
METACITY_PC_MODULES="$METACITY_PC_MODULES gobject-introspection-1.0"
AC_DEFINE(HAVE_INTROSPECTION, 1, [Define if GObject introspection is available])
G_IR_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
AC_SUBST(G_IR_SCANNER)
G_IR_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
AC_SUBST(G_IR_COMPILER)
G_IR_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
AC_SUBST(G_IR_GENERATE)
GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
AC_SUBST(GIRDIR)
TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
AC_SUBST(TYPELIBDIR)
fi
fi
AM_CONDITIONAL(WITH_INTROSPECTION, test "$have_introspection" = "yes")
AC_MSG_CHECKING([Xcursor]) AC_MSG_CHECKING([Xcursor])
if $PKG_CONFIG xcursor; then if $PKG_CONFIG xcursor; then
have_xcursor=yes have_xcursor=yes
@ -590,6 +614,7 @@ metacity-$VERSION:
Solaris Xinerama: ${use_solaris_xinerama} Solaris Xinerama: ${use_solaris_xinerama}
Startup notification: ${have_startup_notification} Startup notification: ${have_startup_notification}
Compositing manager: ${have_xcomposite} Compositing manager: ${have_xcomposite}
Introspection: ${have_introspection}
Session management: ${found_sm} Session management: ${found_sm}
Shape extension: ${found_shape} Shape extension: ${found_shape}
Resize-and-rotate: ${found_randr} Resize-and-rotate: ${found_randr}

View File

@ -141,7 +141,7 @@ libmetacity_private_la_LIBADD = @METACITY_LIBS@
libmetacityincludedir = $(includedir)/metacity-1/metacity-private libmetacityincludedir = $(includedir)/metacity-1/metacity-private
libmetacityinclude_HEADERS = \ libmetacityinclude_base_headers = \
include/boxes.h \ include/boxes.h \
ui/gradient.h \ ui/gradient.h \
include/util.h \ include/util.h \
@ -149,7 +149,6 @@ libmetacityinclude_HEADERS = \
ui/preview-widget.h \ ui/preview-widget.h \
ui/theme-parser.h \ ui/theme-parser.h \
ui/theme.h \ ui/theme.h \
include/atomnames.h \
include/prefs.h \ include/prefs.h \
include/window.h \ include/window.h \
include/workspace.h \ include/workspace.h \
@ -162,6 +161,14 @@ libmetacityinclude_HEADERS = \
include/keybindings.h \ include/keybindings.h \
include/mutter-plugin.h include/mutter-plugin.h
# Excluded from scanning for introspection but installed
libmetacityinclude_extra_headers = \
include/atomnames.h
libmetacityinclude_HEADERS = \
$(libmetacityinclude_base_headers) \
$(libmetacityinclude_extra_headers)
metacity_theme_viewer_SOURCES= \ metacity_theme_viewer_SOURCES= \
ui/theme-viewer.c ui/theme-viewer.c
@ -180,9 +187,45 @@ metacity.schemas.in: schema_bindings ${srcdir}/metacity.schemas.in.in
bin_PROGRAMS=metacity metacity-theme-viewer bin_PROGRAMS=metacity metacity-theme-viewer
libexec_PROGRAMS=metacity-dialog libexec_PROGRAMS=metacity-dialog
api_version = $(METACITY_MAJOR_VERSION).$(METACITY_MINOR_VERSION)
if WITH_INTROSPECTION
# These files are in package-private directories, even though they may be used
# by plugins. If you're writing a plugin, use g-ir-compiler --add-include-path
# and g-ir-compiler --includedir.
girdir = $(pkglibdir)
gir_DATA = Meta-$(api_version).gir
typelibdir = $(pkglibdir)
typelib_DATA = Meta-$(api_version).typelib
# We need to strip out the attribute that would point back to libmetacity-introspect
# so that libgirepository looks for symbols in the executable instead
Meta-$(api_version).gir: $(G_IR_SCANNER) metacity $(libmetacityinclude_HEADERS) $(metacity_SOURCES)
$(G_IR_SCANNER) \
--namespace=Meta \
--nsversion=$(api_version) \
--include=GObject-2.0 \
--include=Gdk-2.0 \
--include=Gtk-2.0 \
--include=Clutter-0.9 \
--pkg=clutter-0.9 \
--pkg=gtk+-2.0 \
--include=xfixes-4.0 \
--program=./metacity \
$(filter %.c,$(metacity_SOURCES)) \
$(libmetacityinclude_base_headers) \
$(INCLUDES) \
-o $@
Meta-$(api_version).typelib: $(G_IR_COMPILER) Meta-$(api_version).gir
LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. $(G_IR_COMPILER) Meta-$(api_version).gir -o $@
endif
EFENCE= EFENCE=
metacity_LDADD=@METACITY_LIBS@ $(EFENCE) metacity_LDADD=@METACITY_LIBS@ libmetacity-private.la $(EFENCE)
metacity_LDFLAGS=-export-dynamic metacity_LDFLAGS=-export-dynamic
metacity_theme_viewer_LDADD= @METACITY_LIBS@ libmetacity-private.la metacity_theme_viewer_LDADD= @METACITY_LIBS@ libmetacity-private.la
metacity_dialog_LDADD=@METACITY_LIBS@ metacity_dialog_LDADD=@METACITY_LIBS@
@ -192,9 +235,9 @@ testasyncgetprop_SOURCES=core/async-getprop.h core/async-getprop.c core/testasyn
noinst_PROGRAMS=testboxes testgradient testasyncgetprop schema_bindings noinst_PROGRAMS=testboxes testgradient testasyncgetprop schema_bindings
testboxes_LDADD= @METACITY_LIBS@ testboxes_LDADD= @METACITY_LIBS@ libmetacity-private.la
testgradient_LDADD= @METACITY_LIBS@ testgradient_LDADD= @METACITY_LIBS@ libmetacity-private.la
testasyncgetprop_LDADD= @METACITY_LIBS@ testasyncgetprop_LDADD= @METACITY_LIBS@ libmetacity-private.la
@INTLTOOL_DESKTOP_RULE@ @INTLTOOL_DESKTOP_RULE@

View File

@ -73,6 +73,11 @@
#include <clutter/x11/clutter-x11.h> #include <clutter/x11/clutter-x11.h>
#endif #endif
#ifdef HAVE_INTROSPECTION
#include <girepository.h>
#include "compositor/mutter/mutter-plugin-manager.h"
#endif
/** /**
* The exit code we'll return to our parent process when we eventually die. * The exit code we'll return to our parent process when we eventually die.
*/ */
@ -228,6 +233,7 @@ typedef struct
gboolean composite; gboolean composite;
gboolean no_composite; gboolean no_composite;
gboolean no_tab_popup; gboolean no_tab_popup;
gchar *introspect;
} MetaArguments; } MetaArguments;
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
@ -323,6 +329,13 @@ meta_parse_options (int *argc, char ***argv,
N_("Whether window popup/frame should be shown when cycling windows."), N_("Whether window popup/frame should be shown when cycling windows."),
NULL NULL
}, },
#ifdef HAVE_INTROSPECTION
{
"introspect-dump", 0, 0, G_OPTION_ARG_STRING,
&my_args.introspect,
N_("Internal argument for GObject introspection"), "INTROSPECT"
},
#endif
{NULL} {NULL}
}; };
GOptionContext *ctx; GOptionContext *ctx;
@ -513,6 +526,8 @@ main (int argc, char **argv)
meta_warning ("Could not change to home directory %s.\n", meta_warning ("Could not change to home directory %s.\n",
g_get_home_dir ()); g_get_home_dir ());
g_type_init ();
meta_print_self_identity (); meta_print_self_identity ();
bindtextdomain (GETTEXT_PACKAGE, METACITY_LOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, METACITY_LOCALEDIR);
@ -522,6 +537,56 @@ main (int argc, char **argv)
/* Parse command line arguments.*/ /* Parse command line arguments.*/
ctx = meta_parse_options (&argc, &argv, &meta_args); ctx = meta_parse_options (&argc, &argv, &meta_args);
#ifdef WITH_CLUTTER
/* This must come before the introspect below, so we load all the plugins
* in order to get their get_type functions.
*/
if (meta_args.mutter_plugins)
{
char **plugins = g_strsplit (meta_args.mutter_plugins, ",", -1);
char **plugin;
GSList *plugins_list = NULL;
for (plugin = plugins; *plugin; plugin++)
{
g_strstrip (*plugin);
plugins_list = g_slist_prepend (plugins_list, *plugin);
}
plugins_list = g_slist_reverse (plugins_list);
meta_prefs_override_clutter_plugins (plugins_list);
g_slist_free(plugins_list);
g_strfreev (plugins);
}
#endif /* WITH_CLUTTER */
#ifdef HAVE_INTROSPECTION
g_irepository_prepend_search_path (METACITY_PKGLIBDIR);
if (meta_args.introspect)
{
GError *error = NULL;
if (meta_args.mutter_plugins)
{
/* We need to load all plugins so that we can call their
* get_type functions. We do not call
* mutter_plugin_manager_initialize because almost nothing else
* is initialized at this point, and we don't plan to run any real
* plugin code.
*/
MutterPluginManager *mgr = mutter_plugin_manager_new (NULL);
if (!mutter_plugin_manager_load (mgr))
g_critical ("failed to load plugins");
}
if (!g_irepository_dump (meta_args.introspect, &error))
{
g_printerr ("failed to dump: %s\n", error->message);
return 1;
}
return 0;
}
#endif
meta_set_syncing (meta_args.sync || (g_getenv ("METACITY_SYNC") != NULL)); meta_set_syncing (meta_args.sync || (g_getenv ("METACITY_SYNC") != NULL));
if (meta_args.print_version) if (meta_args.print_version)
@ -537,8 +602,6 @@ main (int argc, char **argv)
meta_main_loop = g_main_loop_new (NULL, FALSE); meta_main_loop = g_main_loop_new (NULL, FALSE);
g_type_init ();
meta_ui_init (&argc, &argv); meta_ui_init (&argc, &argv);
#ifdef WITH_CLUTTER #ifdef WITH_CLUTTER
@ -638,27 +701,6 @@ main (int argc, char **argv)
if (meta_args.composite || meta_args.no_composite) if (meta_args.composite || meta_args.no_composite)
meta_prefs_set_compositing_manager (meta_args.composite); meta_prefs_set_compositing_manager (meta_args.composite);
#ifdef WITH_CLUTTER
if (meta_args.mutter_plugins)
{
char **plugins = g_strsplit (meta_args.mutter_plugins, ",", -1);
char **plugin;
GSList *plugins_list = NULL;
for (plugin = plugins; *plugin; plugin++)
{
g_strstrip (*plugin);
plugins_list = g_slist_prepend (plugins_list, *plugin);
}
plugins_list = g_slist_reverse (plugins_list);
meta_prefs_override_clutter_plugins (plugins_list);
g_slist_free(plugins_list);
g_strfreev (plugins);
}
#endif
if (meta_args.no_tab_popup) if (meta_args.no_tab_popup)
{ {
meta_prefs_override_no_tab_popup (TRUE); meta_prefs_override_no_tab_popup (TRUE);