From 9add5d03b63b841dc437c9b0e9e2b8d43b96ea7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hagen=20M=C3=B6bius?= Date: Fri, 9 Sep 2022 23:52:42 +0100 Subject: [PATCH] Add handling Qt6's EntryPoint library. - this fixes #10792 - Qt6EntryPoint(d) replaces qtmain(d) from Qt 4 & 5 - uses the same mechanism: `main: true` - uses a special mixin class for pkg-config and config-tool dependency calculation --- mesonbuild/dependencies/qt.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/mesonbuild/dependencies/qt.py b/mesonbuild/dependencies/qt.py index ea8b849d1..e1e9e07dd 100644 --- a/mesonbuild/dependencies/qt.py +++ b/mesonbuild/dependencies/qt.py @@ -145,15 +145,18 @@ class _QtBase: if not isinstance(self.qtmain, bool): raise DependencyException('"main" argument must be a boolean') - def _link_with_qtmain(self, is_debug: bool, libdir: T.Union[str, T.List[str]]) -> bool: + def _link_with_qt_winmain(self, is_debug: bool, libdir: T.Union[str, T.List[str]]) -> bool: libdir = mesonlib.listify(libdir) # TODO: shouldn't be necessary - base_name = 'qtmaind' if is_debug else 'qtmain' - qtmain = self.clib_compiler.find_library(base_name, self.env, libdir) - if qtmain: - self.link_args.append(qtmain[0]) + base_name = self.get_qt_winmain_base_name(is_debug) + qt_winmain = self.clib_compiler.find_library(base_name, self.env, libdir) + if qt_winmain: + self.link_args.append(qt_winmain[0]) return True return False + def get_qt_winmain_base_name(self, is_debug: bool) -> str: + return 'qtmaind' if is_debug else 'qtmain' + def get_exe_args(self, compiler: 'Compiler') -> T.List[str]: # Originally this was -fPIE but nowadays the default # for upstream and distros seems to be -reduce-relocations @@ -212,7 +215,7 @@ class QtPkgConfigDependency(_QtBase, PkgConfigDependency, metaclass=abc.ABCMeta) is_debug = True break libdir = self.get_pkgconfig_variable('libdir', [], None) - if not self._link_with_qtmain(is_debug, libdir): + if not self._link_with_qt_winmain(is_debug, libdir): self.is_found = False return @@ -332,7 +335,7 @@ class QmakeQtDependency(_QtBase, ConfigToolDependency, metaclass=abc.ABCMeta): self.link_args.append(libfile) if self.env.machines[self.for_machine].is_windows() and self.qtmain: - if not self._link_with_qtmain(is_debug, libdir): + if not self._link_with_qt_winmain(is_debug, libdir): self.is_found = False def _sanitize_version(self, version: str) -> str: @@ -375,6 +378,12 @@ class QmakeQtDependency(_QtBase, ConfigToolDependency, metaclass=abc.ABCMeta): return 'qmake' +class Qt6WinMainMixin: + + def get_qt_winmain_base_name(self, is_debug: bool) -> str: + return 'Qt6EntryPointd' if is_debug else 'Qt6EntryPoint' + + class Qt4ConfigToolDependency(QmakeQtDependency): def get_private_includes(self, mod_inc_dir: str, module: str) -> T.List[str]: @@ -387,7 +396,7 @@ class Qt5ConfigToolDependency(QmakeQtDependency): return _qt_get_private_includes(mod_inc_dir, module, self.version) -class Qt6ConfigToolDependency(QmakeQtDependency): +class Qt6ConfigToolDependency(Qt6WinMainMixin, QmakeQtDependency): def get_private_includes(self, mod_inc_dir: str, module: str) -> T.List[str]: return _qt_get_private_includes(mod_inc_dir, module, self.version) @@ -431,7 +440,7 @@ class Qt5PkgConfigDependency(QtPkgConfigDependency): return _qt_get_private_includes(mod_inc_dir, module, self.version) -class Qt6PkgConfigDependency(QtPkgConfigDependency): +class Qt6PkgConfigDependency(Qt6WinMainMixin, QtPkgConfigDependency): def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]): super().__init__(name, env, kwargs)