From 214d03568f75fbd578cc97d46f48d5d882f3870b Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 1 Sep 2021 00:13:46 -0400 Subject: new custom dependency lookup for iconv Also internally needed by intl, so add that as a proxied dependency instead of coding it manually. --- mesonbuild/dependencies/__init__.py | 3 ++- mesonbuild/dependencies/misc.py | 30 +++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'mesonbuild/dependencies') diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index bd90c90..ff0bd30 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -35,7 +35,7 @@ from .scalapack import scalapack_factory from .misc import ( BlocksDependency, OpenMPDependency, cups_factory, curses_factory, gpgme_factory, libgcrypt_factory, libwmf_factory, netcdf_factory, pcap_factory, python3_factory, - shaderc_factory, threads_factory, ThreadDependency, intl_factory, + shaderc_factory, threads_factory, ThreadDependency, iconv_factory, intl_factory, ) from .platform import AppleFrameworks from .qt import qt4_factory, qt5_factory, qt6_factory @@ -252,6 +252,7 @@ packages.update({ 'libgcrypt': libgcrypt_factory, 'gpgme': gpgme_factory, 'shaderc': shaderc_factory, + 'iconv': iconv_factory, 'intl': intl_factory, # From platform: diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index faf06a1..daa7dff 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -448,6 +448,25 @@ class CursesSystemDependency(SystemDependency): break +class IconvBuiltinDependency(BuiltinDependency): + def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + super().__init__(name, env, kwargs) + + if self.clib_compiler.has_function('iconv_open', '', env)[0]: + self.is_found = True + + +class IconvSystemDependency(SystemDependency): + def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): + super().__init__(name, env, kwargs) + + h = self.clib_compiler.has_header('iconv.h', '', env) + self.link_args = self.clib_compiler.find_library('iconv', env, [], self.libtype) + + if h[0] and self.link_args: + self.is_found = True + + class IntlBuiltinDependency(BuiltinDependency): def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): super().__init__(name, env, kwargs) @@ -467,7 +486,9 @@ class IntlSystemDependency(SystemDependency): self.is_found = True if self.static: - self.link_args += self.clib_compiler.find_library('iconv', env, [], self.libtype) + if not self._add_sub_dependency(iconv_factory(env, self.for_machine, {})): + self.is_found = False + return @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM}) @@ -580,6 +601,13 @@ threads_factory = DependencyFactory( system_class=ThreadDependency, ) +iconv_factory = DependencyFactory( + 'iconv', + [DependencyMethods.BUILTIN, DependencyMethods.SYSTEM], + builtin_class=IconvBuiltinDependency, + system_class=IconvSystemDependency, +) + intl_factory = DependencyFactory( 'intl', [DependencyMethods.BUILTIN, DependencyMethods.SYSTEM], -- cgit v1.1