diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-12-16 10:33:56 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-12-17 09:09:38 -0800 |
| commit | f2d3ab56c252adb8bec0272087f33effe7807594 (patch) | |
| tree | 220633b2f02b38f105a8fb47558f7148cc1745cd /mesonbuild | |
| parent | 57e994fe407842a7ce7700295fb5065ca62522de (diff) | |
| download | meson-f2d3ab56c252adb8bec0272087f33effe7807594.tar.gz | |
interpreter: use the new feature where it is useful
Diffstat (limited to 'mesonbuild')
| -rw-r--r-- | mesonbuild/interpreter/type_checking.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index c3f647465..7d6b0073a 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -435,31 +435,30 @@ D_MODULE_VERSIONS_KW: KwargInfo[T.List[T.Union[str, int]]] = KwargInfo( default=[], ) -_link_with_error = '''can only be self-built targets, external dependencies (including libraries) must go in "dependencies".''' +_LINK_WITH_ERROR = 'Dependency and external_library objects must go in the "dependencies" keyword argument' # Allow Dependency for the better error message? But then in other cases it will list this as one of the allowed types! LINK_WITH_KW: KwargInfo[T.List[T.Union[BothLibraries, SharedLibrary, StaticLibrary, CustomTarget, CustomTargetIndex, Jar, Executable]]] = KwargInfo( 'link_with', - ContainerTypeInfo(list, (BothLibraries, SharedLibrary, StaticLibrary, CustomTarget, CustomTargetIndex, Jar, Executable, Dependency)), + ContainerTypeInfo(list, (BothLibraries, SharedLibrary, StaticLibrary, CustomTarget, CustomTargetIndex, Jar, Executable)), listify=True, default=[], - validator=lambda x: _link_with_error if any(isinstance(i, Dependency) for i in x) else None, + extra_types={Dependency: lambda _: _LINK_WITH_ERROR} ) def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, CustomTargetIndex, Dependency]]) -> T.Optional[str]: for l in values: if isinstance(l, (CustomTarget, CustomTargetIndex)) and l.links_dynamically(): return f'{type(l).__name__} returning a shared library is not allowed' - if isinstance(l, Dependency): - return _link_with_error return None LINK_WHOLE_KW: KwargInfo[T.List[T.Union[BothLibraries, StaticLibrary, CustomTarget, CustomTargetIndex]]] = KwargInfo( 'link_whole', - ContainerTypeInfo(list, (BothLibraries, StaticLibrary, CustomTarget, CustomTargetIndex, Dependency)), + ContainerTypeInfo(list, (BothLibraries, StaticLibrary, CustomTarget, CustomTargetIndex)), listify=True, default=[], validator=link_whole_validator, + extra_types={Dependency: lambda _: _LINK_WITH_ERROR} ) DEPENDENCY_SOURCES_KW: KwargInfo[T.List[T.Union[str, File, GeneratedTypes]]] = KwargInfo( |
