Skip to content

Commit

Permalink
dependencies: Distinguish native/cross while caching
Browse files Browse the repository at this point in the history
Closes #1366
  • Loading branch information
nirbheek authored and jpakkane committed Feb 7, 2017
1 parent 4dae59d commit 781e690
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 7 additions & 7 deletions mesonbuild/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ def __init__(self, name, environment, kwargs):
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')
Expand All @@ -142,7 +142,7 @@ def __init__(self, name, environment, kwargs):
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'
Expand Down Expand Up @@ -551,17 +551,17 @@ def __init__(self, environment, kwargs):
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):
raise DependencyException('BOOST_ROOT must be an absolute path.')
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()
Expand Down
12 changes: 12 additions & 0 deletions mesonbuild/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,15 @@ def func_dependency(self, node, args, kwargs):
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:
Expand All @@ -1804,6 +1813,9 @@ def func_dependency(self, node, args, kwargs):
# 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
Expand Down

0 comments on commit 781e690

Please sign in to comment.