[totem] build: Use template files for enums generation
- From: Iñigo Martínez <inigomartinez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] build: Use template files for enums generation
- Date: Thu, 1 Mar 2018 14:24:49 +0000 (UTC)
commit 54bce40ad443351e5c1b02a12b673cc18690e044
Author: Iñigo Martínez <inigomartinez gmail com>
Date: Mon Feb 19 19:48:20 2018 +0100
build: Use template files for enums generation
The data contents for the enum related files are stored in the
build files.
This patch moves this information to template files to be used
along with glib-mkenums.
src/backend/bacon-video-widget-enums.c.template | 34 +++++++++++++++++++++++
src/backend/bacon-video-widget-enums.h.template | 27 ++++++++++++++++++
src/backend/meson.build | 34 +++++++----------------
3 files changed, 71 insertions(+), 24 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-enums.c.template b/src/backend/bacon-video-widget-enums.c.template
new file mode 100644
index 0000000..38ea6ac
--- /dev/null
+++ b/src/backend/bacon-video-widget-enums.c.template
@@ -0,0 +1,34 @@
+/*** BEGIN file-header ***/
+#include "bacon-video-widget-enums.h"
+#include <glib-object.h>
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@basename@" */
+#include "@basename@"
+
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ etype = g_@type@_register_static ("@EnumName@", values);
+ }
+ return etype;
+}
+
+/*** END value-tail ***/
diff --git a/src/backend/bacon-video-widget-enums.h.template b/src/backend/bacon-video-widget-enums.h.template
new file mode 100644
index 0000000..56b683d
--- /dev/null
+++ b/src/backend/bacon-video-widget-enums.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef BVW_ENUMS_H
+#define BVW_ENUMS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@basename@" */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define BVW_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* !BVW_ENUMS_H */
+/*** END file-tail ***/
+
diff --git a/src/backend/meson.build b/src/backend/meson.build
index 28c8e12..ef8da1a 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -42,28 +42,14 @@ sources = files(
'totem-aspect-frame.c'
)
-enums = 'bacon-video-widget-enums'
-enums_header = files('bacon-video-widget.h')
-
-libbacon_gen_sources = []
-
-libbacon_gen_sources += gnome.mkenums(
- enums + '.h',
- sources: enums_header,
- fhead: '#ifndef BVW_ENUMS_H\n#define BVW_ENUMS_H\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n',
- fprod: '/* enumerations from "@filename@" */\n',
- vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define BVW_TYPE_@ENUMSHORT@
(@enum_name@_get_type())\n',
- ftail: 'G_END_DECLS\n\n#endif /* !BVW_ENUMS_H */'
-)
-
-libbacon_gen_sources += gnome.mkenums(
- enums + '.c',
- sources: enums_header,
- fhead: '#include "bacon-video-widget.h"\n#include "bacon-video-widget-enums.h"',
- fprod: '\n/* enumerations from "@filename@" */',
- vhead: 'GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static
const G@Type@Value values[] = {',
- vprod: ' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
- vtail: ' { 0, NULL, NULL }\n };\n etype = g_@type@_register_static ("@EnumName@", values);\n
}\n return etype;\n}\n'
+enum = 'bacon-video-widget-enums'
+enum_headers = files('bacon-video-widget.h')
+
+enum_sources = gnome.mkenums(
+ enum,
+ sources: enum_headers,
+ c_template: enum + '.c.template',
+ h_template: enum + '.h.template'
)
libbacon_video_widget_incs = [
@@ -95,7 +81,7 @@ libbacon_video_widget_cflags = common_flags + warn_flags + [
libbacon_video_widget = static_library(
'baconvideowidget',
- sources: sources + libbacon_gen_sources,
+ sources: sources + enum_sources,
include_directories: libbacon_video_widget_incs,
dependencies: libbacon_video_widget_deps,
c_args: libbacon_video_widget_cflags
@@ -105,7 +91,7 @@ libbacon_video_widget_dep = declare_dependency(
link_with: libbacon_video_widget,
include_directories: backend_inc,
dependencies: libbacon_video_widget_deps,
- sources: libbacon_gen_sources
+ sources: enum_sources
)
if have_easy_codec
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]