mirror of
https://github.com/mesonbuild/meson.git
synced 2026-08-09 01:01:17 +00:00
interpreter: allow Program for custom_target inputs
Previous version of Meson were returning an Executable instead of the LocalProgram, so allow it again; use a convertor so that the LocalProgram is resolved to the underlying file or target. Add support for ExternalProgram while at it. Fixes: #15774 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
committed by
Paolo Bonzini
parent
b9f01e810f
commit
8035ea6f5c
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user