[virt-tools-list] [PATCH 44/47] Add support for GObject introspection
Daniel P. Berrange
berrange at redhat.com
Wed Aug 25 19:37:39 UTC 2010
Introspect the libosinfo API so that non-C language bindings
can be automagically generated
* osinfo/osinfo.h, osinfo/osinfo_dataread.c, osinfo/osinfo_db.h,
osinfo/osinfo_device.h, osinfo/osinfo_devicelist.h,
osinfo/osinfo_entity.h, osinfo/osinfo_filter.h,
osinfo/osinfo_hypervisor.h, osinfo/osinfo_hypervisorlist.h,
osinfo/osinfo_os.h, osinfo/osinfo_oslist.h: Add explicit
includes to match build dependancies, to satisfy g-ir-scanner
limitations. Rename enum values to allow them to be extracted
with correct names
---
.gitignore | 2 ++
configure.ac | 21 +++++++++++++++++++++
osinfo/Makefile.am | 32 ++++++++++++++++++++++++++++++++
osinfo/osinfo.h | 1 -
osinfo/osinfo_dataread.c | 9 ++++++---
osinfo/osinfo_db.h | 8 ++++++++
osinfo/osinfo_device.h | 3 +++
osinfo/osinfo_devicelist.h | 4 ++++
osinfo/osinfo_entity.h | 2 ++
osinfo/osinfo_filter.h | 3 +++
osinfo/osinfo_hypervisor.h | 4 ++++
osinfo/osinfo_hypervisorlist.h | 4 ++++
osinfo/osinfo_os.h | 11 ++++++++---
osinfo/osinfo_oslist.h | 4 ++++
14 files changed, 101 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
index 08c97a8..70d83ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,5 @@ stamp-h1
test/test-skeleton
test/test-skeleton.sh
osinfo/libosinfo.pc
+osinfo/Libosinfo-1.0.gir
+osinfo/Libosinfo-1.0.typelib
diff --git a/configure.ac b/configure.ac
index a7508a5..f179904 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,27 @@ AC_SUBST([NO_UNDEFINED_FLAGS])
AC_SUBST([VERSION_SCRIPT_FLAGS])
AM_CONDITIONAL([USE_VERSION_DEFS], [test "$USE_VERSION_DEFS" = "1"])
+if test "x$enable_introspection" != "xno" ; then
+ PKG_CHECK_MODULES([GOBJECT_INTROSPECTION],
+ [gobject-introspection-1.0 >= 0.9.0],
+ [enable_introspection=yes],
+ [
+ if test "x$enable_introspection" = "xcheck"; then
+ enable_introspection=no
+ else
+ AC_MSG_ERROR([gobject-introspection is not available])
+ fi
+ ])
+ if test "x$enable_introspection" = "xyes" ; then
+ AC_DEFINE([WITH_GOBJECT_INTROSPECTION], [1], [enable GObject introspection support])
+ AC_SUBST(GOBJECT_INTROSPECTION_CFLAGS)
+ AC_SUBST(GOBJECT_INTROSPECTION_LIBS)
+ AC_SUBST([G_IR_SCANNER], [$($PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0)])
+ AC_SUBST([G_IR_COMPILER], [$($PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0)])
+ fi
+fi
+AM_CONDITIONAL([WITH_GOBJECT_INTROSPECTION], [test "x$enable_introspection" = "xyes"])
+
AC_CONFIG_FILES([
Makefile
osinfo/Makefile
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index 09f47fa..fa4348c 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -63,3 +63,35 @@ libosinfo_1_0_la_SOURCES = \
osinfo_dataread.c \
osinfo_db.c
+if WITH_GOBJECT_INTROSPECTION
+
+Libosinfo-1.0.gir: libosinfo-1.0.la $(G_IR_SCANNER) Makefile.am
+ $(AM_V_GEN)$(G_IR_SCANNER) --quiet \
+ --namespace Libosinfo \
+ --nsversion 1.0 \
+ --include GObject-2.0 \
+ --strip-prefix=osinfo \
+ --library=$(builddir)/libosinfo-1.0.la \
+ --output $@ \
+ -I$(top_srcdir) \
+ -I$(srcdir) \
+ --verbose \
+ --pkg=gobject-2.0 \
+ $(libosinfo_1_0_include_HEADERS:%=$(srcdir)/%) \
+ $(libosinfo_1_0_la_SOURCES:%=$(srcdir)/%)
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = Libosinfo-1.0.gir
+
+typelibsdir = $(libdir)/girepository-1.0
+typelibs_DATA = Libosinfo-1.0.typelib
+
+%.typelib: %.gir
+ $(AM_V_GEN)$(G_IR_COMPILER) \
+ --includedir=$(builddir) \
+ --includedir=$(girdir) \
+ -o $@ $<
+
+CLEANFILES = $(gir_DATA) $(typelibs_DATA)
+
+endif # WITH_GOBJECT_INTROSPECTION
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index 9e8ec3e..d619c9f 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -1,7 +1,6 @@
#ifndef __OSINFO_H__
#define __OSINFO_H__
-#include <glib-object.h>
#include <osinfo/osinfo_entity.h>
#include <osinfo/osinfo_filter.h>
#include <osinfo/osinfo_list.h>
diff --git a/osinfo/osinfo_dataread.c b/osinfo/osinfo_dataread.c
index a6575f1..ca84a86 100644
--- a/osinfo/osinfo_dataread.c
+++ b/osinfo/osinfo_dataread.c
@@ -328,17 +328,20 @@ static int __osinfoProcessOs(OsinfoDb *db,
goto cleanup_error;
}
else if (strcmp(name, "upgrades") == 0) {
- err = __osinfoProcessOsRelationship(reader, db, os, UPGRADES);
+ err = __osinfoProcessOsRelationship(reader, db, os,
+ OSINFO_OS_RELATIONSHIP_UPGRADES);
if (err != 0)
goto cleanup_error;
}
else if (strcmp(name, "clones") == 0) {
- err = __osinfoProcessOsRelationship(reader, db, os, CLONES);
+ err = __osinfoProcessOsRelationship(reader, db, os,
+ OSINFO_OS_RELATIONSHIP_CLONES);
if (err != 0)
goto cleanup_error;
}
else if (strcmp(name, "derives-from") == 0) {
- err = __osinfoProcessOsRelationship(reader, db, os, DERIVES_FROM);
+ err = __osinfoProcessOsRelationship(reader, db, os,
+ OSINFO_OS_RELATIONSHIP_DERIVES_FROM);
if (err != 0)
goto cleanup_error;
}
diff --git a/osinfo/osinfo_db.h b/osinfo/osinfo_db.h
index af77e96..30a1abf 100644
--- a/osinfo/osinfo_db.h
+++ b/osinfo/osinfo_db.h
@@ -5,6 +5,14 @@
* Represents the main entry point to data contained by libosinfo.
*/
+#include <glib-object.h>
+#include <osinfo/osinfo_hypervisor.h>
+#include <osinfo/osinfo_os.h>
+#include <osinfo/osinfo_device.h>
+#include <osinfo/osinfo_hypervisorlist.h>
+#include <osinfo/osinfo_oslist.h>
+#include <osinfo/osinfo_devicelist.h>
+
#ifndef __OSINFO_DB_H__
#define __OSINFO_DB_H__
diff --git a/osinfo/osinfo_device.h b/osinfo/osinfo_device.h
index ad88557..37cae0e 100644
--- a/osinfo/osinfo_device.h
+++ b/osinfo/osinfo_device.h
@@ -5,6 +5,9 @@
* Represents a device in libosinfo.
*/
+#include <glib-object.h>
+#include <osinfo/osinfo_entity.h>
+
#ifndef __OSINFO_DEVICE_H__
#define __OSINFO_DEVICE_H__
diff --git a/osinfo/osinfo_devicelist.h b/osinfo/osinfo_devicelist.h
index e5cb25d..5ea900a 100644
--- a/osinfo/osinfo_devicelist.h
+++ b/osinfo/osinfo_devicelist.h
@@ -4,6 +4,10 @@
* osinfo_devicelist.h
*/
+#include <glib-object.h>
+#include <osinfo/osinfo_filter.h>
+#include <osinfo/osinfo_list.h>
+
#ifndef __OSINFO_DEVICELIST_H__
#define __OSINFO_DEVICELIST_H__
diff --git a/osinfo/osinfo_entity.h b/osinfo/osinfo_entity.h
index 30719b6..6c4e5d8 100644
--- a/osinfo/osinfo_entity.h
+++ b/osinfo/osinfo_entity.h
@@ -5,6 +5,8 @@
* All entities represented in libosinfo are derived from this class.
*/
+#include <glib-object.h>
+
#ifndef __OSINFO_ENTITY_H__
#define __OSINFO_ENTITY_H__
diff --git a/osinfo/osinfo_filter.h b/osinfo/osinfo_filter.h
index cec406d..be9ddb5 100644
--- a/osinfo/osinfo_filter.h
+++ b/osinfo/osinfo_filter.h
@@ -5,6 +5,9 @@
* Represents a filter in libosinfo.
*/
+#include <glib-object.h>
+#include <osinfo/osinfo_entity.h>
+
#ifndef __OSINFO_FILTER_H__
#define __OSINFO_FILTER_H__
diff --git a/osinfo/osinfo_hypervisor.h b/osinfo/osinfo_hypervisor.h
index cfa59b1..977fd1c 100644
--- a/osinfo/osinfo_hypervisor.h
+++ b/osinfo/osinfo_hypervisor.h
@@ -5,6 +5,10 @@
* Represents a hypervisor in libosinfo.
*/
+#include <glib-object.h>
+#include <osinfo/osinfo_device.h>
+#include <osinfo/osinfo_devicelist.h>
+
#ifndef __OSINFO_HYPERVISOR_H__
#define __OSINFO_HYPERVISOR_H__
diff --git a/osinfo/osinfo_hypervisorlist.h b/osinfo/osinfo_hypervisorlist.h
index 2487ac2..4c730a1 100644
--- a/osinfo/osinfo_hypervisorlist.h
+++ b/osinfo/osinfo_hypervisorlist.h
@@ -4,6 +4,10 @@
* osinfo_hypervisorlist.h
*/
+#include <glib-object.h>
+#include <osinfo/osinfo_filter.h>
+#include <osinfo/osinfo_list.h>
+
#ifndef __OSINFO_HYPERVISORLIST_H__
#define __OSINFO_HYPERVISORLIST_H__
diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
index 6c1a447..a95bf86 100644
--- a/osinfo/osinfo_os.h
+++ b/osinfo/osinfo_os.h
@@ -5,6 +5,11 @@
* Represents an operating system in libosinfo.
*/
+#include <glib-object.h>
+#include <osinfo/osinfo_device.h>
+#include <osinfo/osinfo_devicelist.h>
+#include <osinfo/osinfo_oslist.h>
+
#ifndef __OSINFO_OS_H__
#define __OSINFO_OS_H__
@@ -44,9 +49,9 @@ struct _OsinfoOsClass
};
typedef enum {
- DERIVES_FROM,
- UPGRADES,
- CLONES,
+ OSINFO_OS_RELATIONSHIP_DERIVES_FROM,
+ OSINFO_OS_RELATIONSHIP_UPGRADES,
+ OSINFO_OS_RELATIONSHIP_CLONES,
} OsinfoOsRelationship;
diff --git a/osinfo/osinfo_oslist.h b/osinfo/osinfo_oslist.h
index 7adc69f..977653d 100644
--- a/osinfo/osinfo_oslist.h
+++ b/osinfo/osinfo_oslist.h
@@ -5,6 +5,10 @@
* All entities represented in libosinfo are derived from this class.
*/
+#include <glib-object.h>
+#include <osinfo/osinfo_filter.h>
+#include <osinfo/osinfo_list.h>
+
#ifndef __OSINFO_OSLIST_H__
#define __OSINFO_OSLIST_H__
--
1.7.2.1
More information about the virt-tools-list
mailing list