diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-11-10 14:08:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-10 14:08:32 -0500 |
commit | fd425d56a5680ab48d1cd03a140c249d90999a09 (patch) | |
tree | f5d30a2cd368d89127dc742119aa3367f9abe2c9 | |
parent | dc10945ad7cd210426091a9e7809c90a9ff0b175 (diff) | |
parent | c7226462a2d9cd45be406017592a3a5107b52642 (diff) | |
download | meson-fd425d56a5680ab48d1cd03a140c249d90999a09.zip meson-fd425d56a5680ab48d1cd03a140c249d90999a09.tar.gz meson-fd425d56a5680ab48d1cd03a140c249d90999a09.tar.bz2 |
Merge pull request #991 from mesonbuild/wip/tingping/gresource-depfile
gnome: Use depfile support of recent glib-compile-resources
-rw-r--r-- | mesonbuild/backend/backends.py | 5 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 4 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 61 |
3 files changed, 42 insertions, 28 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 5cc2442..2861bb6 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -599,10 +599,7 @@ class Backend(): elif '@DEPFILE@' in i: if target.depfile is None: raise MesonException('Custom target %s has @DEPFILE@ but no depfile keyword argument.' % target.name) - if absolute_paths: - dfilename = os.path.join(self.get_target_private_dir_abs(target), target.depfile) - else: - dfilename = os.path.join(self.get_target_private_dir(target), target.depfile) + dfilename = os.path.join(outdir, target.depfile) i = i.replace('@DEPFILE@', dfilename) elif '@PRIVATE_OUTDIR_' in i: match = re.search('@PRIVATE_OUTDIR_(ABS_)?([-a-zA-Z0-9.@:]*)@', i) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index af96f3d..3d378fe 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -494,8 +494,8 @@ int dummy; cmd_type = 'custom' if target.depfile is not None: - rel_dfile = os.path.join(self.get_target_private_dir(target), target.depfile) - abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_private_dir(target)) + rel_dfile = os.path.join(self.get_target_dir(target), target.depfile) + abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) os.makedirs(abs_pdir, exist_ok=True) elem.add_item('DEPFILE', rel_dfile) elem.add_item('COMMAND', cmd) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index fa8aec4..f3f22bc 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -18,6 +18,7 @@ functionality such as gobject-introspection and gresources.''' from .. import build import os import sys +import copy import subprocess from ..mesonlib import MesonException from .. import dependencies @@ -43,9 +44,9 @@ class GnomeModule: def __print_gresources_warning(self, state): global gresource_warning_printed if not gresource_warning_printed: - if mesonlib.version_compare(self._get_native_glib_version(state), '< 2.50.0'): + if mesonlib.version_compare(self._get_native_glib_version(state), '< 2.50.2'): mlog.warning('GLib compiled dependencies do not work fully ' - 'with versions of GLib older than 2.50.0.\n' + 'with versions of GLib older than 2.50.2.\n' 'See the following upstream issue:', mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=745754')) gresource_warning_printed = True @@ -60,9 +61,6 @@ class GnomeModule: if not isinstance(source_dirs, list): source_dirs = [source_dirs] - # Always include current directory, but after paths set by user - source_dirs.append(os.path.join(state.environment.get_source_dir(), state.subdir)) - if len(args) < 2: raise MesonException('Not enough arguments; The name of the resource and the path to the XML file are required') @@ -70,8 +68,8 @@ class GnomeModule: if not isinstance(dependencies, list): dependencies = [dependencies] - if mesonlib.version_compare(self._get_native_glib_version(state), - '< 2.48.2'): + glib_version = self._get_native_glib_version(state) + if mesonlib.version_compare(glib_version, '< 2.48.2'): if len(dependencies) > 0: raise MesonException( 'The "dependencies" argument of gnome.compile_resources() ' @@ -87,18 +85,18 @@ class GnomeModule: else: raise RuntimeError('Unreachable code.') - kwargs['depend_files'] = self._get_gresource_dependencies( + depend_files, depends, subdirs = self._get_gresource_dependencies( state, ifile, source_dirs, dependencies) - for source_dir in source_dirs: - sourcedir = os.path.join(state.build_to_src, state.subdir, source_dir) - cmd += ['--sourcedir', sourcedir] + # Make source dirs relative to build dir now + source_dirs = [os.path.join(state.build_to_src, state.subdir, d) for d in source_dirs] + # Always include current directory, but after paths set by user + source_dirs.append(os.path.join(state.build_to_src, state.subdir)) + # Ensure build directories of generated deps are included + source_dirs += subdirs - if len(dependencies) > 0: - # Add the build variant of each sourcedir if we have any - # generated dependencies. - sourcedir = os.path.join(state.subdir, source_dir) - cmd += ['--sourcedir', sourcedir] + for source_dir in set(source_dirs): + cmd += ['--sourcedir', source_dir] if 'c_name' in kwargs: cmd += ['--c-name', kwargs.pop('c_name')] @@ -106,17 +104,30 @@ class GnomeModule: cmd += mesonlib.stringlistify(kwargs.pop('extra_args', [])) - kwargs['command'] = cmd kwargs['input'] = args[1] kwargs['output'] = args[0] + '.c' + kwargs['depends'] = depends + if mesonlib.version_compare(glib_version, '< 2.50.2'): + # This will eventually go out of sync if dependencies are added + kwargs['depend_files'] = depend_files + kwargs['command'] = cmd + else: + 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) - kwargs['output'] = args[0] + '.h' - target_h = build.CustomTarget(args[0] + '_h', state.subdir, kwargs) + + h_kwargs = { + 'command': cmd, + 'input': args[1], + 'output': args[0] + '.h', + # The header doesn't actually care about the files yet it errors if missing + 'depends': depends + } + target_h = build.CustomTarget(args[0] + '_h', state.subdir, h_kwargs) return [target_c, target_h] def _get_gresource_dependencies(self, state, input_file, source_dirs, dependencies): - self.__print_gresources_warning(state) - for dep in dependencies: if not isinstance(dep, interpreter.CustomTargetHolder) and not \ isinstance(dep, mesonlib.File): @@ -131,6 +142,7 @@ class GnomeModule: for source_dir in source_dirs: cmd += ['--sourcedir', os.path.join(state.subdir, source_dir)] + cmd += ['--sourcedir', state.subdir] # Current dir pc = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True, cwd=state.environment.get_source_dir()) @@ -154,6 +166,8 @@ class GnomeModule: return os.path.exists(os.path.join(state.environment.get_source_dir(), f)) missing_dep_files = [f for f in dep_files if not exists_in_srcdir(f)] + depends = [] + subdirs = [] for missing in missing_dep_files: found = False missing_basename = os.path.basename(missing) @@ -164,6 +178,7 @@ class GnomeModule: found = True dep_files.remove(missing) dep_files.append(dep) + subdirs.append(dep.subdir) break elif isinstance(dep, interpreter.CustomTargetHolder): if dep.held_object.get_basename() == missing_basename: @@ -174,6 +189,8 @@ class GnomeModule: is_built=True, subdir=dep.held_object.get_subdir(), fname=dep.held_object.get_basename())) + depends.append(dep.held_object) + subdirs.append(dep.held_object.get_subdir()) break if not found: @@ -183,7 +200,7 @@ class GnomeModule: 'gnome.compile_resources() using the "dependencies" ' 'keyword argument.' % (missing, input_file)) - return dep_files + return dep_files, depends, subdirs @staticmethod def _get_link_args(state, lib, depends=None): |