diff options
author | Iikka Eklund <iikka.eklund@qt.io> | 2022-06-21 12:13:34 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-22 17:21:43 +0000 |
commit | a9257e7ad0e673571f0979dc400fae0f1686b0fd (patch) | |
tree | dc360d2f865fd138092f56f4db79fe1a66bb45a0 | |
parent | 1892763c8c3872a41679f9e6540504cb1ef85b00 (diff) |
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.
Change-Id: I4c1d8b5253e33466ccdf463f89473966e90c0e0c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Toni Saario <toni.saario@qt.io>
(cherry picked from commit 5271f5082cd5413c618fc464fbeea6529626838b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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 |