summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIikka Eklund <iikka.eklund@qt.io>2021-05-27 11:24:35 +0300
committerIikka Eklund <iikka.eklund@qt.io>2021-06-21 15:19:16 +0300
commit08448a5f48748fec88c52659361af3546196bd7f (patch)
treead4fb7d57cef152b64fce01e9930e72c483a30ce
parentc92c3c19e8ba02eeceff882b71571a076bef504d (diff)
Conan: Read status flag from .cmake.conf
The status information (alpha1, beta2, rc3, ...) needs to be part of the Conan package reference. As Conan supports semantic versioning the best place to put the status is to append it to the version string: qtbase/6.2.0-alpha1@qt/everywhere qtbase/6.2.0-beta2@qt/everywhere qtbase/6.2.0-rc3@qt/everywhere qtbase/6.2.0@qt/everywhere Other Conan packages declaring a dependency can use e.g. syntax: # notice the asterix character after version self.requires(f"qtbase/[<=<version>, include_prerelease=True}]@..) This way the status information is not in the Conan channel part and downstream consumers of the Conan package does not need to update the dependency (Conan reference string) every time the version changes. Put the status information next to Qt version string in .cmake.cache. Task-number: QTBUG-94385 Pick-to: 6.2 Change-Id: Ib277f99ea1e87253b93f59e463bd6c7dd8b3203e Reviewed-by: Toni Saario <toni.saario@qt.io>
-rw-r--r--.cmake.conf1
-rw-r--r--conanfile.py25
2 files changed, 12 insertions, 14 deletions
diff --git a/.cmake.conf b/.cmake.conf
index 099f7e7563..a63f70d6b9 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -1,4 +1,5 @@
set(QT_REPO_MODULE_VERSION "6.2.0")
+set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
# Minimum requirement for building Qt
set(QT_MIN_SUPPORTED_CMAKE_VERSION "3.16")
diff --git a/conanfile.py b/conanfile.py
index 610ce75f21..15d90fc883 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -316,36 +316,33 @@ class QtOptionParser:
return ret
+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 ""
+
+
class QtBase(ConanFile):
name = "qtbase"
license = "GPL-3.0+, Commercial Qt License Agreement"
author = "The Qt Company <https://www.qt.io/contact-us>"
url = "https://code.qt.io/cgit/qt/qtbase.git/"
description = "Qt6 core framework libraries and tools."
- topics = ("status:rc1", "qt", "qt6")
+ topics = ("qt", "qt6")
settings = "os", "compiler", "arch", "build_type"
_qt_option_parser = QtOptionParser()
options = _qt_option_parser.get_qt_conan_options()
default_options = _qt_option_parser.get_default_qt_conan_options()
- exports = "configure_options.json", "configure_features.txt"
+ exports = "configure_options.json", "configure_features.txt", ".cmake.conf"
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"
- def _parse_qt_version(self, source_path: Path) -> str:
- cmake_conf = Path(source_path / ".cmake.conf").resolve(strict=True)
- print(f"Parsing Qt version from: {cmake_conf}")
- with open(str(cmake_conf)) as f:
- for line in f:
- match = re.search(r"QT_REPO_MODULE_VERSION.*\"([\d.]+)\"", line)
- if match:
- return match.group(1)
- else:
- raise QtConanError(f"Unable to parse Qt version from: {cmake_conf}")
-
def set_version(self):
# Executed during "conan export" i.e. in source tree
- self.version = self._parse_qt_version(Path(__file__).parent.absolute())
+ _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 source(self):
# sources are installed next to recipe, no need to clone sources here