diff options
author | David Seifert <soap@gentoo.org> | 2018-09-02 22:03:05 +0200 |
---|---|---|
committer | David Seifert <soap@gentoo.org> | 2018-09-02 22:03:05 +0200 |
commit | 5242241f5e204e97636b714095307b84cfea9dbc (patch) | |
tree | f1deabdd8b07ff43d69850a7cfe0edadfe0120c2 /mesonbuild/dependencies | |
parent | 0aa973777f388e655b9d528e5e564e774da28d6a (diff) | |
download | meson-5242241f5e204e97636b714095307b84cfea9dbc.zip meson-5242241f5e204e97636b714095307b84cfea9dbc.tar.gz meson-5242241f5e204e97636b714095307b84cfea9dbc.tar.bz2 |
Prefer pkgconfig for `GMockDependency`
* Also bring `main` semantics in line with `GTestDependency`
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r-- | mesonbuild/dependencies/dev.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index e68b3c1..4d77332 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -102,13 +102,18 @@ class GTestDependency(ExternalDependency): class GMockDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('gmock', environment, 'cpp', kwargs) + self.main = kwargs.get('main', False) + # GMock may be a library or just source. # Work with both. gmock_detect = self.clib_compiler.find_library("gmock", self.env, []) - if gmock_detect: + gmock_main_detect = self.clib_compiler.find_library("gmock_main", self.env, []) + if gmock_detect and (not self.main or gmock_main_detect): self.is_found = True self.compile_args = [] self.link_args = gmock_detect + if self.main: + self.link_args += gmock_main_detect self.sources = [] self.prebuilt = True return @@ -123,7 +128,7 @@ class GMockDependency(ExternalDependency): self.link_args = [] all_src = mesonlib.File.from_absolute_file(os.path.join(d, 'gmock-all.cc')) main_src = mesonlib.File.from_absolute_file(os.path.join(d, 'gmock_main.cc')) - if kwargs.get('main', False): + if self.main: self.sources = [all_src, main_src] else: self.sources = [all_src] @@ -138,6 +143,24 @@ class GMockDependency(ExternalDependency): else: return 'building self' + @classmethod + def _factory(cls, environment, kwargs): + methods = cls._process_method_kw(kwargs) + candidates = [] + + if DependencyMethods.PKGCONFIG in methods: + pcname = 'gmock_main' if kwargs.get('main', False) else 'gmock' + candidates.append(functools.partial(PkgConfigDependency, pcname, environment, kwargs)) + + if DependencyMethods.SYSTEM in methods: + candidates.append(functools.partial(GMockDependency, environment, kwargs)) + + return candidates + + @staticmethod + def get_methods(): + return [DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM] + class LLVMDependency(ConfigToolDependency): """ |