From: "Zeeshan Ali (Khattak)" <zeesha...@gnome.org>

This commit adds the generation of osinfo_enum_types.[ch] using
glib-mkenums. These files will register the various enums that will get
added to osinfo header files with glib.

Commit message shamelessly stolen from a similar commit to libvirt-glib
by Christophe Fergeau <cferg...@redhat.com>.
---
 configure.ac                        |  3 +++
 osinfo/Makefile.am                  | 16 ++++++++++++++--
 osinfo/libosinfo.syms               |  8 ++++++++
 osinfo/osinfo.h                     |  3 +++
 osinfo/osinfo_enum_types.c.template | 36 ++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_enum_types.h.template | 24 ++++++++++++++++++++++++
 6 files changed, 88 insertions(+), 2 deletions(-)
 create mode 100644 osinfo/osinfo_enum_types.c.template
 create mode 100644 osinfo/osinfo_enum_types.h.template

diff --git a/configure.ac b/configure.ac
index c0950f7..277ab33 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,6 +173,9 @@ fi
 AC_SUBST(COVERAGE_CFLAGS)
 AC_SUBST(COVERAGE_LDFLAGS)
 
+# Setup GLIB_MKENUMS to use glib-mkenums even if GLib is uninstalled.
+GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+AC_SUBST(GLIB_MKENUMS)
 
 AC_CONFIG_FILES([
        Makefile
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index 6ddb956..922cf2a 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -1,9 +1,14 @@
 
-EXTRA_DIST = libosinfo.syms
+EXTRA_DIST = libosinfo.syms \
+            osinfo_enum_types.h.template \
+            osinfo_enum_types.c.template
+
+BUILT_SOURCES = osinfo_enum_types.c \
+               osinfo_enum_types.h
 
 if USE_VERSION_DEFS
 LIBOSINFO_VERSION_FILE = $(builddir)/libosinfo.def
-BUILT_SOURCES = $(LIBOSINFO_VERSION_FILE)
+BUILT_SOURCES += $(LIBOSINFO_VERSION_FILE)
 
 %.def: %.syms
        $(AM_V_GEN)rm -f -- $@-tmp $@ ; \
@@ -82,6 +87,7 @@ libosinfo_1_0_include_HEADERS = \
   $(NULL)
 
 libosinfo_1_0_la_SOURCES =     \
+  $(BUILT_SOURCES)             \
   osinfo_entity.c              \
   osinfo_filter.c              \
   osinfo_list.c                        \
@@ -113,6 +119,12 @@ libosinfo_1_0_la_SOURCES = \
   osinfo_loader.c              \
   $(NULL)
 
+osinfo_enum_types.h: $(libosinfo_1_0_include_HEADERS) 
osinfo_enum_types.h.template
+       $(AM_V_GEN) ( $(GLIB_MKENUMS) --template 
$(srcdir)/osinfo_enum_types.h.template 
$(libosinfo_1_0_include_HEADERS:%=$(srcdir)/%) ) > $(srcdir)/osinfo_enum_types.h
+
+osinfo_enum_types.c: $(libosinfo_1_0_include_HEADERS) 
osinfo_enum_types.c.template
+       $(AM_V_GEN) ( $(GLIB_MKENUMS) --template 
$(srcdir)/osinfo_enum_types.c.template 
$(libosinfo_1_0_include_HEADERS:%=$(srcdir)/%) ) > $(srcdir)/osinfo_enum_types.c
+
 if WITH_GOBJECT_INTROSPECTION
 
 Libosinfo-1.0.gir: libosinfo-1.0.la $(G_IR_SCANNER) Makefile.am
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 8cbb94e..2d28388 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -315,6 +315,14 @@ LIBOSINFO_0.2.1 {
        osinfo_media_get_installer_reboots;
 } LIBOSINFO_0.2.0;
 
+LIBOSINFO_0.2.2 {
+    global:
+       osinfo_install_config_param_policy_get_type;
+       osinfo_media_error_get_type;
+       osinfo_product_relationship_get_type;
+} LIBOSINFO_0.2.1;
+
+
 /* Symbols in next release...
 
   LIBOSINFO_0.0.2 {
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index 204569b..81ed1cc 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -25,6 +25,9 @@
 #ifndef __OSINFO_H__
 #define __OSINFO_H__
 
+#include <glib-object.h>
+
+#include <osinfo/osinfo_enum_types.h>
 #include <osinfo/osinfo_entity.h>
 #include <osinfo/osinfo_filter.h>
 #include <osinfo/osinfo_list.h>
diff --git a/osinfo/osinfo_enum_types.c.template 
b/osinfo/osinfo_enum_types.c.template
new file mode 100644
index 0000000..1f3e474
--- /dev/null
+++ b/osinfo/osinfo_enum_types.c.template
@@ -0,0 +1,36 @@
+/*** BEGIN file-header ***/
+#include <osinfo/osinfo.h>
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+  static volatile gsize g_define_type_id__volatile = 0;
+
+  if (g_once_init_enter (&g_define_type_id__volatile))
+    {
+      static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+        { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+        { 0, NULL, NULL }
+      };
+      GType g_define_type_id =
+        g_@type@_register_static (g_intern_static_string ("@EnumName@"), 
values);
+      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+    }
+
+  return g_define_type_id__volatile;
+}
+
+/*** END value-tail ***/
diff --git a/osinfo/osinfo_enum_types.h.template 
b/osinfo/osinfo_enum_types.h.template
new file mode 100644
index 0000000..3f4ce1f
--- /dev/null
+++ b/osinfo/osinfo_enum_types.h.template
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef __OSINFO_ENUM_TYPES_H__
+#define __OSINFO_ENUM_TYPES_H__
+
+#include <osinfo/osinfo.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __OSINFO_ENUM_TYPES_H__ */
+/*** END file-tail ***/
-- 
1.8.0

_______________________________________________
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Reply via email to