Skip to content

Commit

Permalink
(#23171) qt: add options to enable several modules at once
Browse files Browse the repository at this point in the history
* add options to enable several modules

essentials, addons, deprecated and preview

* qt5: remove unused patch

cleanup after fca4d56

* set default options

* ony enable once each module
  • Loading branch information
ericLemanissier authored Apr 6, 2024
1 parent 44d1576 commit 2f8bc17
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 26 deletions.
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 @@ class QtConan(ConanFile):
"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 @@ class QtConan(ConanFile):
"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 @@ class QtConan(ConanFile):
"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 @@ def configure(self):
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 @@ def configure(self):
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 @@ def _enablemodule(mod):
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 @@ 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 build_requirements(self):
if self._settings_build.os == "Windows" and is_msvc(self):
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

0 comments on commit 2f8bc17

Please sign in to comment.