diff options
author | Iikka Eklund <iikka.eklund@qt.io> | 2022-06-21 12:13:34 +0300 |
---|---|---|
committer | Iikka Eklund <iikka.eklund@qt.io> | 2022-06-22 18:18:42 +0300 |
commit | 5271f5082cd5413c618fc464fbeea6529626838b (patch) | |
tree | 890e56c2c8e1c5a6b710addfbc69c310193f6624 /conanfile.py | |
parent | 2c0518eb62ebe475abf84b8ee2fd50c53720d3a4 (diff) | |
download | qtbase-5271f5082cd5413c618fc464fbeea6529626838b.tar.gz |
Conan: Do not force 'qt_host_path' usage in cross-build context
If the user does not pass:
-o qtbase:qt_host_path=/foo
then log a warning but allow to continue. For example Boot2Qt
integration resolves the 'QT_HOST_PATH' by other means thus making it
a mandatory option to be passed by the user should not be needed.
Pick-to: 6.3 6.4
Change-Id: I4c1d8b5253e33466ccdf463f89473966e90c0e0c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Toni Saario <toni.saario@qt.io>
Diffstat (limited to 'conanfile.py')
-rw-r--r-- | conanfile.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/conanfile.py b/conanfile.py index b2a7189f1a..3f05cedabf 100644 --- a/conanfile.py +++ b/conanfile.py @@ -8,7 +8,7 @@ import re import shutil from functools import lru_cache from pathlib import Path -from typing import Dict +from typing import Dict, Union class QtConanError(Exception): @@ -128,13 +128,22 @@ class QtBase(ConanFile): print("Setting 3rd party package requirement: {0}".format(requirement)) self.requires(requirement) - def _resolve_qt_host_path(self) -> str: - # When cross-building the user needs to pass 'qt_host_path' which is transformed to - # QT_HOST_PATH later on. Resolve the exact path. - qt_host_path = self.options.get_safe("qt_host_path") - if not qt_host_path: - raise QtConanError("Expected 'qt_host_path' option in cross-build context") - return str(Path(os.path.expandvars(str(qt_host_path))).expanduser().resolve(strict=True)) + def _resolve_qt_host_path(self) -> Union[str, None]: + """ + Attempt to resolve QT_HOST_PATH. + + When cross-building the user needs to pass 'qt_host_path' which is transformed to + QT_HOST_PATH later on. Resolve the exact path if possible. + + Returns: + string: The resolved QT_HOST_PATH or None if unable to determine it. + """ + _host_p = self.options.get_safe("qt_host_path") + if _host_p: + return str(Path(os.path.expandvars(str(_host_p))).expanduser().resolve(strict=True)) + else: + print("Warning: 'qt_host_path' option was not given in cross-build context") + return None def configure(self): if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "8": @@ -249,7 +258,9 @@ class QtBase(ConanFile): def package_info(self): self._shared.package_info(self) if tools.cross_building(conanfile=self): - self.env_info.QT_HOST_PATH.append(self._resolve_qt_host_path()) + qt_host_path = self._resolve_qt_host_path() + if qt_host_path: + self.env_info.QT_HOST_PATH.append(qt_host_path) def package_id(self): # https://docs.conan.io/en/latest/creating_packages/define_abi_compatibility.html |