Skip to content

Commit

Permalink
fix custom_target crash if boolean true is specified in install_dir
Browse files Browse the repository at this point in the history
We accept boolean false to indicate "do not install this one particular
output", but the type checking simply checked if it is a bool. We do
this correctly for configure_file, so copy the same validator from
there.
  • Loading branch information
eli-schwartz committed May 26, 2022
1 parent 9b91540 commit fda4c49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mesonbuild/interpreter/kwargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class CustomTarget(TypedDict):
input: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex,
build.ExtractedObjects, build.GeneratedList, ExternalProgram, File]]
install: bool
install_dir: T.List[T.Union[str, bool]]
install_dir: T.List[T.Union[str, T.Literal[False]]]
install_mode: FileMode
install_tag: T.List[T.Optional[str]]
output: T.List[str]
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/interpreter/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,12 @@ def _output_validator(outputs: T.List[str]) -> T.Optional[str]:

INSTALL_KW = KwargInfo('install', bool, default=False)

CT_INSTALL_DIR_KW: KwargInfo[T.List[T.Union[str, bool]]] = KwargInfo(
CT_INSTALL_DIR_KW: KwargInfo[T.List[T.Union[str, Literal[False]]]] = KwargInfo(
'install_dir',
ContainerTypeInfo(list, (str, bool)),
listify=True,
default=[],
validator=lambda x: 'must be `false` if boolean' if True in x else None,
)

CT_BUILD_BY_DEFAULT: KwargInfo[T.Optional[bool]] = KwargInfo('build_by_default', (bool, type(None)), since='0.40.0')
Expand Down

0 comments on commit fda4c49

Please sign in to comment.