summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIikka Eklund <iikka.eklund@qt.io>2021-06-28 10:55:31 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-26 06:58:47 +0000
commit8234fb149d812b9ac99be466cd5e025029aaa38c (patch)
treea9e2c316c0f5bb720f1a36166654c2dedcee4a68
parent25f34210a1975e92f816ed61f676e2111aa8f6b7 (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. Task-number: QTBUG-94816 Change-Id: Idb08326dc13b90b2a70db3a2f53e5a4d4a348adb Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io> Reviewed-by: Toni Saario <toni.saario@qt.io> (cherry picked from commit c49ae50dc3bb0cf4235c85333a42fb5b91962a2f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--.cmake.conf1
-rw-r--r--conanfile.py93
2 files changed, 18 insertions, 76 deletions
diff --git a/.cmake.conf b/.cmake.conf
index 4e73b3d..4aa8eb1 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -1 +1,2 @@
set(QT_REPO_MODULE_VERSION "6.2.0")
+set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
diff --git a/conanfile.py b/conanfile.py
index 5aacf4f..d00c0b8 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -26,90 +26,31 @@
##
#############################################################################
-from conans import ConanFile, tools, CMake
-import os
+from conans import ConanFile
+import re
from pathlib import Path
-class QtConanError(Exception):
- pass
+def _parse_qt_version_by_key(key: str) -> str:
+ 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 ".".join(_parse_qt_version_by_key("QT_REPO_MODULE_VERSION").split(".")[:2])
class QtActiveQtFormats(ConanFile):
name = "qtactiveqt"
- version = "6.2.0"
- license = "LGPL-3.0+, GPL-2.0+, 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/qtactiveqt.git"
description = "Active Qt adds support for ActiveX and COM functionality for Qt on Windows."
- topics = ("qt", "qt6", "addon", "ActiveX", "COM", "Windows")
- settings = "os", "compiler", "build_type", "arch"
- options = {"shared": [True, False, "default"],
- "qt6": "ANY"} # this is needed to model unique package_id for the Add-on build per used Qt6 version
- default_options = {"shared": "default", # default: Use the value of the Qt build
- "qt6": None}
+ topics = "qt", "qt6", "addon", "ActiveX", "COM", "Windows"
+ settings = "os", "compiler", "arch", "build_type"
+ # 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"
-
- def source(self):
- # sources are installed next to recipe, no need to clone etc. sources here
- pass
-
- def _get_cmake_prefix_path(self):
- # 'QTDIR' provided as env variable in profile file which is part of the Qt essential binary
- # package(s). Installed under .conan/profiles
- cmake_prefix_path = os.environ.get("QTDIR")
- if not cmake_prefix_path:
- raise QtConanError("'QTDIR' not defined! The 'QTDIR' needs to point to Qt installation directory.")
- print(f"CMAKE_PREFIX_PATH for '{self.name}/{self.version}' build is: {cmake_prefix_path}")
- return cmake_prefix_path
-
- def _read_env(self, key):
- value = os.environ.get(key)
- if not value:
- raise QtConanError(f"{self.settings.os} build specified but '{key}' was not defined?")
- return value
-
- def _get_qtcmake(self):
- qt_install_path = self._get_cmake_prefix_path()
- ext = ".bat" if tools.os_info.is_windows else ""
- qtcmake = os.path.abspath(os.path.join(qt_install_path, "bin", "qt-cmake" + ext))
- if not os.path.exists(qtcmake):
- raise QtConanError(f"Unable to locate {qtcmake} from 'QTDIR': {qt_install_path}")
- return qtcmake
-
- def _get_cmake_tool(self):
- cmake = CMake(self, cmake_program=self._get_qtcmake())
- cmake.verbose = True
-
- # Qt modules need to be 'installed'.
- # We need to direct the 'make install' to some directory under Conan cache,
- # place it under the current build directory which is also under the Conan cache.
- # Note, the actual 'make install' is called in "package()".
- install_dir = os.path.join(os.getcwd(), "_install_tmp")
- cmake.definitions["CMAKE_INSTALL_PREFIX"] = install_dir
-
- cmake_toolchain_file = os.environ.get("CMAKE_TOOLCHAIN_FILE")
- if cmake_toolchain_file:
- cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = cmake_toolchain_file
-
- return cmake
-
- def build(self):
- cmake = self._get_cmake_tool()
- self.run('%s "%s" %s' % (self._get_qtcmake(), self.source_folder, cmake.command_line))
- self.run('cmake --build . %s' % cmake.build_config)
-
- def package(self):
- install_dir = os.path.join(os.getcwd(), "_install_tmp") # see 'CMAKE_INSTALL_PREFIX' above
- self.run('cmake --build . --target install')
- self.copy("*", src=install_dir, dst=".")
-
- def package_info(self):
- self.cpp_info.libs = ["Qt6AxBase", "Qt6AxContainer", "Qt6AxServer"] # used for the actual library filename, Ordered list with the library names
-
- def deploy(self):
- self.copy("*") # copy from current package
- self.copy_deps("*") # copy from dependencies
-
+ python_requires = f"qt-conan-common/{_get_qt_minor_version()}@qt/everywhere"
+ python_requires_extend = "qt-conan-common.QtLeafModule"