[mutter] Build and install introspection information
- From: Owen Taylor <otaylor src gnome org>
- To: svn-commits-list gnome org
- Subject: [mutter] Build and install introspection information
- Date: Fri, 24 Apr 2009 09:57:24 -0400 (EDT)
commit 76a3f9d4024b5f5efa5857ee8334152f9d52d4d7
Author: Owen W. Taylor <otaylor redhat com>
Date: Sat Nov 1 13:40:29 2008 -0400
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
---
configure.in | 25 +++++++++++++++
src/Makefile.am | 59 ++++++++++++++++++++++++++++++++-----
src/core/main.c | 88 ++++++++++++++++++++++++++++++++++++++++--------------
3 files changed, 141 insertions(+), 31 deletions(-)
diff --git a/configure.in b/configure.in
index b6bff5d..c7c3262 100644
--- a/configure.in
+++ b/configure.in
@@ -164,6 +164,11 @@ AC_ARG_WITH(clutter,
[Use clutter for compositing]),,
with_clutter=auto)
+AC_ARG_WITH(introspection,
+ AC_HELP_STRING([--with-introspection],
+ [Use GObject introspection]),,
+ with_introspection=auto)
+
AC_ARG_ENABLE(xsync,
AC_HELP_STRING([--disable-xsync],
[disable metacity's use of the XSync extension]),,
@@ -324,6 +329,25 @@ if test x$have_clutter = xyes; then
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])
if $PKG_CONFIG xcursor; then
have_xcursor=yes
@@ -590,6 +614,7 @@ metacity-$VERSION:
Solaris Xinerama: ${use_solaris_xinerama}
Startup notification: ${have_startup_notification}
Compositing manager: ${have_xcomposite}
+ Introspection: ${have_introspection}
Session management: ${found_sm}
Shape extension: ${found_shape}
Resize-and-rotate: ${found_randr}
diff --git a/src/Makefile.am b/src/Makefile.am
index e48508e..5e44e4f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,7 +8,7 @@ endif
INCLUDES= METACITY_CFLAGS@ -I $(srcdir)/include -I$(srcdir)/compositor -DMETACITY_LIBEXECDIR=\"$(libexecdir)\" -DHOST_ALIAS=\"@HOST_ALIAS \" -DMETACITY_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" -DMETACITY_PKGDATADIR=\"$(pkgdatadir)\" -DMETACITY_DATADIR=\"$(datadir)\" -DG_LOG_DOMAIN=\"metacity\" -DSN_API_NOT_YET_FROZEN=1 -DMETACITY_MAJOR_VERSION=$(METACITY_MAJOR_VERSION) -DMETACITY_MINOR_VERSION=$(METACITY_MINOR_VERSION) -DMETACITY_MICRO_VERSION=$(METACITY_MICRO_VERSION) -DMETACITY_CLUTTER_PLUGIN_API_VERSION=$(METACITY_CLUTTER_PLUGIN_API_VERSION) -DMETACITY_PKGLIBDIR=\"$(pkglibdir)\" -DMUTTER_PLUGIN_DIR=\"@MUTTER_PLUGIN_DIR \"
-metacity_SOURCES= \
+metacity_SOURCES= \
core/async-getprop.c \
core/async-getprop.h \
core/bell.c \
@@ -103,7 +103,7 @@ metacity_SOURCES= \
include/all-keybindings.h
if WITH_CLUTTER
-metacity_SOURCES += \
+metacity_SOURCES += \
compositor/mutter/compositor-mutter.c \
compositor/mutter/mutter-shaped-texture.c \
compositor/mutter/mutter-shaped-texture.h \
@@ -141,7 +141,7 @@ libmetacity_private_la_LIBADD = @METACITY_LIBS@
libmetacityincludedir = $(includedir)/metacity-1/metacity-private
-libmetacityinclude_HEADERS = \
+libmetacityinclude_base_headers = \
include/boxes.h \
ui/gradient.h \
include/util.h \
@@ -149,7 +149,6 @@ libmetacityinclude_HEADERS = \
ui/preview-widget.h \
ui/theme-parser.h \
ui/theme.h \
- include/atomnames.h \
include/prefs.h \
include/window.h \
include/workspace.h \
@@ -162,6 +161,14 @@ libmetacityinclude_HEADERS = \
include/keybindings.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= \
ui/theme-viewer.c
@@ -180,9 +187,45 @@ metacity.schemas.in: schema_bindings ${srcdir}/metacity.schemas.in.in
bin_PROGRAMS=metacity metacity-theme-viewer
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=
-metacity_LDADD= METACITY_LIBS@ $(EFENCE)
+metacity_LDADD= METACITY_LIBS@ libmetacity-private.la $(EFENCE)
metacity_LDFLAGS=-export-dynamic
+
metacity_theme_viewer_LDADD= @METACITY_LIBS@ libmetacity-private.la
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
-testboxes_LDADD= @METACITY_LIBS@
-testgradient_LDADD= @METACITY_LIBS@
-testasyncgetprop_LDADD= @METACITY_LIBS@
+testboxes_LDADD= @METACITY_LIBS@ libmetacity-private.la
+testgradient_LDADD= @METACITY_LIBS@ libmetacity-private.la
+testasyncgetprop_LDADD= @METACITY_LIBS@ libmetacity-private.la
@INTLTOOL_DESKTOP_RULE@
diff --git a/src/core/main.c b/src/core/main.c
index ed7d985..0fafeaf 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -73,6 +73,11 @@
#include <clutter/x11/clutter-x11.h>
#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.
*/
@@ -228,6 +233,7 @@ typedef struct
gboolean composite;
gboolean no_composite;
gboolean no_tab_popup;
+ gchar *introspect;
} MetaArguments;
#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."),
NULL
},
+#ifdef HAVE_INTROSPECTION
+ {
+ "introspect-dump", 0, 0, G_OPTION_ARG_STRING,
+ &my_args.introspect,
+ N_("Internal argument for GObject introspection"), "INTROSPECT"
+ },
+#endif
{NULL}
};
GOptionContext *ctx;
@@ -513,6 +526,8 @@ main (int argc, char **argv)
meta_warning ("Could not change to home directory %s.\n",
g_get_home_dir ());
+ g_type_init ();
+
meta_print_self_identity ();
bindtextdomain (GETTEXT_PACKAGE, METACITY_LOCALEDIR);
@@ -522,6 +537,56 @@ main (int argc, char **argv)
/* Parse command line arguments.*/
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));
if (meta_args.print_version)
@@ -537,8 +602,6 @@ main (int argc, char **argv)
meta_main_loop = g_main_loop_new (NULL, FALSE);
- g_type_init ();
-
meta_ui_init (&argc, &argv);
#ifdef WITH_CLUTTER
@@ -638,27 +701,6 @@ main (int argc, char **argv)
if (meta_args.composite || meta_args.no_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)
{
meta_prefs_override_no_tab_popup (TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]