Merge pull request #5254 from dcbaker/fix-sub-dependencies

Fix sub dependencies
pull/5358/head
Dylan Baker 6 years ago committed by GitHub
commit 529d3788ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      mesonbuild/dependencies/base.py
  2. 2
      mesonbuild/dependencies/boost.py
  3. 6
      mesonbuild/dependencies/dev.py
  4. 2
      test cases/frameworks/15 llvm/meson.build
  5. 2
      test cases/frameworks/2 gtest/meson.build
  6. 2
      test cases/frameworks/3 gmock/meson.build

@ -25,6 +25,7 @@ import textwrap
import platform
import itertools
import ctypes
import typing
from typing import Any, Dict, List, Tuple
from enum import Enum
from pathlib import Path, PurePath
@ -73,6 +74,8 @@ class Dependency:
@classmethod
def _process_method_kw(cls, kwargs):
method = kwargs.get('method', 'auto')
if isinstance(method, DependencyMethods):
return method
if method not in [e.value for e in DependencyMethods]:
raise DependencyException('method {!r} is invalid'.format(method))
method = DependencyMethods(method)
@ -176,6 +179,20 @@ class Dependency:
"""
raise RuntimeError('Unreachable code in partial_dependency called')
def _add_sub_dependency(self, dep_type: typing.Type['Dependency'], env: Environment,
kwargs: typing.Dict[str, typing.Any], *,
method: DependencyMethods = DependencyMethods.AUTO) -> None:
"""Add an internal dependency of of the given type.
This method is intended to simplify cases of adding a dependency on
another dependency type (such as threads). This will by default set
the method back to auto, but the 'method' keyword argument can be
used to overwrite this behavior.
"""
kwargs = kwargs.copy()
kwargs['method'] = method
self.ext_deps.append(dep_type(env, kwargs))
class InternalDependency(Dependency):
def __init__(self, version, incdirs, compile_args, link_args, libraries, whole_libraries, sources, ext_deps):

@ -105,7 +105,7 @@ class BoostDependency(ExternalDependency):
self.requested_modules = self.get_requested(kwargs)
if 'thread' in self.requested_modules:
self.ext_deps.append(ThreadDependency(environment, kwargs))
self._add_sub_dependency(ThreadDependency, environment, kwargs)
self.boost_root = None
self.boost_roots = []

@ -46,7 +46,7 @@ class GTestDependency(ExternalDependency):
self.main = kwargs.get('main', False)
self.src_dirs = ['/usr/src/gtest/src', '/usr/src/googletest/googletest/src']
self.detect()
self.ext_deps.append(ThreadDependency(environment, kwargs))
self._add_sub_dependency(ThreadDependency, environment, kwargs)
def detect(self):
gtest_detect = self.clib_compiler.find_library("gtest", self.env, [])
@ -117,7 +117,7 @@ class GMockDependency(ExternalDependency):
def __init__(self, environment, kwargs):
super().__init__('gmock', environment, 'cpp', kwargs)
self.main = kwargs.get('main', False)
self.ext_deps.append(ThreadDependency(environment, kwargs))
self._add_sub_dependency(ThreadDependency, environment, kwargs)
# If we are getting main() from GMock, we definitely
# want to avoid linking in main() from GTest
@ -256,7 +256,7 @@ class LLVMDependency(ConfigToolDependency):
self._set_old_link_args()
self.link_args = strip_system_libdirs(environment, self.link_args)
self.link_args = self.__fix_bogus_link_args(self.link_args)
self.ext_deps.append(ThreadDependency(environment, kwargs))
self._add_sub_dependency(ThreadDependency, environment, kwargs)
@staticmethod
def __fix_bogus_link_args(args):

@ -1,6 +1,6 @@
project('llvmtest', ['c', 'cpp'], default_options : ['c_std=c99'])
d = dependency('llvm', required : false)
d = dependency('llvm', required : false, method : 'config-tool')
if not d.found()
d = dependency('llvm', required : false, static : true)
if not d.found()

@ -4,7 +4,7 @@ gtest = dependency('gtest', main : true, required : false)
if not gtest.found()
error('MESON_SKIP_TEST: gtest not installed.')
endif
gtest_nomain = dependency('gtest', main : false)
gtest_nomain = dependency('gtest', main : false, method : 'system')
e = executable('testprog', 'test.cc', dependencies : gtest)
test('gtest test', e)

@ -3,7 +3,7 @@ project('gmock test', 'cpp')
# Using gmock without gtest is a pain so just
# don't support that then.
gtest = dependency('gtest', main : true, required : false)
gtest = dependency('gtest', main : true, required : false, method : 'system')
if not gtest.found()
error('MESON_SKIP_TEST: gtest not installed.')
endif

Loading…
Cancel
Save