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
Change-Id: Ib277f99ea1e87253b93f59e463bd6c7dd8b3203e
Reviewed-by: Toni Saario <toni.saario@qt.io>
(cherry picked from commit 08448a5f48748fec88c52659361af3546196bd7f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Iikka Eklund 2021-05-27 11:24:35 +03:00 committed by Qt Cherry-pick Bot
parent a1a051f792
commit dc9d23451e
2 changed files with 12 additions and 14 deletions

View File

@ -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")

View File

@ -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