diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
commit | 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch) | |
tree | 4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/vala/8 generated sources | |
parent | Initial commit. (diff) | |
download | meson-upstream.tar.xz meson-upstream.zip |
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/vala/8 generated sources')
18 files changed, 214 insertions, 0 deletions
diff --git a/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template b/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template new file mode 100644 index 0000000..9d45a93 --- /dev/null +++ b/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/test cases/vala/8 generated sources/dependency-generated/enum-types.h.template b/test cases/vala/8 generated sources/dependency-generated/enum-types.h.template new file mode 100644 index 0000000..e5478ab --- /dev/null +++ b/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/test cases/vala/8 generated sources/dependency-generated/enums.h b/test cases/vala/8 generated sources/dependency-generated/enums.h new file mode 100644 index 0000000..3fb621e --- /dev/null +++ b/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/test cases/vala/8 generated sources/dependency-generated/lib.vala b/test cases/vala/8 generated sources/dependency-generated/lib.vala new file mode 100644 index 0000000..3fcbb7f --- /dev/null +++ b/test cases/vala/8 generated sources/dependency-generated/lib.vala @@ -0,0 +1,3 @@ +int whatever() { + return 0; +} diff --git a/test cases/vala/8 generated sources/dependency-generated/main.vala b/test cases/vala/8 generated sources/dependency-generated/main.vala new file mode 100644 index 0000000..33c14ce --- /dev/null +++ b/test cases/vala/8 generated sources/dependency-generated/main.vala @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/test cases/vala/8 generated sources/dependency-generated/meson.build b/test cases/vala/8 generated sources/dependency-generated/meson.build new file mode 100644 index 0000000..a1895b4 --- /dev/null +++ b/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/test cases/vala/8 generated sources/dependency-generated/null.c b/test cases/vala/8 generated sources/dependency-generated/null.c new file mode 100644 index 0000000..8337712 --- /dev/null +++ b/test cases/vala/8 generated sources/dependency-generated/null.c @@ -0,0 +1 @@ +// diff --git a/test cases/vala/8 generated sources/meson.build b/test cases/vala/8 generated sources/meson.build new file mode 100644 index 0000000..711a93a --- /dev/null +++ b/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/test cases/vala/8 generated sources/onlygen/maingen.in b/test cases/vala/8 generated sources/onlygen/maingen.in new file mode 100644 index 0000000..33c14ce --- /dev/null +++ b/test cases/vala/8 generated sources/onlygen/maingen.in @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/test cases/vala/8 generated sources/onlygen/meson.build b/test cases/vala/8 generated sources/onlygen/meson.build new file mode 100644 index 0000000..f48e0b8 --- /dev/null +++ b/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/test cases/vala/8 generated sources/src/config.vala.in b/test cases/vala/8 generated sources/src/config.vala.in new file mode 100644 index 0000000..a5196fd --- /dev/null +++ b/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/test cases/vala/8 generated sources/src/copy_file.py b/test cases/vala/8 generated sources/src/copy_file.py new file mode 100644 index 0000000..ff42ac3 --- /dev/null +++ b/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/test cases/vala/8 generated sources/src/meson.build b/test cases/vala/8 generated sources/src/meson.build new file mode 100644 index 0000000..06515c1 --- /dev/null +++ b/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/test cases/vala/8 generated sources/src/returncode.in b/test cases/vala/8 generated sources/src/returncode.in new file mode 100644 index 0000000..e3d3ea6 --- /dev/null +++ b/test cases/vala/8 generated sources/src/returncode.in @@ -0,0 +1,3 @@ +int return_code() { + return 0; +} diff --git a/test cases/vala/8 generated sources/src/test.vala b/test cases/vala/8 generated sources/src/test.vala new file mode 100644 index 0000000..ca27676 --- /dev/null +++ b/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/test cases/vala/8 generated sources/src/write_wrapper.py b/test cases/vala/8 generated sources/src/write_wrapper.py new file mode 100644 index 0000000..b5608f7 --- /dev/null +++ b/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/test cases/vala/8 generated sources/test.json b/test cases/vala/8 generated sources/test.json new file mode 100644 index 0000000..d99a6ce --- /dev/null +++ b/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/test cases/vala/8 generated sources/tools/meson.build b/test cases/vala/8 generated sources/tools/meson.build new file mode 100644 index 0000000..303468e --- /dev/null +++ b/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')]) |