defer setting values until after we know it cannot be None

pull/12839/head
Eli Schwartz 11 months ago
parent dabe7b16d9
commit 07c051ed27
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 5
      mesonbuild/dependencies/cmake.py
  2. 5
      mesonbuild/dependencies/pkgconfig.py
  3. 9
      mesonbuild/wrap/wrap.py

@ -126,9 +126,10 @@ class CMakeDependency(ExternalDependency):
cm_args = check_cmake_args(cm_args)
if CMakeDependency.class_cmakeinfo[self.for_machine] is None:
CMakeDependency.class_cmakeinfo[self.for_machine] = self._get_cmake_info(cm_args)
self.cmakeinfo = CMakeDependency.class_cmakeinfo[self.for_machine]
if self.cmakeinfo is None:
cmakeinfo = CMakeDependency.class_cmakeinfo[self.for_machine]
if cmakeinfo is None:
raise self._gen_exception('Unable to obtain CMake system information')
self.cmakeinfo = cmakeinfo
package_version = kwargs.get('cmake_package_version', '')
if not isinstance(package_version, str):

@ -277,13 +277,14 @@ class PkgConfigDependency(ExternalDependency):
super().__init__(DependencyTypeName('pkgconfig'), environment, kwargs, language=language)
self.name = name
self.is_libtool = False
self.pkgconfig = PkgConfigInterface.instance(self.env, self.for_machine, self.silent)
if not self.pkgconfig:
pkgconfig = PkgConfigInterface.instance(self.env, self.for_machine, self.silent)
if not pkgconfig:
msg = f'Pkg-config for machine {self.for_machine} not found. Giving up.'
if self.required:
raise DependencyException(msg)
mlog.debug(msg)
return
self.pkgconfig = pkgconfig
version = self.pkgconfig.version(name)
if version is None:

@ -404,12 +404,13 @@ class Resolver:
def resolve(self, packagename: str, force_method: T.Optional[Method] = None) -> T.Tuple[str, Method]:
self.packagename = packagename
self.directory = packagename
self.wrap = self.wraps.get(packagename)
if not self.wrap:
self.wrap = self.get_from_wrapdb(packagename)
if not self.wrap:
wrap = self.wraps.get(packagename)
if not wrap:
wrap = self.get_from_wrapdb(packagename)
if not wrap:
m = f'Neither a subproject directory nor a {self.packagename}.wrap file was found.'
raise WrapNotFoundException(m)
self.wrap = wrap
self.directory = self.wrap.directory
if self.wrap.has_wrap:

Loading…
Cancel
Save