aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/qt.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-03-22 15:25:29 -0700
committerDylan Baker <dylan@pnwbakers.com>2021-03-23 15:28:08 -0700
commitc211fea51389728783cf59ae41156a5e0de9c41a (patch)
tree3269d721c713be5e7cd9d0c3a30e14b20b58e46e /mesonbuild/modules/qt.py
parent54c55f77a976deb0047a78468250b75525df6514 (diff)
downloadmeson-c211fea51389728783cf59ae41156a5e0de9c41a.zip
meson-c211fea51389728783cf59ae41156a5e0de9c41a.tar.gz
meson-c211fea51389728783cf59ae41156a5e0de9c41a.tar.bz2
Refactor Qt Dependency into proper split classes with factories
Currently the Qt Dependencies still use the old "combined" method for dependencies with multiple ways to be found. This is problematic as it means that `get_variable()` and friends don't work, as the dependency can't implement any of those methods. The correct solution is to make use of multiple Dependency instances, and a factory to tie them together. This does that. To handle QMake, I've leveraged the existing config-tool mechanism, which allows us to save a good deal of code, and use well tested code instead of rolling more of our own code. The one thing this doesn't do, but we probably should, is expose the macOS ExtraFrameworks directly, instead of forcing them to be found through QMake. That is a problem for another series, and someone who cares more about macOS than I do.
Diffstat (limited to 'mesonbuild/modules/qt.py')
-rw-r--r--mesonbuild/modules/qt.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index addc571..645696d 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from mesonbuild.dependencies.base import find_external_dependency
import os
import shutil
import typing as T
@@ -20,7 +21,7 @@ from .. import mlog
from .. import build
from .. import mesonlib
from ..mesonlib import MesonException, extract_as_list, File, unholder, version_compare
-from ..dependencies import Dependency, Qt4Dependency, Qt5Dependency, Qt6Dependency
+from ..dependencies import Dependency
import xml.etree.ElementTree as ET
from . import ModuleReturnValue, get_include_args, ExtensionModule
from ..interpreterbase import noPosargs, permittedKwargs, FeatureNew, FeatureNewKwargs
@@ -28,16 +29,11 @@ from ..interpreter import extract_required_kwarg
from ..programs import NonExistingExternalProgram
if T.TYPE_CHECKING:
- from .. import Interpreter
+ from ..interpreter import Interpreter
from ..dependencies.qt import QtBaseDependency
+ from ..environment import Environment
from ..programs import ExternalProgram
-_QT_DEPS_LUT = {
- 4: Qt4Dependency,
- 5: Qt5Dependency,
- 6: Qt6Dependency,
-}
-
class QtBaseModule(ExtensionModule):
tools_detected = False
@@ -57,7 +53,7 @@ class QtBaseModule(ExtensionModule):
# It is important that this list does not change order as the order of
# the returned ExternalPrograms will change as well
bins = ['moc', 'uic', 'rcc', 'lrelease']
- found = {b: NonExistingExternalProgram(name=f'{b}-{qt_dep.name}')
+ found = {b: NonExistingExternalProgram(name=f'{b}-qt{qt_dep.qtver}')
for b in bins}
wanted = f'== {qt_dep.version}'
@@ -67,7 +63,7 @@ class QtBaseModule(ExtensionModule):
yield os.path.join(qt_dep.bindir, b), b
# prefer the <tool>-qt<version> of the tool to the plain one, as we
# don't know what the unsuffixed one points to without calling it.
- yield f'{b}-{qt_dep.name}', b
+ yield f'{b}-qt{qt_dep.qtver}', b
yield b, b
for b, name in gen_bins():
@@ -97,13 +93,13 @@ class QtBaseModule(ExtensionModule):
if p.found():
setattr(self, name, p)
- def _detect_tools(self, env, method, required=True):
+ def _detect_tools(self, env: 'Environment', method, required=True):
if self.tools_detected:
return
self.tools_detected = True
mlog.log(f'Detecting Qt{self.qt_version} tools')
kwargs = {'required': required, 'modules': 'Core', 'method': method}
- qt = _QT_DEPS_LUT[self.qt_version](env, kwargs)
+ qt = find_external_dependency(f'qt{self.qt_version}', env, kwargs)
if qt.found():
# Get all tools and then make sure that they are the right version
self.compilers_detect(qt)
@@ -247,7 +243,7 @@ class QtBaseModule(ExtensionModule):
compile_args = []
for dep in unholder(dependencies):
if isinstance(dep, Dependency):
- for arg in dep.get_compile_args():
+ for arg in dep.get_all_compile_args():
if arg.startswith('-I') or arg.startswith('-D'):
compile_args.append(arg)
else: