aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-02-19 08:20:06 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-02-20 23:32:04 +0530
commitdabf0c1882772700fed2c6c18ca06919a8bc280d (patch)
tree2162f117ab22017d4c83016f8e6a2f116e76dc0c
parentcb0aa6a83a53afd61572219c1a81f1395d4c4603 (diff)
downloadmeson-dabf0c1882772700fed2c6c18ca06919a8bc280d.zip
meson-dabf0c1882772700fed2c6c18ca06919a8bc280d.tar.gz
meson-dabf0c1882772700fed2c6c18ca06919a8bc280d.tar.bz2
gnome: Support configure_file() output in compile_resources
We can't support generated XML files with custom_target() because the dependency scanning happens at configure time, but we *can* support generating them with configure_file(). Closes https://github.com/mesonbuild/meson/issues/1380
-rw-r--r--mesonbuild/modules/gnome.py13
-rw-r--r--test cases/frameworks/7 gnome/resources/copyfile.py6
-rw-r--r--test cases/frameworks/7 gnome/resources/meson.build11
3 files changed, 25 insertions, 5 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 7338205..4687e81 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -105,7 +105,13 @@ can not be used with the current version of glib-compiled-resources, due to
ifile = args[1]
if isinstance(ifile, mesonlib.File):
- ifile = os.path.join(ifile.subdir, ifile.fname)
+ # glib-compile-resources will be run inside the source dir,
+ # so we need either 'src_to_build' or the absolute path.
+ # Absolute path is the easiest choice.
+ if ifile.is_built:
+ ifile = os.path.join(state.environment.get_build_dir(), ifile.subdir, ifile.fname)
+ else:
+ ifile = os.path.join(ifile.subdir, ifile.fname)
elif isinstance(ifile, str):
ifile = os.path.join(state.subdir, ifile)
elif isinstance(ifile, (interpreter.CustomTargetHolder,
@@ -206,9 +212,10 @@ can not be used with the current version of glib-compiled-resources, due to
cmd += ['--sourcedir', os.path.join(state.subdir, source_dir)]
cmd += ['--sourcedir', state.subdir] # Current dir
- pc, stdout = Popen_safe(cmd, cwd=state.environment.get_source_dir())[0:2]
+ pc, stdout, stderr = Popen_safe(cmd, cwd=state.environment.get_source_dir())
if pc.returncode != 0:
- mlog.warning('glib-compile-resources has failed to get the dependencies for {}'.format(cmd[1]))
+ m = 'glib-compile-resources failed to get dependencies for {}:\n{}'
+ mlog.warning(m.format(cmd[1], stderr))
raise subprocess.CalledProcessError(pc.returncode, cmd)
dep_files = stdout.split('\n')[:-1]
diff --git a/test cases/frameworks/7 gnome/resources/copyfile.py b/test cases/frameworks/7 gnome/resources/copyfile.py
new file mode 100644
index 0000000..7e44c48
--- /dev/null
+++ b/test cases/frameworks/7 gnome/resources/copyfile.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+
+import sys
+import shutil
+
+shutil.copy(sys.argv[1], sys.argv[2])
diff --git a/test cases/frameworks/7 gnome/resources/meson.build b/test cases/frameworks/7 gnome/resources/meson.build
index 2e72501..fdf6f63 100644
--- a/test cases/frameworks/7 gnome/resources/meson.build
+++ b/test cases/frameworks/7 gnome/resources/meson.build
@@ -1,8 +1,15 @@
# There are two tests here, because the 2nd one depends on a version of
-# GLib (2.48.2) that is very recent at the time of writing.
+# GLib (2.51.1) that is very recent at the time of writing.
+
+copyfile = find_program('copyfile.py')
+
+simple_gresource = configure_file(
+ input : 'simple.gresource.xml',
+ output : 'simple-gen.gresource.xml',
+ command : [copyfile, '@INPUT@', '@OUTPUT@'])
simple_resources = gnome.compile_resources('simple-resources',
- 'simple.gresource.xml',
+ simple_gresource,
install_header : true,
export : true,
source_dir : '../resources-data',