[glib/wip/meson: 36/53] meson: gio/tests: add more gresource tests



commit 9b7cd949ea871c110414f84e07cac328232a2a71
Author: Tim-Philipp Müller <tim centricular com>
Date:   Thu Feb 23 00:40:45 2017 +0000

    meson: gio/tests: add more gresource tests

 gio/meson.build       |    2 +-
 gio/tests/meson.build |   72 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 2 deletions(-)
---
diff --git a/gio/meson.build b/gio/meson.build
index c889900..1ac7597 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -779,7 +779,7 @@ executable('glib-compile-schemas',
   link_args : noseh_link_args,
   dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
 
-executable('glib-compile-resources',
+glib_compile_resources = executable('glib-compile-resources',
   [gconstructor_as_data_h, 'gvdb/gvdb-builder.c', 'glib-compile-resources.c'],
   install : true,
   c_args : ['-DHAVE_CONFIG_H=1'] + gio_c_args,
diff --git a/gio/tests/meson.build b/gio/tests/meson.build
index 3bc644a..1f9da53 100644
--- a/gio/tests/meson.build
+++ b/gio/tests/meson.build
@@ -182,7 +182,77 @@ foreach extra_program : uninstalled_test_extra_programs + test_extra_programs
       dependencies : [libglib_dep, libgmodule_dep, libgio_dep] + extra_deps)
 endforeach
 
-# FIXME: Add resources test
+if not meson.is_cross_build() or meson.has_exe_wrapper()
+
+  plugin_resources_c = custom_target('plugin-resources.c',
+    input : 'test4.gresource.xml',
+    output : 'plugin-resources.c',
+    command : [glib_compile_resources,
+               '--target=@OUTPUT@',
+               '--sourcedir=' + meson.current_source_dir(),
+               '--generate-source',
+               '--c-name', '_g_plugin',
+               '@INPUT@'])
+
+  # -module -export-dynamic + on win32_platform -no-undefined
+  shared_module ('resourceplugin', 'resourceplugin.c', plugin_resources_c,
+    link_args : ['-export-dynamic'],
+    dependencies : [libglib_dep, libgmodule_dep, libgio_dep])
+
+  test_gresource = custom_target('test.gresource',
+    input : 'test.gresource.xml',
+    output : 'test.gresource',
+    command : [glib_compile_resources,
+               '--target=@OUTPUT@',
+               '--sourcedir=' + meson.current_source_dir(),
+               '--sourcedir=' + meson.current_build_dir(),
+               '@INPUT@'])
+
+  test_resources2_c = custom_target('test_resources2.c',
+    input : 'test3.gresource.xml',
+    output : 'test_resources2.c',
+    command : [glib_compile_resources,
+               '--target=@OUTPUT@',
+               '--sourcedir=' + meson.current_source_dir(),
+               '--generate',
+               '--c-name', '_g_test2',
+               '--manual-register',
+               '@INPUT@'])
+
+  test_resources2_h = custom_target('test_resources2.h',
+    input : 'test3.gresource.xml',
+    output : 'test_resources2.h',
+    command : [glib_compile_resources,
+               '--target=@OUTPUT@',
+               '--sourcedir=' + meson.current_source_dir(),
+               '--generate',
+               '--c-name', '_g_test2',
+               '--manual-register',
+               '@INPUT@'])
+
+  test_resources_c = custom_target('test_resources.c',
+    input : 'test2.gresource.xml',
+    output : 'test_resources.c',
+    command : [glib_compile_resources,
+               '--target=@OUTPUT@',
+               '--sourcedir=' + meson.current_source_dir(),
+               '--generate-source',
+               '--c-name', '_g_test1',
+               '@INPUT@'])
+
+  # referenced by test.gresource.xml
+  test_generated_txt = configure_file(input : 'test1.txt',
+    output : 'test-generated.txt',
+    configuration : configuration_data(),
+    install : false)
+
+  exe = executable('resources', 'resources.c', test_gresource,
+      test_resources_c, test_resources2_c, test_resources2_h,
+      install : false,
+      c_args : test_c_args,
+      dependencies : [libglib_dep, libgmodule_dep, libgio_dep])
+  test('resources', exe, env : test_env)
+endif
 
 foo = '''
 c_args_atomic = [ ]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]