diff options
Diffstat (limited to 'mesonbuild/dependencies/misc.py')
| -rw-r--r-- | mesonbuild/dependencies/misc.py | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 3ab2194e3..9f6746328 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -21,15 +21,16 @@ from ..options import OptionKey if T.TYPE_CHECKING: from ..environment import Environment + from .base import DependencyObjectKWs from .factory import DependencyGenerator @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE}) def netcdf_factory(env: 'Environment', for_machine: 'mesonlib.MachineChoice', - kwargs: T.Dict[str, T.Any], + kwargs: DependencyObjectKWs, methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']: - language = kwargs.get('language') + language = T.cast('T.Optional[str]', kwargs.get('language')) if language is None: language = 'c' if language not in ('c', 'cpp', 'fortran'): @@ -54,7 +55,7 @@ packages['netcdf'] = netcdf_factory class AtomicBuiltinDependency(BuiltinDependency): - def __init__(self, name: str, env: Environment, kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: Environment, kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) self.feature_since = ('1.7.0', "consider checking for `atomic_flag_clear` with and without `find_library('atomic')`") @@ -63,7 +64,7 @@ class AtomicBuiltinDependency(BuiltinDependency): class AtomicSystemDependency(SystemDependency): - def __init__(self, name: str, env: Environment, kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: Environment, kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) self.feature_since = ('1.7.0', "consider checking for `atomic_flag_clear` with and without `find_library('atomic')`") @@ -75,7 +76,7 @@ class AtomicSystemDependency(SystemDependency): class DlBuiltinDependency(BuiltinDependency): - def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) self.feature_since = ('0.62.0', "consider checking for `dlopen` with and without `find_library('dl')`") @@ -84,7 +85,7 @@ class DlBuiltinDependency(BuiltinDependency): class DlSystemDependency(SystemDependency): - def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) self.feature_since = ('0.62.0', "consider checking for `dlopen` with and without `find_library('dl')`") @@ -111,8 +112,8 @@ class OpenMPDependency(SystemDependency): '199810': '1.0', } - def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]) -> None: - language = kwargs.get('language') + def __init__(self, environment: 'Environment', kwargs: DependencyObjectKWs) -> None: + language = T.cast('T.Optional[str]', kwargs.get('language')) super().__init__('openmp', environment, kwargs, language=language) self.is_found = False if self.clib_compiler.get_id() == 'nagfor': @@ -165,7 +166,7 @@ packages['openmp'] = OpenMPDependency class ThreadDependency(SystemDependency): - def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]) -> None: + def __init__(self, name: str, environment: 'Environment', kwargs: DependencyObjectKWs) -> None: super().__init__(name, environment, kwargs) self.is_found = True # Happens if you are using a language with threads @@ -179,7 +180,7 @@ class ThreadDependency(SystemDependency): class BlocksDependency(SystemDependency): - def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]) -> None: + def __init__(self, environment: 'Environment', kwargs: DependencyObjectKWs) -> None: super().__init__('blocks', environment, kwargs) self.name = 'blocks' self.is_found = False @@ -222,7 +223,7 @@ class PcapDependencyConfigTool(ConfigToolDependency): # version 1.10.3 will hopefully add actual support for --version skip_version = '--help' - def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, environment: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, environment, kwargs) if not self.is_found: return @@ -251,7 +252,7 @@ class CupsDependencyConfigTool(ConfigToolDependency): tools = ['cups-config'] tool_name = 'cups-config' - def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, environment: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, environment, kwargs) if not self.is_found: return @@ -264,7 +265,7 @@ class LibWmfDependencyConfigTool(ConfigToolDependency): tools = ['libwmf-config'] tool_name = 'libwmf-config' - def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, environment: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, environment, kwargs) if not self.is_found: return @@ -277,7 +278,7 @@ class LibGCryptDependencyConfigTool(ConfigToolDependency): tools = ['libgcrypt-config'] tool_name = 'libgcrypt-config' - def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, environment: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, environment, kwargs) if not self.is_found: return @@ -291,7 +292,7 @@ class GpgmeDependencyConfigTool(ConfigToolDependency): tools = ['gpgme-config'] tool_name = 'gpg-config' - def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, environment: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, environment, kwargs) if not self.is_found: return @@ -302,7 +303,7 @@ class GpgmeDependencyConfigTool(ConfigToolDependency): class ShadercDependency(SystemDependency): - def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, environment: 'Environment', kwargs: DependencyObjectKWs): super().__init__('shaderc', environment, kwargs) static_lib = 'shaderc_combined' @@ -334,7 +335,7 @@ class CursesConfigToolDependency(ConfigToolDependency): # ncurses5.4-config is for macOS Catalina tools = ['ncursesw6-config', 'ncursesw5-config', 'ncurses6-config', 'ncurses5-config', 'ncurses5.4-config'] - def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None): + def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs, language: T.Optional[str] = None): exclude_paths = None # macOS mistakenly ships /usr/bin/ncurses5.4-config and a man page for # it, but none of the headers or libraries. Ignore /usr/bin because it @@ -358,7 +359,7 @@ class CursesSystemDependency(SystemDependency): implementations, and the differences between them can be very annoying. """ - def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) candidates = [ @@ -389,7 +390,7 @@ class CursesSystemDependency(SystemDependency): self.version = f'{v_major}.{v_minor}' # Check the version if possible, emit a warning if we can't - req = kwargs.get('version') + req = T.cast('T.Iterable[str]', kwargs.get('version')) if req: if self.version: self.is_found, *_ = mesonlib.version_compare_many(self.version, req) @@ -405,7 +406,7 @@ class CursesSystemDependency(SystemDependency): class IconvBuiltinDependency(BuiltinDependency): - def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) self.feature_since = ('0.60.0', "consider checking for `iconv_open` with and without `find_library('iconv')`") code = '''#include <iconv.h>\n\nint main() {\n iconv_open("","");\n}''' # [ignore encoding] this is C, not python, Mr. Lint @@ -415,7 +416,7 @@ class IconvBuiltinDependency(BuiltinDependency): class IconvSystemDependency(SystemDependency): - def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) self.feature_since = ('0.60.0', "consider checking for `iconv_open` with and without find_library('iconv')") @@ -427,7 +428,7 @@ class IconvSystemDependency(SystemDependency): class IntlBuiltinDependency(BuiltinDependency): - def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) self.feature_since = ('0.59.0', "consider checking for `ngettext` with and without `find_library('intl')`") code = '''#include <libintl.h>\n\nint main() {\n gettext("Hello world");\n}''' @@ -437,7 +438,7 @@ class IntlBuiltinDependency(BuiltinDependency): class IntlSystemDependency(SystemDependency): - def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) self.feature_since = ('0.59.0', "consider checking for `ngettext` with and without `find_library('intl')`") @@ -448,18 +449,18 @@ class IntlSystemDependency(SystemDependency): self.is_found = True if self.static: - if not self._add_sub_dependency(iconv_factory(env, self.for_machine, {'static': True})): + if not self._add_sub_dependency(iconv_factory(env, self.for_machine, {'static': True})): # type: ignore[typeddict-unknown-key] self.is_found = False class OpensslSystemDependency(SystemDependency): - def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs): super().__init__(name, env, kwargs) - dependency_kwargs = { + dependency_kwargs: DependencyObjectKWs = { 'method': 'system', 'static': self.static, - } + } # type: ignore[typeddict-unknown-key] if not self.clib_compiler.has_header('openssl/ssl.h', '', env)[0]: return @@ -506,7 +507,7 @@ class ObjFWDependency(ConfigToolDependency): tools = ['objfw-config'] tool_name = 'objfw-config' - def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]): + def __init__(self, environment: 'Environment', kwargs: DependencyObjectKWs): super().__init__('objfw', environment, kwargs) self.feature_since = ('1.5.0', '') if not self.is_found: @@ -516,7 +517,7 @@ class ObjFWDependency(ConfigToolDependency): # TODO: Expose --framework-libs extra_flags = [] - for module in mesonlib.stringlistify(mesonlib.extract_as_list(kwargs, 'modules')): + for module in mesonlib.stringlistify(mesonlib.extract_as_list(kwargs, 'modules')): # type: ignore[arg-type] extra_flags.append('--package') extra_flags.append(module) @@ -528,7 +529,7 @@ class ObjFWDependency(ConfigToolDependency): @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM}) def curses_factory(env: 'Environment', for_machine: 'mesonlib.MachineChoice', - kwargs: T.Dict[str, T.Any], + kwargs: DependencyObjectKWs, methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']: candidates: T.List['DependencyGenerator'] = [] @@ -554,7 +555,7 @@ packages['curses'] = curses_factory @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM}) def shaderc_factory(env: 'Environment', for_machine: 'mesonlib.MachineChoice', - kwargs: T.Dict[str, T.Any], + kwargs: DependencyObjectKWs, methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']: """Custom DependencyFactory for ShaderC. |
