aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/vala/8 generated sources
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /meson/test cases/vala/8 generated sources
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/vala/8 generated sources')
-rw-r--r--meson/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template43
-rw-r--r--meson/test cases/vala/8 generated sources/dependency-generated/enum-types.h.template26
-rw-r--r--meson/test cases/vala/8 generated sources/dependency-generated/enums.h15
-rw-r--r--meson/test cases/vala/8 generated sources/dependency-generated/lib.vala3
-rw-r--r--meson/test cases/vala/8 generated sources/dependency-generated/main.vala3
-rw-r--r--meson/test cases/vala/8 generated sources/dependency-generated/meson.build44
-rw-r--r--meson/test cases/vala/8 generated sources/dependency-generated/null.c1
-rw-r--r--meson/test cases/vala/8 generated sources/meson.build14
-rw-r--r--meson/test cases/vala/8 generated sources/onlygen/maingen.in3
-rw-r--r--meson/test cases/vala/8 generated sources/onlygen/meson.build7
-rw-r--r--meson/test cases/vala/8 generated sources/src/config.vala.in3
-rw-r--r--meson/test cases/vala/8 generated sources/src/copy_file.py6
-rw-r--r--meson/test cases/vala/8 generated sources/src/meson.build17
-rw-r--r--meson/test cases/vala/8 generated sources/src/returncode.in3
-rw-r--r--meson/test cases/vala/8 generated sources/src/test.vala4
-rw-r--r--meson/test cases/vala/8 generated sources/src/write_wrapper.py12
-rw-r--r--meson/test cases/vala/8 generated sources/test.json7
-rw-r--r--meson/test cases/vala/8 generated sources/tools/meson.build3
18 files changed, 214 insertions, 0 deletions
diff --git a/meson/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template b/meson/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template
new file mode 100644
index 000000000..85d74d11c
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template
@@ -0,0 +1,43 @@
+/*** BEGIN file-header ***/
+
+#include "enum-types.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+#include "@filename@"
+/*** END file-production ***/
+
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+ static gsize static_g_define_type_id = 0;
+
+ if (g_once_init_enter (&static_g_define_type_id)) {
+ 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 (&static_g_define_type_id, g_define_type_id);
+ }
+
+ return static_g_define_type_id;
+}
+
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+
+/*** END file-tail ***/
diff --git a/meson/test cases/vala/8 generated sources/dependency-generated/enum-types.h.template b/meson/test cases/vala/8 generated sources/dependency-generated/enum-types.h.template
new file mode 100644
index 000000000..e5478ab43
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/dependency-generated/enum-types.h.template
@@ -0,0 +1,26 @@
+/*** BEGIN file-header ***/
+
+#ifndef __EXAMPLE_ENUMS_TYPES_H__
+#define __EXAMPLE_ENUMS_TYPES_H__
+
+#include <glib-object.h>
+#include "enums.h"
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define EXAMPLE_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __EXAMPLE_ENUMS_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/meson/test cases/vala/8 generated sources/dependency-generated/enums.h b/meson/test cases/vala/8 generated sources/dependency-generated/enums.h
new file mode 100644
index 000000000..3fb621eb8
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/dependency-generated/enums.h
@@ -0,0 +1,15 @@
+#ifndef __EXAMPLE_ENUMS_H__
+#define __EXAMPLE_ENUMS_H__
+
+G_BEGIN_DECLS
+
+typedef enum {
+ EXAMPLE_VERBOSITY_ERRORS,
+ EXAMPLE_VERBOSITY_MINIMAL,
+ EXAMPLE_VERBOSITY_DETAILED,
+ EXAMPLE_VERBOSITY_DEBUG,
+} ExampleVerbosity;
+
+G_END_DECLS
+
+#endif /* __EXAMPLE_ENUMS_H__ */
diff --git a/meson/test cases/vala/8 generated sources/dependency-generated/lib.vala b/meson/test cases/vala/8 generated sources/dependency-generated/lib.vala
new file mode 100644
index 000000000..3fcbb7fa7
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/dependency-generated/lib.vala
@@ -0,0 +1,3 @@
+int whatever() {
+ return 0;
+}
diff --git a/meson/test cases/vala/8 generated sources/dependency-generated/main.vala b/meson/test cases/vala/8 generated sources/dependency-generated/main.vala
new file mode 100644
index 000000000..33c14ce1d
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/dependency-generated/main.vala
@@ -0,0 +1,3 @@
+int main() {
+ return 0;
+}
diff --git a/meson/test cases/vala/8 generated sources/dependency-generated/meson.build b/meson/test cases/vala/8 generated sources/dependency-generated/meson.build
new file mode 100644
index 000000000..a1895b4f7
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/dependency-generated/meson.build
@@ -0,0 +1,44 @@
+# Test that dependencies with their own generated sources don't
+# confuse the Vala build instruction generator.
+
+# Test case for https://github.com/mesonbuild/meson/issues/1084
+
+gnome = import('gnome')
+
+gobject = dependency('gobject-2.0')
+
+enums = gnome.mkenums('enum-types',
+ sources: 'enums.h',
+ c_template: 'enum-types.c.template',
+ h_template: 'enum-types.h.template',
+)
+
+libcommon = library('common',
+ enums[0], enums[1],
+ dependencies: gobject)
+
+common_dep = declare_dependency(
+ # This is required so that whoever depends on this also depends
+ # on the generated header; that won't happen implicitly.
+ # See: https://github.com/mesonbuild/meson/issues/1084
+ sources: enums[1],
+ link_with: libcommon,
+)
+
+libplover_vala = library('plover',
+ 'lib.vala',
+ dependencies: [common_dep, gobject]
+)
+
+plover_dep = declare_dependency(
+ link_with: libplover_vala,
+ dependencies: common_dep
+)
+
+vala_prog = executable('hello',
+ 'main.vala',
+ link_with: libplover_vala,
+ # There's no need to specify common_dep here since plover_dep pulls it
+ # in, but it should be harmless to do so.
+ dependencies: [common_dep, plover_dep, gobject]
+)
diff --git a/meson/test cases/vala/8 generated sources/dependency-generated/null.c b/meson/test cases/vala/8 generated sources/dependency-generated/null.c
new file mode 100644
index 000000000..8337712ea
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/dependency-generated/null.c
@@ -0,0 +1 @@
+//
diff --git a/meson/test cases/vala/8 generated sources/meson.build b/meson/test cases/vala/8 generated sources/meson.build
new file mode 100644
index 000000000..711a93a6f
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/meson.build
@@ -0,0 +1,14 @@
+project('mytest', 'vala', 'c')
+
+cd = configuration_data()
+cd.set('x', 'y')
+
+subdir('src')
+
+executable('generatedtestparent', [src, config, returncode, wrapper],
+ install : true,
+ dependencies: [dependency('glib-2.0'), dependency('gobject-2.0')])
+
+subdir('tools')
+subdir('onlygen')
+subdir('dependency-generated')
diff --git a/meson/test cases/vala/8 generated sources/onlygen/maingen.in b/meson/test cases/vala/8 generated sources/onlygen/maingen.in
new file mode 100644
index 000000000..33c14ce1d
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/onlygen/maingen.in
@@ -0,0 +1,3 @@
+int main() {
+ return 0;
+}
diff --git a/meson/test cases/vala/8 generated sources/onlygen/meson.build b/meson/test cases/vala/8 generated sources/onlygen/meson.build
new file mode 100644
index 000000000..f48e0b887
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/onlygen/meson.build
@@ -0,0 +1,7 @@
+onlygen = generator(copy,
+ output : '@BASENAME@.vala',
+ arguments : ['@INPUT@', '@OUTPUT@'])
+
+executable('onlygentest', onlygen.process('maingen.in'),
+ install : true,
+ dependencies: [dependency('glib-2.0'), dependency('gobject-2.0')])
diff --git a/meson/test cases/vala/8 generated sources/src/config.vala.in b/meson/test cases/vala/8 generated sources/src/config.vala.in
new file mode 100644
index 000000000..a5196fdf1
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/src/config.vala.in
@@ -0,0 +1,3 @@
+namespace Config {
+ public static const string x = "@x@";
+}
diff --git a/meson/test cases/vala/8 generated sources/src/copy_file.py b/meson/test cases/vala/8 generated sources/src/copy_file.py
new file mode 100644
index 000000000..ff42ac359
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/src/copy_file.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+
+import sys
+import shutil
+
+shutil.copyfile(sys.argv[1], sys.argv[2])
diff --git a/meson/test cases/vala/8 generated sources/src/meson.build b/meson/test cases/vala/8 generated sources/src/meson.build
new file mode 100644
index 000000000..06515c191
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/src/meson.build
@@ -0,0 +1,17 @@
+config = configure_file(input: 'config.vala.in',
+ output: 'config.vala',
+ configuration: cd)
+
+print = find_program('write_wrapper.py')
+wrapper = custom_target('wrapper',
+ output : 'print_wrapper.vala',
+ command : [print, '@OUTPUT@'])
+
+copy = find_program('copy_file.py')
+gen = generator(copy,
+ output : '@BASENAME@.vala',
+ arguments : ['@INPUT@', '@OUTPUT@'])
+
+returncode = gen.process('returncode.in')
+
+src = files('test.vala')
diff --git a/meson/test cases/vala/8 generated sources/src/returncode.in b/meson/test cases/vala/8 generated sources/src/returncode.in
new file mode 100644
index 000000000..e3d3ea64e
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/src/returncode.in
@@ -0,0 +1,3 @@
+int return_code() {
+ return 0;
+}
diff --git a/meson/test cases/vala/8 generated sources/src/test.vala b/meson/test cases/vala/8 generated sources/src/test.vala
new file mode 100644
index 000000000..ca276761a
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/src/test.vala
@@ -0,0 +1,4 @@
+int main() {
+ print_wrapper (Config.x);
+ return return_code ();
+}
diff --git a/meson/test cases/vala/8 generated sources/src/write_wrapper.py b/meson/test cases/vala/8 generated sources/src/write_wrapper.py
new file mode 100644
index 000000000..b5608f7a3
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/src/write_wrapper.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import sys
+
+contents = '''
+void print_wrapper(string arg) {
+ print (arg);
+}
+'''
+
+with open(sys.argv[1], 'w') as f:
+ f.write(contents)
diff --git a/meson/test cases/vala/8 generated sources/test.json b/meson/test cases/vala/8 generated sources/test.json
new file mode 100644
index 000000000..d99a6cede
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/test.json
@@ -0,0 +1,7 @@
+{
+ "installed": [
+ {"type": "exe", "file": "usr/bin/generatedtestparent"},
+ {"type": "exe", "file": "usr/bin/generatedtest"},
+ {"type": "exe", "file": "usr/bin/onlygentest"}
+ ]
+}
diff --git a/meson/test cases/vala/8 generated sources/tools/meson.build b/meson/test cases/vala/8 generated sources/tools/meson.build
new file mode 100644
index 000000000..303468e32
--- /dev/null
+++ b/meson/test cases/vala/8 generated sources/tools/meson.build
@@ -0,0 +1,3 @@
+executable('generatedtest', [src, config, returncode, wrapper],
+ install : true,
+ dependencies: [dependency('glib-2.0'), dependency('gobject-2.0')])