diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-11-30 13:41:16 +0530 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-11-30 23:15:19 +0200 |
commit | e1bdc098ca48990322b058e2a2a9fce16c3e7674 (patch) | |
tree | e5659ed22a65ea302ee508c06f75c7c1e234b71d | |
parent | e0274441fc49a39784767fea61992125b37c2349 (diff) | |
download | meson-e1bdc098ca48990322b058e2a2a9fce16c3e7674.zip meson-e1bdc098ca48990322b058e2a2a9fce16c3e7674.tar.gz meson-e1bdc098ca48990322b058e2a2a9fce16c3e7674.tar.bz2 |
gnome.compile_resources: Prefer generated files over source files
We should always prefer generated files over onces in the source tree
else if the same file also exists in the source tree we get strange
behaviour where we ignore dependencies and the project has to be
built twice to be fully up-to-date.
See: https://bugzilla.gnome.org/show_bug.cgi?id=787677
Closes https://github.com/mesonbuild/meson/issues/2686
-rw-r--r-- | mesonbuild/modules/gnome.py | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index a53eca8..f916c2c 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -220,9 +220,10 @@ class GnomeModule(ExtensionModule): input_file, '--generate-dependencies'] + # Prefer generated files over source files + cmd += ['--sourcedir', state.subdir] # Current build dir for source_dir in source_dirs: cmd += ['--sourcedir', os.path.join(state.subdir, source_dir)] - cmd += ['--sourcedir', state.subdir] # Current dir pc, stdout, stderr = Popen_safe(cmd, cwd=state.environment.get_source_dir()) if pc.returncode != 0: @@ -240,25 +241,20 @@ class GnomeModule(ExtensionModule): # # If there are multiple generated resource files with the same basename # then this code will get confused. - def exists_in_srcdir(f): 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) - + for resfile in dep_files[:]: + resbasename = os.path.basename(resfile) for dep in dependencies: if hasattr(dep, 'held_object'): dep = dep.held_object if isinstance(dep, mesonlib.File): - if dep.fname != missing_basename: + if dep.fname != resbasename: continue - found = True - dep_files.remove(missing) + dep_files.remove(resfile) dep_files.append(dep) subdirs.append(dep.subdir) break @@ -266,12 +262,11 @@ class GnomeModule(ExtensionModule): fname = None outputs = {(o, os.path.basename(o)) for o in dep.get_outputs()} for o, baseo in outputs: - if baseo == missing_basename: + if baseo == resbasename: fname = o break if fname is not None: - found = True - dep_files.remove(missing) + dep_files.remove(resfile) dep_files.append( mesonlib.File( is_built=True, @@ -280,16 +275,13 @@ class GnomeModule(ExtensionModule): depends.append(dep) subdirs.append(dep.get_subdir()) break - else: - raise RuntimeError('Unreachable code.') - - if not found: - raise MesonException( - 'Resource "%s" listed in "%s" was not found. If this is a ' - 'generated file, pass the target that generates it to ' - 'gnome.compile_resources() using the "dependencies" ' - 'keyword argument.' % (missing, input_file)) - + else: + if not exists_in_srcdir(resfile): + raise MesonException( + 'Resource "%s" listed in "%s" was not found. If this is a ' + 'generated file, pass the target that generates it to ' + 'gnome.compile_resources() using the "dependencies" ' + 'keyword argument.' % (resfile, input_file)) return dep_files, depends, subdirs def _get_link_args(self, state, lib, depends=None, include_rpath=False, |