fix bug with openssl when cmake is missing

Fixes #12098

DependencyFactory was returning a lambda, but it has no log_tried() function
1.2
Charles Brunet 1 year ago committed by Nirbheek Chauhan
parent 5ac498e19e
commit de1ba4eb8c
  1. 16
      mesonbuild/dependencies/cmake.py
  2. 8
      mesonbuild/dependencies/misc.py
  3. 5
      test cases/unit/117 openssl cmake bug/meson.build
  4. 7
      test cases/unit/117 openssl cmake bug/nativefile.ini
  5. 7
      unittests/platformagnostictests.py

@ -652,3 +652,19 @@ class CMakeDependency(ExternalDependency):
if default_value is not None:
return default_value
raise DependencyException(f'Could not get cmake variable and no default provided for {self!r}')
class CMakeDependencyFactory:
def __init__(self, name: T.Optional[str] = None, modules: T.Optional[T.List[str]] = None):
self.name = name
self.modules = modules
def __call__(self, name: str, env: Environment, kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None, force_use_global_compilers: bool = False) -> CMakeDependency:
if self.modules:
kwargs['modules'] = self.modules
return CMakeDependency(self.name or name, env, kwargs, language, force_use_global_compilers)
@staticmethod
def log_tried() -> str:
return CMakeDependency.log_tried()

@ -23,7 +23,7 @@ from .. import mesonlib
from .. import mlog
from .base import DependencyException, DependencyMethods
from .base import BuiltinDependency, SystemDependency
from .cmake import CMakeDependency
from .cmake import CMakeDependency, CMakeDependencyFactory
from .configtool import ConfigToolDependency
from .detect import packages
from .factory import DependencyFactory, factory_methods
@ -599,19 +599,19 @@ packages['openssl'] = openssl_factory = DependencyFactory(
'openssl',
[DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM, DependencyMethods.CMAKE],
system_class=OpensslSystemDependency,
cmake_class=lambda name, env, kwargs: CMakeDependency('OpenSSL', env, dict(kwargs, modules=['OpenSSL::Crypto', 'OpenSSL::SSL'])),
cmake_class=CMakeDependencyFactory('OpenSSL', modules=['OpenSSL::Crypto', 'OpenSSL::SSL']),
)
packages['libcrypto'] = libcrypto_factory = DependencyFactory(
'libcrypto',
[DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM, DependencyMethods.CMAKE],
system_class=OpensslSystemDependency,
cmake_class=lambda name, env, kwargs: CMakeDependency('OpenSSL', env, dict(kwargs, modules=['OpenSSL::Crypto'])),
cmake_class=CMakeDependencyFactory('OpenSSL', modules=['OpenSSL::Crypto']),
)
packages['libssl'] = libssl_factory = DependencyFactory(
'libssl',
[DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM, DependencyMethods.CMAKE],
system_class=OpensslSystemDependency,
cmake_class=lambda name, env, kwargs: CMakeDependency('OpenSSL', env, dict(kwargs, modules=['OpenSSL::SSL'])),
cmake_class=CMakeDependencyFactory('OpenSSL', modules=['OpenSSL::SSL']),
)

@ -0,0 +1,5 @@
project('bug', 'cpp')
# When cmake is not available,
# this triggers the bug described in #12098
openssl_dep = dependency('openssl')

@ -0,0 +1,7 @@
[binaries]
cmake = '/path/to/nothing'
[built-in options]
pkg_config_path = ''

@ -254,3 +254,10 @@ class PlatformAgnosticTests(BasePlatformTests):
self.assertEqual(data['modules'], expected)
self.assertEqual(data['count'], 68)
def test_cmake_openssl_not_found_bug(self):
"""Issue #12098"""
testdir = os.path.join(self.unit_test_dir, '117 openssl cmake bug')
self.meson_native_files.append(os.path.join(testdir, 'nativefile.ini'))
out = self.init(testdir, allow_fail=True)
self.assertNotIn('Unhandled python exception', out)

Loading…
Cancel
Save