aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-11-28 03:04:39 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-12-02 02:07:19 +0530
commit62ba5ca1ec1b9423b2fe6676dd163e2a06a7b0a5 (patch)
tree129bbe84d8360da562aca8cd300fa088d5d9527c /mesonbuild/build.py
parente1bdc098ca48990322b058e2a2a9fce16c3e7674 (diff)
downloadmeson-62ba5ca1ec1b9423b2fe6676dd163e2a06a7b0a5.zip
meson-62ba5ca1ec1b9423b2fe6676dd163e2a06a7b0a5.tar.gz
meson-62ba5ca1ec1b9423b2fe6676dd163e2a06a7b0a5.tar.bz2
custom target: Consider all build depends while serializing
Currently, we only consider the build depends of the Executable being run when serializing custom targets. However, this is not always sufficient, for example if the executable loads modules at runtime or if the executable is actually a python script that loads a built module. For these cases, we need to set PATH on Windows correctly or the custom target will fail to run at build time complaining about missing DLLs.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r--mesonbuild/build.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 8eb95dc..7757300 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1549,6 +1549,24 @@ class CustomTarget(Target):
deps.append(c)
return deps
+ def get_transitive_build_target_deps(self):
+ '''
+ Recursively fetch the build targets that this custom target depends on,
+ whether through `command:`, `depends:`, or `sources:` The recursion is
+ only performed on custom targets.
+ This is useful for setting PATH on Windows for finding required DLLs.
+ F.ex, if you have a python script that loads a C module that links to
+ other DLLs in your project.
+ '''
+ bdeps = set()
+ deps = self.get_target_dependencies()
+ for d in deps:
+ if isinstance(d, BuildTarget):
+ bdeps.add(d)
+ elif isinstance(d, CustomTarget):
+ bdeps.update(d.get_transitive_build_target_deps())
+ return bdeps
+
def flatten_command(self, cmd):
cmd = listify(cmd, unholder=True)
final_cmd = []