aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-11-11 04:30:15 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-11-13 03:57:58 +0530
commit69dcbb6ec9e8bab86b66c9d78dc4a0dba4350659 (patch)
treebc6feb246b4bb1996104595ff909106d64ce0a78
parent085650a1e3769366ac47f7d8a59386ed6d5a1ef5 (diff)
downloadmeson-69dcbb6ec9e8bab86b66c9d78dc4a0dba4350659.zip
meson-69dcbb6ec9e8bab86b66c9d78dc4a0dba4350659.tar.gz
meson-69dcbb6ec9e8bab86b66c9d78dc4a0dba4350659.tar.bz2
gnome.generate_gir: Add gir deps and includes recursively
Earlier, we were never adding dependencies on other GirTargets that we need. The dependency would only be added indirectly through other BuildTargets such as SharedLibrary. Now we add all GirTargets specified in the `dependencies :` kwarg to the list of dependencies of the GirTarget that we generate. Also, we weren't adding include directories for the typelib generation command recursively. We were only adding it for the GirTargets listed under the `dependencies :` kwarg to gnome.generate_gir. Now we search all link targets, find GirTargets, extract the include dir, and use it. In summation, dependencies were completely broken.
-rw-r--r--mesonbuild/modules/gnome.py53
1 files changed, 37 insertions, 16 deletions
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index f3f22bc..15ed178 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -401,6 +401,41 @@ class GnomeModule:
deps = [deps]
deps = (girtarget.get_all_link_deps() + girtarget.get_external_deps() +
deps)
+ # Need to recursively add deps on GirTarget sources from our
+ # dependencies and also find the include directories needed for the
+ # typelib generation custom target below.
+ typelib_includes = []
+ for dep in deps:
+ if hasattr(dep, 'held_object'):
+ dep = dep.held_object
+ # Add a dependency on each GirTarget listed in dependencies and add
+ # the directory where it will be generated to the typelib includes
+ if isinstance(dep, dependencies.InternalDependency):
+ for source in dep.sources:
+ if hasattr(source, 'held_object'):
+ source = source.held_object
+ if isinstance(source, GirTarget) and source not in depends:
+ depends.append(source)
+ subdir = os.path.join(state.environment.get_build_dir(),
+ source.get_subdir())
+ if subdir not in typelib_includes:
+ typelib_includes.append(subdir)
+ # Do the same, but for dependencies of dependencies. These are
+ # stored in the list of generated sources for each link dep (from
+ # girtarget.get_all_link_deps() above).
+ # FIXME: Store this in the original form from declare_dependency()
+ # so it can be used here directly.
+ elif isinstance(dep, build.SharedLibrary):
+ for source in dep.generated:
+ if isinstance(source, GirTarget):
+ subdir = os.path.join(state.environment.get_build_dir(),
+ source.get_subdir())
+ if subdir not in typelib_includes:
+ typelib_includes.append(subdir)
+ elif isinstance(dep, dependencies.PkgConfigDependency):
+ girdir = dep.get_pkgconfig_variable("girdir")
+ if girdir and girdir not in typelib_includes:
+ typelib_includes.append(girdir)
# ldflags will be misinterpreted by gir scanner (showing
# spurious dependencies) but building GStreamer fails if they
# are not used here.
@@ -441,22 +476,8 @@ class GnomeModule:
typelib_cmd = ['g-ir-compiler', scan_target, '--output', '@OUTPUT@']
typelib_cmd += self._get_include_args(state, gir_inc_dirs,
prefix='--includedir=')
- for dep in deps:
- if hasattr(dep, 'held_object'):
- dep = dep.held_object
- if isinstance(dep, dependencies.InternalDependency):
- for source in dep.sources:
- if isinstance(source.held_object, GirTarget):
- typelib_cmd += [
- "--includedir=%s" % (
- os.path.join(state.environment.get_build_dir(),
- source.held_object.get_subdir()),
- )
- ]
- elif isinstance(dep, dependencies.PkgConfigDependency):
- girdir = dep.get_pkgconfig_variable("girdir")
- if girdir:
- typelib_cmd += ["--includedir=%s" % (girdir, )]
+ for incdir in typelib_includes:
+ typelib_cmd += ["--includedir=" + incdir]
typelib_kwargs = {
'output': typelib_output,