diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2017-03-29 10:47:08 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2017-03-29 13:56:29 -0700 |
commit | 7aa28456dfa4b865782bbf11a3ffb554c1af54df (patch) | |
tree | 991e5914e40b656f044aca0a761ed458a1e88793 | |
parent | fa107031249e7a45c2b7187e85ab5e06ca5e4a9d (diff) | |
download | meson-7aa28456dfa4b865782bbf11a3ffb554c1af54df.zip meson-7aa28456dfa4b865782bbf11a3ffb554c1af54df.tar.gz meson-7aa28456dfa4b865782bbf11a3ffb554c1af54df.tar.bz2 |
Add dependency type for Valgrind
Valgrind is a bit of a strange beast, in general use one isn't supposed
to link against valgrinds libs, they're non-PIC static libs, instead,
including the headers does magic to make valgrind work.
This patch implements a simple ValgrindDependency class subclassed from
PkgConfigDependency, that overwrites (effectively) only the
get_link_args method to always return an empty list. This solution may
seem strange, but I think that it follows the principle of least
surprise, and simplifies the most common use case for valgrind.
Essentially without this every valgrind consumer would be forced to
implement the following code to have a usable valgrind dependency
object:
_dep = dependency('valgrind', required : false)
if _dep.found()
valgrind_dep = declare_dependency(
compile_args : _dep.get_pkgconfig_variable('Cflags')
)
else
valgrind_dep = []
endif
While the above is workable, it's surprising behavior and the above code
snippet becomes boilerplate that everyone needs to copy into their meson
files.
Fixes #826
-rw-r--r-- | authors.txt | 1 | ||||
-rw-r--r-- | mesonbuild/dependencies.py | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/authors.txt b/authors.txt index 64792a2..5bd0ba9 100644 --- a/authors.txt +++ b/authors.txt @@ -72,3 +72,4 @@ Aaron Small Joe Baldino Peter Harris Roger Boerdijk +Dylan Baker diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index eacb15b..7f22ae6 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -1483,6 +1483,14 @@ class Python3Dependency(Dependency): def get_version(self): return self.version +class ValgrindDependency(PkgConfigDependency): + + def __init__(self, environment, kwargs): + PkgConfigDependency.__init__(self, 'valgrind', environment, kwargs) + + def get_link_args(self): + return [] + def get_dep_identifier(name, kwargs): elements = [name] modlist = kwargs.get('modules', []) @@ -1544,4 +1552,5 @@ packages = {'boost': BoostDependency, 'gl': GLDependency, 'threads': ThreadDependency, 'python3': Python3Dependency, + 'valgrind': ValgrindDependency, } |