Try using already setup fallback subprojects before using native dependency

In the case the main project set a subproject for a dependency another
subprojects uses, that other subproject should rather use the first
subproject rather that using native dependency.

For example in gst-all we set all GStreamer modules as subprojects
and, gst-plugins-base is set after gstreamer core, and
we want gst-plugins-base to always use GStreamer core from the subproject
and not the possibly avalaible native one.
pull/861/head
Thibault Saunier 8 years ago
parent fcaf319e49
commit 77b379f5cf
  1. 29
      mesonbuild/interpreter.py
  2. 4
      test cases/linuxlike/5 dependency versions/meson.build
  3. 3
      test cases/linuxlike/5 dependency versions/subprojects/somelib/meson.build

@ -1834,11 +1834,23 @@ class Interpreter():
# We need to actually search for this dep
exception = None
dep = None
try:
dep = dependencies.find_external_dependency(name, self.environment, kwargs)
except dependencies.DependencyException as e:
exception = e
pass
# If the fallback has already been configured (possibly by a higher level project)
# try to use it before using the native version
if 'fallback' in kwargs:
dirname, varname = self.get_subproject_infos(kwargs)
if dirname in self.subprojects:
try:
dep = self.subprojects[dirname].get_variable_method([varname], {})
dep = dep.held_object
except KeyError:
pass
if not dep:
try:
dep = dependencies.find_external_dependency(name, self.environment, kwargs)
except dependencies.DependencyException as e:
exception = e
pass
if not dep or not dep.found():
if 'fallback' in kwargs:
@ -1852,12 +1864,15 @@ class Interpreter():
self.coredata.deps[identifier] = dep
return DependencyHolder(dep)
def dependency_fallback(self, name, kwargs):
def get_subproject_infos(self, kwargs):
fbinfo = kwargs['fallback']
check_stringlist(fbinfo)
if len(fbinfo) != 2:
raise InterpreterException('Fallback info must have exactly two items.')
dirname, varname = fbinfo
return fbinfo
def dependency_fallback(self, name, kwargs):
dirname, varname = self.get_subproject_infos(kwargs)
try:
self.do_subproject(dirname, {})
except:

@ -32,3 +32,7 @@ somelibfail = dependency('somelib',
required : false,
fallback : ['somelibfail', 'some_dep'])
assert(somelibfail.found() == false, 'somelibfail found via wrong fallback')
fakezlib_dep = dependency('zlib',
fallback : ['somelib', 'fakezlib_dep'])
assert(fakezlib_dep.type_name() == 'internal', 'fakezlib_dep should be of type "internal", not ' + fakezlib_dep.type_name())

@ -6,3 +6,6 @@ someinc = include_directories('.')
some_dep = declare_dependency(link_with : somelib,
include_directories : someinc)
fakezlib_dep = declare_dependency(link_with : somelib,
include_directories : someinc)

Loading…
Cancel
Save