Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt: add options to enable several modules at once #23171

Merged
merged 6 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions recipes/qt/5.x.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.errors import ConanException, ConanInvalidConfiguration
from conan.tools.android import android_abi
from conan.tools.apple import is_apple_os
from conan.tools.build import build_jobs, check_min_cppstd, cross_building
Expand Down Expand Up @@ -27,6 +27,8 @@
"qtspeech", "qtnetworkauth", "qtremoteobjects", "qtwebglplugin", "qtlottie", "qtquicktimeline", "qtquick3d",
"qtknx", "qtmqtt", "qtcoap", "qtopcua"]

_module_statuses = ["essential", "addon", "deprecated", "preview"]

name = "qt"
description = "Qt is a cross-platform framework for graphical user interfaces."
topics = ("ui", "framework")
Expand Down Expand Up @@ -78,6 +80,7 @@
"multiconfiguration": [True, False]
}
options.update({module: [True, False] for module in _submodules})
options.update({f"{status}_modules": [True, False] for status in _module_statuses})

default_options = {
"shared": False,
Expand Down Expand Up @@ -118,8 +121,10 @@
"cross_compile": None,
"sysroot": None,
"config": None,
"multiconfiguration": False
"multiconfiguration": False,
"essential_modules": not os.getenv('CONAN_CENTER_BUILD_SERVICE')
}
default_options.update({f"{status}_modules": False for status in _module_statuses if status != "essential"})

no_copy_source = True
short_paths = True
Expand Down Expand Up @@ -222,16 +227,6 @@
if not self.options.with_dbus:
del self.options.with_atspi

if not self.options.qtmultimedia:
self.options.rm_safe("with_libalsa")
del self.options.with_openal
del self.options.with_gstreamer
del self.options.with_pulseaudio

if self.settings.os in ("FreeBSD", "Linux"):
if self.options.qtwebengine:
self.options.with_fontconfig = True

if self.options.multiconfiguration:
del self.settings.build_type

Expand All @@ -246,6 +241,8 @@
modulename = section[section.find('"') + 1: section.rfind('"')]
status = str(config.get(section, "status"))
if status not in ("obsolete", "ignore"):
if status not in self._module_statuses:
raise ConanException(f"module {modulename} has status {status} which is not in self._module_statuses {self._module_statuses}")
submodules_tree[modulename] = {"status": status,
"path": str(config.get(section, "path")), "depends": []}
if config.has_option(section, "depends"):
Expand All @@ -267,11 +264,27 @@
for module in self._submodules:
if self.options.get_safe(module):
_enablemodule(module)
else:
if module in submodules_tree:
for status in self._module_statuses:
if getattr(self.options, f"{status}_modules") and submodules_tree[module]['status'] == status:
_enablemodule(module)
break

for module in self._submodules:
if module in self.options and not self.options.get_safe(module):
setattr(self.options, module, False)

if not self.options.qtmultimedia:
self.options.rm_safe("with_libalsa")
del self.options.with_openal
del self.options.with_gstreamer
del self.options.with_pulseaudio

if self.settings.os in ("FreeBSD", "Linux"):
if self.options.qtwebengine:
self.options.with_fontconfig = True

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, "11")
Expand Down Expand Up @@ -427,6 +440,8 @@
self.info.settings.compiler.runtime_type = "Release/Debug"
if self.info.settings.os == "Android":
del self.info.options.android_sdk
for status in self._module_statuses:
delattr(self.info.options, f"{status}_modules")

def build_requirements(self):
if self._settings_build.os == "Windows" and is_msvc(self):
Expand Down Expand Up @@ -931,7 +946,7 @@
filecontents += 'set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_GADGET_EXPORT" "Q_NAMESPACE" "Q_NAMESPACE_EXPORT")\n'
save(self, os.path.join(self.package_folder, self._cmake_core_extras_file), filecontents)

def _create_private_module(module, dependencies=[]):

Check warning on line 949 in recipes/qt/5.x.x/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Dangerous default value [] as argument
if "Core" not in dependencies:
dependencies.append("Core")
dependencies_string = ';'.join(f'Qt5::{dependency}' for dependency in dependencies)
Expand Down Expand Up @@ -1000,7 +1015,7 @@
reqs.append(corrected_req)
return reqs

def _create_module(module, requires=[], has_include_dir=True):

Check warning on line 1018 in recipes/qt/5.x.x/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Dangerous default value [] as argument
componentname = f"qt{module}"
assert componentname not in self.cpp_info.components, f"Module {module} already present in self.cpp_info.components"
self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt5::{module}")
Expand Down
42 changes: 28 additions & 14 deletions recipes/qt/6.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from conan.tools.gnu import PkgConfigDeps
from conan.tools.microsoft import msvc_runtime_flag, is_msvc
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
from conan.errors import ConanException, ConanInvalidConfiguration

required_conan_version = ">=1.55.0"

Expand All @@ -28,6 +28,8 @@ class QtConan(ConanFile):
"qtspeech", "qthttpserver", "qtquick3dphysics", "qtgrpc", "qtquickeffectmaker"]
_submodules += ["qtgraphs"] # new modules for qt 6.6.0

_module_statuses = ["essential", "addon", "deprecated", "preview"]

name = "qt"
description = "Qt is a cross-platform framework for graphical user interfaces."
topics = ("framework", "ui")
Expand Down Expand Up @@ -76,6 +78,7 @@ class QtConan(ConanFile):
"disabled_features": [None, "ANY"],
}
options.update({module: [True, False] for module in _submodules})
options.update({f"{status}_modules": [True, False] for status in _module_statuses})

# this significantly speeds up windows builds
no_copy_source = True
Expand Down Expand Up @@ -118,7 +121,9 @@ class QtConan(ConanFile):
"sysroot": None,
"multiconfiguration": False,
"disabled_features": "",
"essential_modules": not os.getenv('CONAN_CENTER_BUILD_SERVICE')
}
default_options.update({f"{status}_modules": False for status in _module_statuses if status != "essential"})

short_paths = True

Expand All @@ -145,6 +150,8 @@ def _get_module_tree(self):
continue
status = str(config.get(section, "status"))
if status not in ["obsolete", "ignore", "additionalLibrary"]:
if status not in self._module_statuses:
raise ConanException(f"module {modulename} has status {status} which is not in self._module_statuses {self._module_statuses}")
assert modulename in self._submodules, f"module {modulename} not in self._submodules"
self._submodules_tree[modulename] = {"status": status,
"path": str(config.get(section, "path")), "depends": []}
Expand Down Expand Up @@ -202,16 +209,6 @@ def configure(self):
self.options.rm_safe("with_x11")
self.options.rm_safe("with_egl")

if not self.options.get_safe("qtmultimedia"):
self.options.rm_safe("with_libalsa")
del self.options.with_openal
del self.options.with_gstreamer
del self.options.with_pulseaudio

if self.settings.os in ("FreeBSD", "Linux"):
if self.options.get_safe("qtwebengine"):
self.options.with_fontconfig = True

if self.options.multiconfiguration:
del self.settings.build_type

Expand All @@ -223,9 +220,14 @@ def _enablemodule(mod):

# enable all modules which are
# - required by a module explicitely enabled by the consumer
for module in self._get_module_tree:
if getattr(self.options, module):
_enablemodule(module)
for module_name, module in self._get_module_tree.items():
if getattr(self.options, module_name):
_enablemodule(module_name)
else:
for status in self._module_statuses:
if getattr(self.options, f"{status}_modules") and module['status'] == status:
_enablemodule(module_name)
break

# disable all modules which are:
# - not explicitely enabled by the consumer and
Expand All @@ -234,6 +236,16 @@ def _enablemodule(mod):
if getattr(self.options, module).value is None:
setattr(self.options, module, False)

if not self.options.get_safe("qtmultimedia"):
self.options.rm_safe("with_libalsa")
del self.options.with_openal
del self.options.with_gstreamer
del self.options.with_pulseaudio

if self.settings.os in ("FreeBSD", "Linux"):
if self.options.get_safe("qtwebengine"):
self.options.with_fontconfig = True

def validate(self):
if os.getenv('CONAN_CENTER_BUILD_SERVICE') is not None:
if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) >= "11" or \
Expand Down Expand Up @@ -634,6 +646,8 @@ def package_id(self):
self.info.settings.compiler.runtime_type = "Release/Debug"
if self.info.settings.os == "Android":
del self.info.options.android_sdk
for status in self._module_statuses:
delattr(self.info.options, f"{status}_modules")

def source(self):
destination = self.source_folder
Expand Down
Loading