aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-12-03 22:59:27 +0200
committerGitHub <noreply@github.com>2016-12-03 22:59:27 +0200
commit8e8f75005db38daf2e54bc76c4542b74f2f7cefe (patch)
treef2c17763fe18837d70e7104d8776534d0c54814c
parent10e2b9bca0016c5af87ec1647f29b5916304546b (diff)
parent9a6db2eb2f1acf3111371516c56eae0e7a69de13 (diff)
downloadmeson-8e8f75005db38daf2e54bc76c4542b74f2f7cefe.zip
meson-8e8f75005db38daf2e54bc76c4542b74f2f7cefe.tar.gz
meson-8e8f75005db38daf2e54bc76c4542b74f2f7cefe.tar.bz2
Merge pull request #1076 from mesonbuild/tingping/gresource-export
gnome.compile_resources(): Add export and install_header kwargs
-rw-r--r--mesonbuild/modules/gnome.py32
-rw-r--r--test cases/frameworks/7 gnome/installed_files.txt2
-rw-r--r--test cases/frameworks/7 gnome/resources/meson.build11
-rw-r--r--test cases/frameworks/7 gnome/resources/resources.py10
4 files changed, 53 insertions, 2 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 38b3319..d7b05eb 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -111,12 +111,33 @@ can not be used with the current version of glib-compiled-resources, due to
if 'c_name' in kwargs:
cmd += ['--c-name', kwargs.pop('c_name')]
+ export = kwargs.pop('export', False)
+ if not export:
+ cmd += ['--internal']
+
cmd += ['--generate', '--target', '@OUTPUT@']
cmd += mesonlib.stringlistify(kwargs.pop('extra_args', []))
+ gresource = kwargs.pop('gresource_bundle', False)
+ if gresource:
+ output = args[0] + '.gresource'
+ name = args[0] + '_gresource'
+ else:
+ output = args[0] + '.c'
+ name = args[0] + '_c'
+
+ if kwargs.get('install', False) and not gresource:
+ raise MesonException('The install kwarg only applies to gresource bundles, see install_header')
+
+ install_header = kwargs.pop('install_header', False)
+ if install_header and gresource:
+ raise MesonException('The install_header kwarg does not apply to gresource bundles')
+ if install_header and not export:
+ raise MesonException('GResource header is installed yet export is not enabled')
+
kwargs['input'] = args[1]
- kwargs['output'] = args[0] + '.c'
+ kwargs['output'] = output
kwargs['depends'] = depends
if not mesonlib.version_compare(glib_version, gresource_dep_needed_version):
# This will eventually go out of sync if dependencies are added
@@ -126,7 +147,10 @@ can not be used with the current version of glib-compiled-resources, due to
depfile = kwargs['output'] + '.d'
kwargs['depfile'] = depfile
kwargs['command'] = copy.copy(cmd) + ['--dependency-file', '@DEPFILE@']
- target_c = build.CustomTarget(args[0] + '_c', state.subdir, kwargs)
+ target_c = build.CustomTarget(name, state.subdir, kwargs)
+
+ if gresource: # Only one target for .gresource files
+ return [target_c]
h_kwargs = {
'command': cmd,
@@ -135,6 +159,10 @@ can not be used with the current version of glib-compiled-resources, due to
# The header doesn't actually care about the files yet it errors if missing
'depends': depends
}
+ if install_header:
+ h_kwargs['install'] = install_header
+ h_kwargs['install_dir'] = kwargs.get('install_dir',
+ state.environment.coredata.get_builtin_option('includedir'))
target_h = build.CustomTarget(args[0] + '_h', state.subdir, h_kwargs)
return [target_c, target_h]
diff --git a/test cases/frameworks/7 gnome/installed_files.txt b/test cases/frameworks/7 gnome/installed_files.txt
index 06f4163..d0d51d5 100644
--- a/test cases/frameworks/7 gnome/installed_files.txt
+++ b/test cases/frameworks/7 gnome/installed_files.txt
@@ -12,3 +12,5 @@ usr/share/gir-1.0/Meson-1.0.gir
usr/share/gir-1.0/MesonDep1-1.0.gir
usr/share/gir-1.0/MesonDep2-1.0.gir
usr/share/glib-2.0/schemas/com.github.meson.gschema.xml
+usr/share/simple-resources.gresource
+usr/include/simple-resources.h
diff --git a/test cases/frameworks/7 gnome/resources/meson.build b/test cases/frameworks/7 gnome/resources/meson.build
index f17e469..2e72501 100644
--- a/test cases/frameworks/7 gnome/resources/meson.build
+++ b/test cases/frameworks/7 gnome/resources/meson.build
@@ -3,6 +3,8 @@
simple_resources = gnome.compile_resources('simple-resources',
'simple.gresource.xml',
+ install_header : true,
+ export : true,
source_dir : '../resources-data',
c_name : 'simple_resources')
@@ -11,6 +13,15 @@ simple_res_exe = executable('simple-resources-test',
dependencies: gio)
test('simple resource test', simple_res_exe)
+gnome.compile_resources('simple-resources',
+ 'simple.gresource.xml',
+ gresource_bundle: true,
+ install: true,
+ install_dir: get_option('datadir'),
+ source_dir : '../resources-data',
+)
+test('simple resource test (gresource)', find_program('resources.py'))
+
if glib.version() >= '2.52.0'
# This test cannot pass if GLib version is older than 9.99.9.
# Meson will raise an error if the user tries to use the 'dependencies'
diff --git a/test cases/frameworks/7 gnome/resources/resources.py b/test cases/frameworks/7 gnome/resources/resources.py
new file mode 100644
index 0000000..b351b04
--- /dev/null
+++ b/test cases/frameworks/7 gnome/resources/resources.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+import os
+from gi.repository import Gio
+
+if __name__ == '__main__':
+ res = Gio.resource_load(os.path.join('resources', 'simple-resources.gresource'))
+ Gio.Resource._register(res)
+
+ data = Gio.resources_lookup_data('/com/example/myprog/res1.txt', Gio.ResourceLookupFlags.NONE)
+ assert(data.get_data() == b'This is a resource.\n')