From ff3083c95688b70d33105b2abbf6e62064662e1b Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 15 Nov 2022 11:02:15 -0800 Subject: [PATCH] type_checking: add a type checking helper for strings in include_directories --- mesonbuild/interpreter/type_checking.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index 9cee49567..0783c2c2e 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -13,6 +13,7 @@ from ..build import (CustomTarget, BuildTarget, BothLibraries, SharedLibrary, StaticLibrary, Jar, Executable) from ..coredata import UserFeatureOption from ..dependencies import Dependency, InternalDependency +from ..interpreterbase import FeatureNew from ..interpreterbase.decorators import KwargInfo, ContainerTypeInfo from ..mesonlib import ( File, FileMode, MachineChoice, listify, has_path_sep, OptionKey, @@ -26,6 +27,7 @@ if T.TYPE_CHECKING: from typing_extensions import Literal from ..interpreterbase import TYPE_var + from ..interpreterbase.decorators import FeatureCheckBase def in_set_validator(choices: T.Set[str]) -> T.Callable[[str], T.Optional[str]]: """Check that the choice given was one of the given set.""" @@ -373,6 +375,13 @@ INCLUDE_DIRECTORIES: KwargInfo[T.List[T.Union[str, IncludeDirs]]] = KwargInfo( default=[], ) +def include_dir_string_new(val: T.List[T.Union[str, IncludeDirs]]) -> T.Iterable[FeatureCheckBase]: + strs = [v for v in val if isinstance(v, str)] + if strs: + str_msg = ", ".join(f"'{s}'" for s in strs) + yield FeatureNew('include_directories kwarg of type string', '1.0.0', + f'Use include_directories({str_msg}) instead') + # for cases like default_options and override_options DEFAULT_OPTIONS: KwargInfo[T.List[str]] = KwargInfo( 'default_options',