dependencies: Don't Repeat Yourself when it comes to lookup methods
We need to extend the candidates the same way per method, but we handle each method twice: once in explicit method checks, and once for auto. We can just handle auto as a special list of methods, though.
This commit is contained in:
parent
216f7476de
commit
c780d240e2
|
@ -192,37 +192,30 @@ def _build_external_dependency_list(name: str, env: 'Environment', for_machine:
|
|||
|
||||
candidates: T.List['DependencyGenerator'] = []
|
||||
|
||||
# If it's explicitly requested, use the dub detection method (only)
|
||||
if 'dub' == kwargs.get('method', ''):
|
||||
if kwargs.get('method', 'auto') == 'auto':
|
||||
# Just use the standard detection methods.
|
||||
methods = ['pkg-config', 'extraframework', 'cmake']
|
||||
else:
|
||||
# If it's explicitly requested, use that detection method (only).
|
||||
methods = [kwargs['method']]
|
||||
|
||||
# Exclusive to when it is explicitly requested
|
||||
if 'dub' in methods:
|
||||
candidates.append(functools.partial(DubDependency, name, env, kwargs))
|
||||
return candidates
|
||||
|
||||
# If it's explicitly requested, use the pkgconfig detection method (only)
|
||||
if 'pkg-config' == kwargs.get('method', ''):
|
||||
candidates.append(functools.partial(PkgConfigDependency, name, env, kwargs))
|
||||
return candidates
|
||||
|
||||
# If it's explicitly requested, use the CMake detection method (only)
|
||||
if 'cmake' == kwargs.get('method', ''):
|
||||
candidates.append(functools.partial(CMakeDependency, name, env, kwargs))
|
||||
return candidates
|
||||
|
||||
# If it's explicitly requested, use the Extraframework detection method (only)
|
||||
if 'extraframework' == kwargs.get('method', ''):
|
||||
# On OSX, also try framework dependency detector
|
||||
if env.machines[for_machine].is_darwin():
|
||||
candidates.append(functools.partial(ExtraFrameworkDependency, name, env, kwargs))
|
||||
return candidates
|
||||
|
||||
# Otherwise, just use the pkgconfig and cmake dependency detector
|
||||
if 'auto' == kwargs.get('method', 'auto'):
|
||||
# Preferred first candidate for auto.
|
||||
if 'pkg-config' in methods:
|
||||
candidates.append(functools.partial(PkgConfigDependency, name, env, kwargs))
|
||||
|
||||
# On OSX, also try framework dependency detector
|
||||
# On OSX only, try framework dependency detector.
|
||||
if 'extraframework' in methods:
|
||||
if env.machines[for_machine].is_darwin():
|
||||
candidates.append(functools.partial(ExtraFrameworkDependency, name, env, kwargs))
|
||||
|
||||
# Only use CMake as a last resort, since it might not work 100% (see #6113)
|
||||
# Only use CMake:
|
||||
# - if it's explicitly requested
|
||||
# - as a last resort, since it might not work 100% (see #6113)
|
||||
if 'cmake' in methods:
|
||||
candidates.append(functools.partial(CMakeDependency, name, env, kwargs))
|
||||
|
||||
return candidates
|
||||
|
|
Loading…
Reference in New Issue