[easytag/wip/application-window: 19/23] Generate enum descriptions with glib-mkenums



commit baded5b5938d20e80efcbfe2a26498d6ebbcd064
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 b52ee2e..5468312 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,6 +40,8 @@ ltmain.sh
 /src/libapetag/.deps/
 /src/win32/.deps/
 /src/win32/easytag.rc
+/src/enums.c
+/src/enums.h
 /????-report.html
 /????-report.xml
 /test-suite.log
diff --git a/Makefile.am b/Makefile.am
index 2154b30..52d95d8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,6 +50,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 \
@@ -153,6 +154,44 @@ easytag-$(PACKAGE_VERSION)-setup.exe: easytag-win32-installer.nsi easytag.exe Ma
                rm -rf $$DESTDIR
 endif
 
+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
@@ -354,6 +393,7 @@ CLEANFILES = \
        $(check_SCRIPTS) \
        $(desktop_DATA) \
        $(easytag_rc) \
+       $(enum_data) \
        $(nodist_man_MANS) \
        *.log \
        easytag-$(PACKAGE_VERSION)-setup.exe \
diff --git a/configure.ac b/configure.ac
index ebc7d90..945e4c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,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]