Debian Codegraph @

vendored-meson/meson/test cases/frameworks/7 gnome/mkenums/meson.build

raw
1 # Generate both header and source via template together.
2
3 myenums = gnome.mkenums('abc1',
4 sources : 'meson-sample.h',
5 h_template : 'enums.h.in',
6 c_template : 'enums.c.in',
7 install_header : true,
8 install_dir : get_option('includedir'))
9
10 enums_c1 = myenums[0]
11 enums_h1 = myenums[1]
12
13 conf = configuration_data()
14 conf.set('ENUM_FILE', 'enums.h')
15 main = configure_file(
16 input : 'main.c',
17 output : 'main1.c',
18 configuration : conf)
19
20 enumexe1 = executable('enumprog1', main, enums_c1, enums_h1,
21 dependencies : gobj)
22 test('enum test 1', enumexe1)
23
24 # Generate both header and source via template individually and overriding.
25
26 enums_h2 = gnome.mkenums('abc2',
27 sources : 'meson-sample.h',
28 h_template : 'enums2.h.in',
29 ftail : '/* trailing header file info */',
30 install_header : true,
31 install_dir : get_option('includedir'))
32
33 enums_c2 = gnome.mkenums('abc2',
34 sources : 'meson-sample.h',
35 depends : [enums_h1, enums_h2],
36 c_template : 'enums2.c.in',
37 ftail : '/* trailing source file info */')
38 # explicitly don't set install_dir here, for bug testing
39 # See https://github.com/mesonbuild/meson/issues/9472
40
41 conf = configuration_data()
42 conf.set('ENUM_FILE', 'enums2.h')
43 main = configure_file(
44 input : 'main.c',
45 output : 'main2.c',
46 configuration : conf)
47
48 enumexe2 = executable('enumprog2', main, enums_c2, enums_h2,
49 dependencies : gobj)
50 test('enum test 2', enumexe2)
51
52 # Generate both header and source by options only.
53 # These are specified in a way that should produce the same result as above
54 # (modulo any filename changes.)
55
56 enums_h3 = gnome.mkenums('enums3.h',
57 sources : 'meson-sample.h',
58 fhead : '''#ifndef MESON_ENUMS_H
59 #define MESON_ENUMS_H
60
61 #include <glib-object.h>
62
63 G_BEGIN_DECLS
64 ''',
65 fprod : '''
66 /* enumerations from "@basename@" */
67 ''',
68 vhead : '''GType @enum_name@_get_type(void) G_GNUC_CONST;
69 #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
70 ''',
71 ftail : '''
72 G_END_DECLS
73
74 #endif /* MESON_ENUMS_H */
75 ''',
76 install_header : true,
77 install_dir : get_option('includedir'))
78
79 enums_c3 = gnome.mkenums('enums3.c',
80 sources : 'meson-sample.h',
81 depends : enums_h3,
82 fhead : '''#include "enums3.h"
83 ''',
84 fprod : '''
85
86 /* enumerations from "@basename@" */
87 #include "@basename@"
88 ''',
89 vhead : '''
90 GType
91 @enum_name@_get_type(void) {
92 static gsize static_g_define_type_id = 0;
93
94 if(g_once_init_enter(&static_g_define_type_id)) {
95 static const G@Type@Value values [] = {
96 ''',
97 vprod : ''' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },''',
98 vtail : ''' { 0, NULL, NULL }
99 };
100
101 GType g_define_type_id =
102 g_@type@_register_static(g_intern_static_string("@EnumName@"), values);
103 g_once_init_leave(&static_g_define_type_id, g_define_type_id);
104 }
105
106 return static_g_define_type_id;
107 }
108 ''')
109
110 conf = configuration_data()
111 conf.set('ENUM_FILE', 'enums3.h')
112 main = configure_file(
113 input : 'main.c',
114 output : 'main3.c',
115 configuration : conf)
116
117 enumexe3 = executable('enumprog3', main, enums_c3, enums_h3,
118 dependencies : gobj)
119 test('enum test 3', enumexe3)
120
121 enums4 = gnome.mkenums_simple('enums4', sources : files('meson-sample.h'),
122 function_prefix : '_')
123 enumexe4 = executable('enumprog4', 'main4.c', enums4, dependencies : gobj)
124 test('enum test 4', enumexe4)
125
126 enums5 = gnome.mkenums_simple('enums5', sources : 'meson-sample.h',
127 install_header : true,
128 decorator : 'MESON_EXPORT',
129 header_prefix : '#include "meson-decls.h"')
130
131 conf = configuration_data()
132 conf.set('ENUM_FILE', 'enums5.h')
133 main = configure_file(
134 input : 'main.c',
135 output : 'main5.c',
136 configuration : conf)
137
138 enumexe5 = executable('enumprog5', main, enums5, dependencies : gobj)
139 test('enum test 5', enumexe5)
140
141 # Generate template then use as input to mkenums
142
143 gen_h_template = configure_file(input: 'enums.h.in',
144 output: 'enums6.h.in',
145 copy: true)
146
147 enums_h6 = gnome.mkenums('enums6',
148 sources : 'meson-sample.h',
149 h_template : gen_h_template,
150 ftail : '/* trailing header file info */',
151 install_header : true,
152 install_dir : get_option('includedir'))
153
154 conf = configuration_data()
155 conf.set('ENUM_FILE', 'enums6.h')
156 main = configure_file(
157 input : 'main.c',
158 output : 'main6.c',
159 configuration : conf)
160
161 enumexe6 = executable('enumprog6', main, enums_c2, enums_h6,
162 dependencies : gobj)
163 test('enum test 6', enumexe6)
164
165 # Test with headers coming from other directories
166 # https://github.com/mesonbuild/meson/pull/10855
167 subdir('subdir')
168 enums7 = gnome.mkenums_simple('enums7', sources: ['meson-sample.h', h2, h3])
169 main = configure_file(
170 input : 'main.c',
171 output : 'main7.c',
172 configuration : {'ENUM_FILE': 'enums7.h'})
173
174 enumexe7 = executable('enumprog7', main, enums7, dependencies : gobj)
175 test('enum test 7', enumexe7)