aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2018-12-30 01:04:11 -0500
committerXavier Claessens <xclaesse@gmail.com>2019-01-16 11:16:46 -0500
commit35f0f7090d7daab3f7e95a0e2d495bdb0f68cf4a (patch)
tree16b96a804c22478e3ec8dc97d64da5f852ebc7b1 /mesonbuild
parent5dac8e51f4bd88c9cc610348e4fecfa21c1d8918 (diff)
downloadmeson-35f0f7090d7daab3f7e95a0e2d495bdb0f68cf4a.zip
meson-35f0f7090d7daab3f7e95a0e2d495bdb0f68cf4a.tar.gz
meson-35f0f7090d7daab3f7e95a0e2d495bdb0f68cf4a.tar.bz2
dependency: Cleanup code by avoiding nested if blocks
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/interpreter.py64
1 files changed, 29 insertions, 35 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index c730c3a..63a91f5 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2979,46 +2979,40 @@ external dependencies (including libraries) must go to "dependencies".''')
if '<' in name or '>' in name or '=' in name:
raise InvalidArguments('Characters <, > and = are forbidden in dependency names. To specify'
'version\n requirements use the \'version\' keyword argument instead.')
- identifier, cached_dep = self._find_cached_dep(name, kwargs)
+ identifier, cached_dep = self._find_cached_dep(name, kwargs)
if cached_dep:
if required and not cached_dep.found():
m = 'Dependency {!r} was already checked and was not found'
raise DependencyException(m.format(display_name))
- dep = cached_dep
- else:
- # If the dependency has already been configured, possibly by
- # a higher level project, try to use it first.
- if has_fallback:
- dirname, varname = self.get_subproject_infos(kwargs)
- if dirname in self.subprojects:
- return self.get_subproject_dep(display_name, dirname, varname, kwargs)
-
- # We need to actually search for this dep
- dep = NotFoundDependency(self.environment)
-
- # Unless a fallback exists and is forced ...
- if self.coredata.get_builtin_option('wrap_mode') == WrapMode.forcefallback and has_fallback:
- pass
- # ... search for it outside the project
- elif name != '':
- self._handle_featurenew_dependencies(name)
- kwargs['required'] = required and not has_fallback
- dep = dependencies.find_external_dependency(name, self.environment, kwargs)
- kwargs['required'] = required
-
- # Search inside the projects list
- if not dep.found():
- if has_fallback:
- return self.dependency_fallback(display_name, kwargs)
-
- # Only store found-deps in the cache
- # Never add fallback deps to self.coredata.deps since we
- # cannot cache them. They must always be evaluated else
- # we won't actually read all the build files.
- if dep.found():
- self.coredata.deps[identifier] = dep
- return DependencyHolder(dep, self.subproject)
+ return DependencyHolder(cached_dep, self.subproject)
+
+ # If the dependency has already been configured, possibly by
+ # a higher level project, try to use it first.
+ if has_fallback:
+ dirname, varname = self.get_subproject_infos(kwargs)
+ if dirname in self.subprojects:
+ return self.get_subproject_dep(name, dirname, varname, kwargs)
+
+ wrap_mode = self.coredata.get_builtin_option('wrap_mode')
+ forcefallback = wrap_mode == WrapMode.forcefallback and has_fallback
+ if name != '' and not forcefallback:
+ self._handle_featurenew_dependencies(name)
+ kwargs['required'] = required and not has_fallback
+ dep = dependencies.find_external_dependency(name, self.environment, kwargs)
+ kwargs['required'] = required
+ # Only store found-deps in the cache
+ # Never add fallback deps to self.coredata.deps since we
+ # cannot cache them. They must always be evaluated else
+ # we won't actually read all the build files.
+ if dep.found():
+ self.coredata.deps[identifier] = dep
+ return DependencyHolder(dep, self.subproject)
+
+ if has_fallback:
+ return self.dependency_fallback(display_name, kwargs)
+
+ return self.notfound_dependency()
@FeatureNew('disabler', '0.44.0')
@noKwargs