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
pull/1403/head
Nirbheek Chauhan 8 years ago
parent cb0aa6a83a
commit dabf0c1882
  1. 13
      mesonbuild/modules/gnome.py
  2. 6
      test cases/frameworks/7 gnome/resources/copyfile.py
  3. 11
      test cases/frameworks/7 gnome/resources/meson.build

@ -105,7 +105,13 @@ can not be used with the current version of glib-compiled-resources, due to
ifile = args[1] ifile = args[1]
if isinstance(ifile, mesonlib.File): 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): elif isinstance(ifile, str):
ifile = os.path.join(state.subdir, ifile) ifile = os.path.join(state.subdir, ifile)
elif isinstance(ifile, (interpreter.CustomTargetHolder, 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', os.path.join(state.subdir, source_dir)]
cmd += ['--sourcedir', state.subdir] # Current 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: 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) raise subprocess.CalledProcessError(pc.returncode, cmd)
dep_files = stdout.split('\n')[:-1] dep_files = stdout.split('\n')[:-1]

@ -0,0 +1,6 @@
#!/usr/bin/env python3
import sys
import shutil
shutil.copy(sys.argv[1], sys.argv[2])

@ -1,8 +1,15 @@
# There are two tests here, because the 2nd one depends on a version of # 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_resources = gnome.compile_resources('simple-resources',
'simple.gresource.xml', simple_gresource,
install_header : true, install_header : true,
export : true, export : true,
source_dir : '../resources-data', source_dir : '../resources-data',

Loading…
Cancel
Save