[easytag/wip/gsettings: 27/35] Generate enum descriptions with glib-mkenums



commit 0e77fe2afb25f889bf5d2ca7b1ea7e30324e304b
Author: David King <amigadave amigadave com>
Date:   Sun Mar 24 19:49:29 2013 +0000

    Generate enum descriptions with glib-mkenums

 .gitignore   |    2 ++
 Makefile.am  |   40 ++++++++++++++++++++++++++++++++++++++++
 configure.ac |    7 +++++++
 3 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e2000fc..d01a0f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,4 +37,6 @@ ltmain.sh
 /src/id3lib/.deps/
 /src/libapetag/.deps/
 /src/win32/.deps/
+/src/enums.c
+/src/enums.h
 stamp-h1
diff --git a/Makefile.am b/Makefile.am
index 225e537..17f4349 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,6 +48,7 @@ easytag_SOURCES = \
        src/crc32.c \
        src/dlm.c \
        src/easytag.c \
+       src/enums.c \
        src/et_core.c \
        src/flac_header.c \
        src/flac_tag.c \
@@ -116,6 +117,44 @@ easytag_LDADD = \
        $(EASYTAG_LIBS) \
        $(ID3LIB_LIBS)
 
+BUILT_SOURCES = \
+       src/enums.h
+
+enum_data = \
+       src/enums.c \
+       src/enums.h
+
+easytag_enum_headers = \
+       $(srcdir)/src/setting.h
+
+src/enums.c: $(easytag_enum_headers) src/enums.h Makefile
+       $(AM_V_GEN)$(GLIB_MKENUMS) \
+               --fhead "#include \"enums.h\"\n\n" \
+               --fprod "/* enumerations from \"@filename \" */\n" \
+               --fprod "#include \"@filename \"\n" \
+               --vhead "GType\n enum_name@_get_type (void)\n{\n" \
+               --vhead "    static GType type = 0;\n\n" \
+               --vhead "    if (!type)\n    {\n" \
+               --vhead "        static const G Type@Value _ enum_name@_values[] = {" \
+               --vprod "            { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+               --vtail "            { 0, NULL, NULL }\n        };\n\n" \
+               --vtail "        type = g_ type@_register_static (\"@EnumName \", _ enum_name@_values);\n    
}\n\n" \
+               --vtail "  return type;\n}\n\n" \
+               $(easytag_enum_headers) > $@
+
+src/enums.h: $(easytag_enum_headers) Makefile
+       $(AM_V_GEN)$(GLIB_MKENUMS) \
+               --fhead "#ifndef ET_ENUMS_H_\n" \
+               --fhead "#define ET_ENUMS_H_\n\n" \
+               --fhead "#include <glib-object.h>\n\n" \
+               --fhead "G_BEGIN_DECLS\n\n" \
+               --fprod "/* enumerations from @filename@ */\n" \
+               --vhead "GType @enum_name _get_type (void);\n" \
+               --vhead "#define ET_TYPE_ ENUMSHORT@ (@enum_name _get_type())\n" \
+               --ftail "G_END_DECLS\n\n" \
+               --ftail "#endif /* ET_ENUMS_H_ */" \
+               $(easytag_enum_headers) > $@
+
 # NSIS installer script.
 # TODO: Run script from dist dir.
 easytag-win32-installer.nsi: easytag-win32-installer.nsi.in Makefile
@@ -324,6 +363,7 @@ endif
 CLEANFILES = \
        $(check_SCRIPTS) \
        $(desktop_DATA) \
+       $(enum_data) \
        $(nodist_man_MANS) \
        easytag-win32-installer.nsi
 
diff --git a/configure.ac b/configure.ac
index 04ede9f..957f35b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,13 @@ AC_PROG_CXXCPP
 AC_PROG_SED
 PKG_PROG_PKG_CONFIG([0.24])
 
+AC_MSG_CHECKING([for glib-mkenums script])
+GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+AS_IF([test "x$GLIB_MKENUMS" = "x"],
+    [AC_MSG_ERROR([glib-mkenums not listed in glib-2.0 pkg-config file])],
+    [AC_SUBST([GLIB_MKENUMS])
+     AC_MSG_RESULT([$GLIB_MKENUMS])])
+
 dnl Man page, generated with xsltproc from DocBook XML.
 AC_ARG_ENABLE([man],
     [AS_HELP_STRING([--disable-man], [Disable building the man page])])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]