diff --git a/docs/yaml/functions/custom_target.yaml b/docs/yaml/functions/custom_target.yaml index b32520501..e9ea288b3 100644 --- a/docs/yaml/functions/custom_target.yaml +++ b/docs/yaml/functions/custom_target.yaml @@ -189,8 +189,10 @@ kwargs: are also accepted. input: - type: array[str | file] - description: Array of source files. *(since 0.41.0)* the array is flattened. + type: array[str | file | program] + description: | + Array of source files. *(since 0.41.0)* the array is flattened. + `program` is supported *since 1.11.2*. install: type: bool diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index d414e8ee8..ef83dc41b 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -9,7 +9,7 @@ import typing as T from .. import compilers from ..build import (CustomTarget, BuildTarget, - CustomTargetIndex, ExtractedObjects, GeneratedList, IncludeDirs, + CustomTargetIndex, ExtractedObjects, GeneratedList, IncludeDirs, LocalProgram, BothLibraries, SharedLibrary, StaticLibrary, Jar, Executable, StructuredSources) from ..options import OptionKey from ..dependencies import Dependency, DependencyMethods, InternalDependency @@ -25,6 +25,7 @@ NoneType: T.Type[None] = type(None) if T.TYPE_CHECKING: from typing_extensions import Literal + from .kwargs import CustomTargetInputs from ..build import ObjectTypes, GeneratedTypes, BuildTargetTypes from ..interpreterbase import TYPE_var from ..options import ElementaryOptionValues @@ -351,11 +352,22 @@ OUTPUT_KW: KwargInfo[str] = KwargInfo( validator=lambda x: _output_validator([x]) ) -CT_INPUT_KW: KwargInfo[T.List[T.Union[str, File, ExternalProgram, BuildTarget, GeneratedTypes, ExtractedObjects]]] = KwargInfo( +def _local_program_convertor(raw: T.List[T.Union[str, File, BuildTarget, GeneratedTypes, ExtractedObjects, LocalProgram]]) -> T.List[CustomTargetInputs]: + result: T.List[CustomTargetInputs] = [] + for i in raw: + if isinstance(i, LocalProgram): + result.append(i.get_target()) + else: + result.append(i) + return result + +CT_INPUT_KW: KwargInfo[T.List[T.Union[str, File, BuildTarget, GeneratedTypes, ExtractedObjects, LocalProgram]]] = KwargInfo( 'input', - ContainerTypeInfo(list, (str, File, ExternalProgram, BuildTarget, CustomTarget, CustomTargetIndex, ExtractedObjects, GeneratedList)), + ContainerTypeInfo(list, (str, File, BuildTarget, CustomTarget, CustomTargetIndex, ExtractedObjects, GeneratedList, Program)), listify=True, default=[], + convertor=_local_program_convertor, + since_values={ExternalProgram: '1.11.2'}, ) CT_INSTALL_TAG_KW: KwargInfo[T.List[T.Union[str, bool]]] = KwargInfo(