Parse contents of gresource xml and add deps manually. A bit of a hack but necessary due to missing upstream functionality. Closes #298.

pull/300/head
Jussi Pakkanen 9 years ago
parent c0070aadae
commit a16463972d
  1. 14
      build.py
  2. 28
      modules/gnome.py
  3. 9
      ninjabackend.py

@ -711,13 +711,16 @@ class CustomTarget:
'install' : True, 'install' : True,
'install_dir' : True, 'install_dir' : True,
'build_always' : True, 'build_always' : True,
'depends' : True} 'depends' : True,
'depend_files' : True,
}
def __init__(self, name, subdir, kwargs): def __init__(self, name, subdir, kwargs):
self.name = name self.name = name
self.subdir = subdir self.subdir = subdir
self.dependencies = [] self.dependencies = []
self.extra_depends = [] self.extra_depends = []
self.depend_files = [] # Files that this target depends on but are not on the command line.
self.process_kwargs(kwargs) self.process_kwargs(kwargs)
self.extra_files = [] self.extra_files = []
self.install_rpath = '' self.install_rpath = ''
@ -795,6 +798,15 @@ class CustomTarget:
if not isinstance(ed, CustomTarget) and not isinstance(ed, BuildTarget): if not isinstance(ed, CustomTarget) and not isinstance(ed, BuildTarget):
raise InvalidArguments('Can only depend on toplevel targets.') raise InvalidArguments('Can only depend on toplevel targets.')
self.extra_depends.append(ed) self.extra_depends.append(ed)
depend_files = kwargs.get('depend_files', [])
if not isinstance(depend_files, list):
depend_files = [depend_files]
for i in depend_files:
if isinstance(i, (File, str)):
self.depend_files.append(i)
else:
mlog.debug(i)
raise InvalidArguments('Unknown type in depend_files.')
def get_basename(self): def get_basename(self):
return self.name return self.name

@ -20,6 +20,7 @@ import os, sys
import subprocess import subprocess
from coredata import MesonException from coredata import MesonException
import mlog import mlog
import xml.etree.ElementTree as ET
girwarning_printed = False girwarning_printed = False
@ -36,13 +37,38 @@ class GnomeModule:
kwargs['command'] = cmd kwargs['command'] = cmd
output_c = args[0] + '.c' output_c = args[0] + '.c'
output_h = args[0] + '.h' output_h = args[0] + '.h'
kwargs['input'] = args[1] resfile = args[1]
kwargs['depend_files'] = self.parse_gresource_xml(state, resfile)
kwargs['input'] = resfile
kwargs['output'] = output_c kwargs['output'] = output_c
target_c = build.CustomTarget(args[0]+'_c', state.subdir, kwargs) target_c = build.CustomTarget(args[0]+'_c', state.subdir, kwargs)
kwargs['output'] = output_h kwargs['output'] = output_h
target_h = build.CustomTarget(args[0] + '_h', state.subdir, kwargs) target_h = build.CustomTarget(args[0] + '_h', state.subdir, kwargs)
return [target_c, target_h] return [target_c, target_h]
def parse_gresource_xml(self, state, fname):
abspath = os.path.join(state.environment.source_dir, state.subdir, fname)
relative_part = os.path.split(fname)[0]
resdir = os.path.join(state.subdir, 'data')
try:
tree = ET.parse(abspath)
root = tree.getroot()
result = []
for child in root[0]:
if child.tag != 'file':
mlog.log("Warning, malformed rcc file: ", os.path.join(state.subdir, fname))
break
else:
relfname = os.path.join(resdir, child.text)
absfname = os.path.join(state.environment.source_dir, relfname)
if os.path.isfile(absfname):
result.append(relfname)
else:
mlog.log('Warning, resource file points to nonexisting file %s.' % relfname)
return result
except Exception:
return []
def generate_gir(self, state, args, kwargs): def generate_gir(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise MesonException('Gir takes one argument') raise MesonException('Gir takes one argument')

@ -300,10 +300,15 @@ class NinjaBackend(backends.Backend):
srcs.append(os.path.join(self.build_to_src, target.subdir, i)) srcs.append(os.path.join(self.build_to_src, target.subdir, i))
else: else:
srcs.append(i.rel_to_builddir(self.build_to_src)) srcs.append(i.rel_to_builddir(self.build_to_src))
deps += srcs
if target.build_always: if target.build_always:
deps.append('PHONY') deps.append('PHONY')
elem = NinjaBuildElement(ofilenames, 'CUSTOM_COMMAND', deps) elem = NinjaBuildElement(ofilenames, 'CUSTOM_COMMAND', srcs)
for i in target.depend_files:
if isinstance(i, mesonlib.File):
deps.append(i.rel_to_builddir(self.build_to_src))
else:
deps.append(os.path.join(self.build_to_src, i))
elem.add_dep(deps)
for d in target.extra_depends: for d in target.extra_depends:
tmp = d.get_filename() tmp = d.get_filename()
if not isinstance(tmp, list): if not isinstance(tmp, list):

Loading…
Cancel
Save