aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIikka Eklund <iikka.eklund@qt.io>2021-08-10 13:27:38 +0300
committerIikka Eklund <iikka.eklund@qt.io>2022-02-04 08:04:31 +0000
commit5395b44435b3b47eff991d0b5a17c653e9f70b88 (patch)
tree005c8d17440538e344757e28c2fb1e04eeebbdf7
parent87888b1ff87404c7c74724963fa038ffad442427 (diff)
Conan: Inherit recipe class from QtLeafModule for common functionality
The qt-conan-common package implements a base class for Qt leaf module recipes. The build steps in leaf modules are mostly identical so it makes sense to put those in the base class. Dependencies are read by the base class from the 'dependencies.yaml' which is the same file the CI system uses. Change-Id: I2b9f9f449eb8a855f7e8109c7268063e006bd3e2 Reviewed-by: Toni Saario <toni.saario@qt.io> (cherry picked from commit 0aaf1d17d03118b96e6773acfe4c79d65aaa9b2c)
-rw-r--r--conanfile.py62
1 files changed, 17 insertions, 45 deletions
diff --git a/conanfile.py b/conanfile.py
index c600997ff6..a2ca5cecc5 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -27,11 +27,9 @@
#############################################################################
from conans import ConanFile
-import os
import re
-from functools import lru_cache
from pathlib import Path
-
+from typing import Dict, Any
_qtdeclarative_features = [
"qml-animation",
@@ -69,63 +67,37 @@ _qtdeclarative_features = [
]
-@lru_cache(maxsize=8)
def _parse_qt_version_by_key(key: str) -> str:
- with open(Path(Path(__file__).parent.resolve() / ".cmake.conf")) as f:
- ret = [m.group(1) for m in [re.search(r"{0} .*\"(.*)\"".format(key), f.read())] if m]
- return ret.pop() if ret else ""
+ with open(Path(__file__).parent.resolve() / ".cmake.conf") as f:
+ m = re.search(fr'{key} .*"(.*)"', f.read())
+ return m.group(1) if m else ""
def _get_qt_minor_version() -> str:
- return _parse_qt_version_by_key('QT_REPO_MODULE_VERSION')[0:3]
+ return ".".join(_parse_qt_version_by_key("QT_REPO_MODULE_VERSION").split(".")[:2])
class QtDeclarative(ConanFile):
name = "qtdeclarative"
- license = "LGPL-3.0-only, Commercial Qt License Agreement"
+ license = "LGPL-3.0, GPL-2.0+, Commercial Qt License Agreement"
author = "The Qt Company <https://www.qt.io/contact-us>"
- url = "https://code.qt.io/cgit/qt/qtdeclarative.git/"
+ url = "https://code.qt.io/cgit/qt/qtdeclarative.git"
description = (
"The Qt Declarative module provides a declarative framework for building highly dynamic, "
"custom user interfaces"
)
- topics = ("qt", "qt6", "qtdeclarative")
+ topics = "qt", "qt6", "qtdeclarative"
settings = "os", "compiler", "arch", "build_type"
- exports = ".cmake.conf" # for referencing the version number and prerelease tag
+ # for referencing the version number and prerelease tag and dependencies info
+ exports = ".cmake.conf", "dependencies.yaml"
exports_sources = "*", "!conan*.*"
- # use commit ID as the RREV (recipe revision) if this is exported from .git repository
- revision_mode = "scm" if Path(Path(__file__).parent.resolve() / ".git").exists() else "hash"
python_requires = f"qt-conan-common/{_get_qt_minor_version()}@qt/everywhere"
+ python_requires_extend = "qt-conan-common.QtLeafModule"
- options = {item.replace("-", "_"): ["yes", "no", None] for item in _qtdeclarative_features}
- default_options = {item.replace("-", "_"): None for item in _qtdeclarative_features}
-
- def set_version(self):
- _ver = _parse_qt_version_by_key("QT_REPO_MODULE_VERSION")
- _prerelease = _parse_qt_version_by_key("QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT")
- self.version = _ver + "-" + _prerelease if _prerelease else _ver
-
- def requirements(self):
- _version = _parse_qt_version_by_key("QT_REPO_MODULE_VERSION")
- # will match latest prerelase of final major.minor.patch
- self.requires(f"qtbase/[<={_version}, include_prerelease=True]@{self.user}/{self.channel}")
- self.requires(f"qtsvg/[<={_version}, include_prerelease=True]@{self.user}/{self.channel}")
- self.requires(f"qtshadertools/[<={_version}, include_prerelease=True]@{self.user}/{self.channel}")
-
- def build(self):
- self.python_requires["qt-conan-common"].module.build_leaf_qt_module(self)
-
- def package(self):
- cmd = ["cmake", "--install", "."]
- self.run(" ".join(cmd), run_environment=True)
-
- def package_info(self):
- self.python_requires["qt-conan-common"].module.package_info(self)
-
- def package_id(self):
- self.info.requires.package_revision_mode()
+ def get_qt_leaf_module_options(self) -> Dict[str, Any]:
+ """Implements abstractmethod from qt-conan-common.QtLeafModule"""
+ return {item.replace("-", "_"): ["yes", "no", None] for item in _qtdeclarative_features}
- def deploy(self):
- self.copy("*") # copy from current package
- if not os.environ.get("QT_CONAN_INSTALL_SKIP_DEPS"):
- self.copy_deps("*") # copy from dependencies
+ def get_qt_leaf_module_default_options(self) -> Dict[str, Any]:
+ """Implements abstractmethod from qt-conan-common.QtLeafModule"""
+ return {item.replace("-", "_"): None for item in _qtdeclarative_features}