Pass --gresources to valac for each compiled gresource

Without this, the user has to both compile the resource with
gnome.compile_resources, pass that to the target sources, and also
pass --gresources=/path/to/gres.xml to vala_args in the target.

With this, we will do that automatically.
pull/1194/head
Nirbheek Chauhan 8 years ago
parent 807a53c6fc
commit 79f6626867
  1. 35
      mesonbuild/backend/backends.py
  2. 5
      mesonbuild/backend/ninjabackend.py
  3. 3
      mesonbuild/modules/gnome.py

@ -504,19 +504,13 @@ class Backend():
libs.append(os.path.join(self.get_target_dir(t), f))
return libs
def eval_custom_target_command(self, target, absolute_paths=False):
if not absolute_paths:
ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output]
else:
ofilenames = [os.path.join(self.environment.get_build_dir(), self.get_target_dir(target), i) \
for i in target.output]
def get_custom_target_sources(self, target, absolute_paths=False):
'''
Custom target sources can be of various object types; strings, File,
BuildTarget, even other CustomTargets.
Returns the path to them relative to the build root directory.
'''
srcs = []
outdir = self.get_target_dir(target)
# Many external programs fail on empty arguments.
if outdir == '':
outdir = '.'
if absolute_paths:
outdir = os.path.join(self.environment.get_build_dir(), outdir)
for i in target.get_sources():
if hasattr(i, 'held_object'):
i = i.held_object
@ -531,8 +525,23 @@ class Backend():
else:
fname = [i.rel_to_builddir(self.build_to_src)]
if absolute_paths:
fname =[os.path.join(self.environment.get_build_dir(), f) for f in fname]
fname = [os.path.join(self.environment.get_build_dir(), f) for f in fname]
srcs += fname
return srcs
def eval_custom_target_command(self, target, absolute_paths=False):
if not absolute_paths:
ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output]
else:
ofilenames = [os.path.join(self.environment.get_build_dir(), self.get_target_dir(target), i) \
for i in target.output]
srcs = self.get_custom_target_sources(target, absolute_paths)
outdir = self.get_target_dir(target)
# Many external programs fail on empty arguments.
if outdir == '':
outdir = '.'
if absolute_paths:
outdir = os.path.join(self.environment.get_build_dir(), outdir)
cmd = []
for i in target.command:
if isinstance(i, build.Executable):

@ -1032,6 +1032,11 @@ int dummy;
args += ['--pkg', d.name]
elif isinstance(d, dependencies.ExternalLibrary):
args += d.get_lang_args('vala')
# Detect gresources and add --gresources arguments for each
for (gres, gensrc) in other_src[1].items():
if hasattr(gensrc, 'gresource_c_output'):
gres_xml, = self.get_custom_target_sources(gensrc)
args += ['--gresources=' + gres_xml]
extra_args = []
for a in target.extra_args.get('vala', []):

@ -162,6 +162,9 @@ can not be used with the current version of glib-compiled-resources, due to
kwargs['depfile'] = depfile
kwargs['command'] = copy.copy(cmd) + ['--dependency-file', '@DEPFILE@']
target_c = build.CustomTarget(name, state.subdir, kwargs)
# Used in backend/ninjabackend.py:generate_vala_compile() to pass
# --gresources to valac when GResources are used in Vala targets
target_c.gresource_c_output = True
if gresource: # Only one target for .gresource files
return [target_c]

Loading…
Cancel
Save