dependencies: Distinguish native/cross while caching

Closes https://github.com/mesonbuild/meson/issues/1366
pull/1373/head
Nirbheek Chauhan 8 years ago committed by Jussi Pakkanen
parent 4dae59dfea
commit 781e69094a
  1. 14
      mesonbuild/dependencies.py
  2. 12
      mesonbuild/interpreter.py

@ -108,14 +108,14 @@ class PkgConfigDependency(Dependency):
self.cargs = []
self.libs = []
if 'native' in kwargs and environment.is_cross_build():
want_cross = not kwargs['native']
self.want_cross = not kwargs['native']
else:
want_cross = environment.is_cross_build()
self.want_cross = environment.is_cross_build()
self.name = name
# When finding dependencies for cross-compiling, we don't care about
# the 'native' pkg-config
if want_cross:
if self.want_cross:
if 'pkgconfig' not in environment.cross_info.config['binaries']:
if self.required:
raise DependencyException('Pkg-config binary missing from cross file')
@ -142,7 +142,7 @@ class PkgConfigDependency(Dependency):
if self.required:
raise DependencyException('Pkg-config not found.')
return
if want_cross:
if self.want_cross:
self.type_string = 'Cross'
else:
self.type_string = 'Native'
@ -551,9 +551,9 @@ class BoostDependency(Dependency):
self.environment = environment
self.libdir = ''
if 'native' in kwargs and environment.is_cross_build():
want_cross = not kwargs['native']
self.want_cross = not kwargs['native']
else:
want_cross = environment.is_cross_build()
self.want_cross = environment.is_cross_build()
try:
self.boost_root = os.environ['BOOST_ROOT']
if not os.path.isabs(self.boost_root):
@ -561,7 +561,7 @@ class BoostDependency(Dependency):
except KeyError:
self.boost_root = None
if self.boost_root is None:
if want_cross:
if self.want_cross:
raise DependencyException('BOOST_ROOT is needed while cross-compiling')
if mesonlib.is_windows():
self.boost_root = self.detect_win_root()

@ -1788,6 +1788,15 @@ class Interpreter(InterpreterBase):
raise InvalidArguments('''Characters <, > and = are forbidden in target names. To specify version
requirements use the version keyword argument instead.''')
identifier = dependencies.get_dep_identifier(name, kwargs)
# Check if we want this as a cross-dep or a native-dep
# FIXME: Not all dependencies support such a distinction right now,
# and we repeat this check inside dependencies that do. We need to
# consolidate this somehow.
is_cross = self.environment.is_cross_build()
if 'native' in kwargs and is_cross:
want_cross = not kwargs['native']
else:
want_cross = is_cross
# Check if we've already searched for and found this dep
cached_dep = None
if identifier in self.coredata.deps:
@ -1804,6 +1813,9 @@ requirements use the version keyword argument instead.''')
# so we properly go into fallback/error code paths
if kwargs.get('required', True) and not getattr(cached_dep, 'required', False):
cached_dep = None
# Don't reuse cached dep if one is a cross-dep and the other is a native dep
if not getattr(cached_dep, 'want_cross', is_cross) == want_cross:
cached_dep = None
if cached_dep:
dep = cached_dep

Loading…
Cancel
Save