aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorBruce Richardson <bruce.richardson@intel.com>2018-04-12 21:20:20 +0100
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-04-13 01:03:59 +0000
commitc213d715ebb594c52425d361409aa28d13b77d9a (patch)
treed29857cf213cbc1d8bf1a63568662019bb20f173 /mesonbuild
parentc04862e24c94000a4e8a7b9c1012178b3b6195d8 (diff)
downloadmeson-c213d715ebb594c52425d361409aa28d13b77d9a.zip
meson-c213d715ebb594c52425d361409aa28d13b77d9a.tar.gz
meson-c213d715ebb594c52425d361409aa28d13b77d9a.tar.bz2
Prune unneeded transitive dependencies
When getting dependencies, we don't need to get the same dependencies and dependency chains multiple times. If library a depends on x, y and z, and library b depends on a, then we should not have to iterate through x, y and z multiple times. Pruning at the stage of scanning the dependencies leads to significant time savings when running meson
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/build.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 08e0c9d..87ce8a5 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -803,12 +803,16 @@ This will become a hard error in a future Meson release.''')
def get_extra_args(self, language):
return self.extra_args.get(language, [])
- def get_dependencies(self):
+ def get_dependencies(self, exclude=None):
transitive_deps = []
+ if exclude is None:
+ exclude = []
for t in itertools.chain(self.link_targets, self.link_whole_targets):
+ if t in transitive_deps or t in exclude:
+ continue
transitive_deps.append(t)
if isinstance(t, StaticLibrary):
- transitive_deps += t.get_dependencies()
+ transitive_deps += t.get_dependencies(transitive_deps + exclude)
return transitive_deps
def get_source_subdir(self):