Skip to content

Commit a46be50

Browse files
committed
WIP: add back the cmake_name parameter to DependencyFactory
1 parent 4aa88d6 commit a46be50

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

mesonbuild/dependencies/dev.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .. import mesonlib, mlog
1818
from ..tooldetect import get_llvm_tool_names
1919
from ..mesonlib import version_compare, version_compare_many, search_version
20-
from .base import DependencyException, DependencyMethods, detect_compiler, strip_system_includedirs, strip_system_libdirs, SystemDependency, ExternalDependency, DependencyCandidate
20+
from .base import DependencyException, DependencyMethods, detect_compiler, strip_system_includedirs, strip_system_libdirs, SystemDependency, ExternalDependency
2121
from .cmake import CMakeDependency
2222
from .configtool import ConfigToolDependency
2323
from .detect import packages
@@ -823,6 +823,6 @@ def get_variable(self, *, cmake: T.Optional[str] = None, pkgconfig: T.Optional[s
823823
packages['zlib'] = zlib_factory = DependencyFactory(
824824
'zlib',
825825
[DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE, DependencyMethods.SYSTEM],
826-
cmake=DependencyCandidate.from_dependency('ZLIB', CMakeDependency),
826+
cmake_name='ZLIB',
827827
system=ZlibSystemDependency,
828828
)

mesonbuild/dependencies/factory.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class DependencyFactory:
5858
:param extra_kwargs: Additional keyword arguments to add when creating the
5959
DependencyCandidate
6060
:param pkgconfig: A custom PackageConfig lookup to use
61-
:param cmake: A custom CMake lookup to use
61+
:param cmake_name: A name to use in a cmake class. Exclusive with :param:`cmake`
62+
:param cmake: A custom CMake lookup to use. Exclusive with :param:`cmake_name`
6263
:param framework: A custom AppleFramework lookup to use
6364
:param configtool: A custom ConfigTool lookup to use. If
6465
DependencyMethods.CONFIG_TOOL is in the `:param:methods` argument,
@@ -73,8 +74,9 @@ class DependencyFactory:
7374

7475
def __init__(self, name: str, methods: T.List[DependencyMethods], *,
7576
extra_kwargs: T.Optional[DependencyObjectKWs] = None,
77+
cmake_name: T.Optional[str] = None,
7678
pkgconfig: T.Union[DependencyCandidate[PkgConfigDependency], T.Type[PkgConfigDependency], None] = PkgConfigDependency,
77-
cmake: T.Union[DependencyCandidate[CMakeDependency], T.Type[CMakeDependency], None] = CMakeDependency,
79+
cmake: T.Union[DependencyCandidate[CMakeDependency], T.Type[CMakeDependency], None] = None,
7880
framework: T.Union[DependencyCandidate[ExtraFrameworkDependency], T.Type[ExtraFrameworkDependency], None] = ExtraFrameworkDependency,
7981
configtool: T.Union[DependencyCandidate[ConfigToolDependency], T.Type[ConfigToolDependency], None] = None,
8082
builtin: T.Union[DependencyCandidate[BuiltinDependency], T.Type[BuiltinDependency], None] = None,
@@ -87,6 +89,14 @@ def __init__(self, name: str, methods: T.List[DependencyMethods], *,
8789
if DependencyMethods.SYSTEM in methods and not system:
8890
raise DependencyException('A system dependency must have a custom class')
8991

92+
if cmake_name is not None and cmake is not None:
93+
raise DependencyException('A most one of `cmake_name` and `cmake` can be provided')
94+
95+
if cmake_name is not None:
96+
cmake = DependencyCandidate.from_dependency(cmake_name, CMakeDependency)
97+
if cmake is None:
98+
cmake = CMakeDependency
99+
90100
def make(arg: T.Union[DependencyCandidate[DepType], T.Type[DepType], None]) -> T.Optional[DependencyCandidate[DepType]]:
91101
if arg is None or isinstance(arg, DependencyCandidate):
92102
return arg

mesonbuild/dependencies/misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def shaderc_factory(env: 'Environment',
606606
'cups',
607607
[DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK, DependencyMethods.CMAKE],
608608
configtool=CupsDependencyConfigTool,
609-
cmake=DependencyCandidate.from_dependency('Cups', CMakeDependency),
609+
cmake_name='Cups',
610610
)
611611

612612
packages['dl'] = dl_factory = DependencyFactory(
@@ -644,7 +644,7 @@ def shaderc_factory(env: 'Environment',
644644
packages['threads'] = threads_factory = DependencyFactory(
645645
'threads',
646646
[DependencyMethods.SYSTEM, DependencyMethods.CMAKE],
647-
cmake=DependencyCandidate.from_dependency('Threads', CMakeDependency),
647+
cmake_name='Threads',
648648
system=ThreadDependency,
649649
)
650650

mesonbuild/dependencies/ui.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
)
1818
from ..envconfig import detect_cpu_family
1919

20-
from .base import DependencyCandidate, DependencyException, DependencyMethods, DependencyTypeName, SystemDependency
21-
from .cmake import CMakeDependency
20+
from .base import DependencyException, DependencyMethods, DependencyTypeName, SystemDependency
2221
from .configtool import ConfigToolDependency
2322
from .detect import packages
2423
from .factory import DependencyFactory
@@ -259,7 +258,7 @@ def __init__(self, name: str, environment: 'Environment', kwargs: DependencyObje
259258
'sdl2',
260259
[DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK, DependencyMethods.CMAKE],
261260
configtool=SDL2DependencyConfigTool,
262-
cmake=DependencyCandidate.from_dependency('SDL2', CMakeDependency),
261+
cmake_name='SDL2',
263262
)
264263

265264
packages['vulkan'] = vulkan_factory = DependencyFactory(

0 commit comments

Comments
 (0)