aboutsummaryrefslogtreecommitdiff
path: root/test cases/frameworks
diff options
context:
space:
mode:
authorElliott Sales de Andrade <quantum.analyst@gmail.com>2016-09-28 18:18:00 -0400
committerElliott Sales de Andrade <quantum.analyst@gmail.com>2016-09-28 18:32:46 -0400
commit8f024c06970dcaec1564516c4583ae8543713ea8 (patch)
tree86b30c388a133b76172fd1ef2893c6f8cd381975 /test cases/frameworks
parentd61b71fdc2fdd0b3c6cb60f9ab55c5b511a95fd9 (diff)
downloadmeson-8f024c06970dcaec1564516c4583ae8543713ea8.zip
meson-8f024c06970dcaec1564516c4583ae8543713ea8.tar.gz
meson-8f024c06970dcaec1564516c4583ae8543713ea8.tar.bz2
Allow running mkenums without templates.
Diffstat (limited to 'test cases/frameworks')
-rw-r--r--test cases/frameworks/7 gnome/installed_files.txt2
-rw-r--r--test cases/frameworks/7 gnome/mkenums/enums2.c.in41
-rw-r--r--test cases/frameworks/7 gnome/mkenums/enums2.h.in24
-rw-r--r--test cases/frameworks/7 gnome/mkenums/main.c2
-rw-r--r--test cases/frameworks/7 gnome/mkenums/meson.build115
5 files changed, 178 insertions, 6 deletions
diff --git a/test cases/frameworks/7 gnome/installed_files.txt b/test cases/frameworks/7 gnome/installed_files.txt
index ad802a0..c922f8b 100644
--- a/test cases/frameworks/7 gnome/installed_files.txt
+++ b/test cases/frameworks/7 gnome/installed_files.txt
@@ -1,4 +1,6 @@
usr/include/enums.h
+usr/include/enums2.h
+usr/include/enums3.h
usr/include/marshaller.h
usr/lib/girepository-1.0/Meson-1.0.typelib
usr/lib/libgirlib.so
diff --git a/test cases/frameworks/7 gnome/mkenums/enums2.c.in b/test cases/frameworks/7 gnome/mkenums/enums2.c.in
new file mode 100644
index 0000000..62e1adc
--- /dev/null
+++ b/test cases/frameworks/7 gnome/mkenums/enums2.c.in
@@ -0,0 +1,41 @@
+/*** BEGIN file-header ***/
+
+#include "enums.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 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 ***/
+
+/*** BEGIN file-tail ***/
+/*** END file-tail ***/
diff --git a/test cases/frameworks/7 gnome/mkenums/enums2.h.in b/test cases/frameworks/7 gnome/mkenums/enums2.h.in
new file mode 100644
index 0000000..479867f
--- /dev/null
+++ b/test cases/frameworks/7 gnome/mkenums/enums2.h.in
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef MESON_ENUMS_H
+#define MESON_ENUMS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@basename@" */
+/*** 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 /* MESON_ENUMS_H */
+/*** END file-tail ***/
diff --git a/test cases/frameworks/7 gnome/mkenums/main.c b/test cases/frameworks/7 gnome/mkenums/main.c
index 52e5461..d257185 100644
--- a/test cases/frameworks/7 gnome/mkenums/main.c
+++ b/test cases/frameworks/7 gnome/mkenums/main.c
@@ -2,7 +2,7 @@
#include<string.h>
#include<glib-object.h>
#include"meson-sample.h"
-#include"enums.h"
+#include"@ENUM_FILE@"
int main(int argc, char **argv) {
GEnumClass *xenum = g_type_class_ref(MESON_TYPE_THE_XENUM);
diff --git a/test cases/frameworks/7 gnome/mkenums/meson.build b/test cases/frameworks/7 gnome/mkenums/meson.build
index dbb8793..f0989cf 100644
--- a/test cases/frameworks/7 gnome/mkenums/meson.build
+++ b/test cases/frameworks/7 gnome/mkenums/meson.build
@@ -1,13 +1,118 @@
-myenums = gnome.mkenums('abc',
+# Generate both header and source via template together.
+
+myenums = gnome.mkenums('abc1',
sources : 'meson-sample.h',
h_template : 'enums.h.in',
c_template : 'enums.c.in',
install_header : true,
install_dir : get_option('includedir'))
-enums_c = myenums[0]
-enums_h = myenums[1]
+enums_c1 = myenums[0]
+enums_h1 = myenums[1]
+
+conf = configuration_data()
+conf.set('ENUM_FILE', 'enums.h')
+main = configure_file(
+ input : 'main.c',
+ output : 'main1.c',
+ configuration : conf)
+
+enumexe1 = executable('enumprog1', main, enums_c1, enums_h1,
+dependencies : gobj)
+test('enum test 1', enumexe1)
+
+# Generate both header and source via template individually and overriding.
+
+enums_c2 = gnome.mkenums('abc2',
+ sources : 'meson-sample.h',
+ c_template : 'enums2.c.in',
+ ftail : '/* trailing source file info */',
+ install_header : true,
+ install_dir : get_option('includedir'))
+
+enums_h2 = gnome.mkenums('abc2',
+ sources : 'meson-sample.h',
+ h_template : 'enums2.h.in',
+ ftail : '/* trailing header file info */',
+ install_header : true,
+ install_dir : get_option('includedir'))
+
+conf = configuration_data()
+conf.set('ENUM_FILE', 'enums2.h')
+main = configure_file(
+ input : 'main.c',
+ output : 'main2.c',
+ configuration : conf)
+
+enumexe2 = executable('enumprog2', main, enums_c2, enums_h2,
+dependencies : gobj)
+test('enum test 2', enumexe2)
+
+# Generate both header and source by options only.
+# These are specified in a way that should produce the same result as above
+# (modulo any filename changes.)
+
+enums_h3 = gnome.mkenums('enums3.h',
+ sources : 'meson-sample.h',
+ fhead : '''#ifndef MESON_ENUMS_H
+#define MESON_ENUMS_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+''',
+ fprod : '''
+/* enumerations from "@basename@" */
+''',
+ vhead : '''GType @enum_name@_get_type(void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+''',
+ ftail : '''
+G_END_DECLS
+
+#endif /* MESON_ENUMS_H */
+''',
+ install_header : true,
+ install_dir : get_option('includedir'))
+
+enums_c3 = gnome.mkenums('enums3.c',
+ sources : 'meson-sample.h',
+ depends : enums_h3,
+ fhead : '''#include "enums3.h"
+''',
+ fprod : '''
+
+/* enumerations from "@basename@" */
+#include "@basename@"
+''',
+ vhead : '''
+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 [] = {
+''',
+ vprod : ''' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },''',
+ vtail : ''' { 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;
+}
+''')
+
+conf = configuration_data()
+conf.set('ENUM_FILE', 'enums3.h')
+main = configure_file(
+ input : 'main.c',
+ output : 'main3.c',
+ configuration : conf)
-enumexe = executable('enumprog', 'main.c', enums_c, enums_h,
+enumexe3 = executable('enumprog3', main, enums_c3, enums_h3,
dependencies : gobj)
-test('enum test', enumexe)
+test('enum test 3', enumexe3)