Skip to content

Commit

Permalink
Convert qt extension to separate versioned extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred Wilson committed Sep 15, 2023
1 parent 23e4e96 commit a4c401f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion snapcraft/extensions/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def apply_extensions(
for extension_name in sorted(declared_extensions.keys()):
extension_class = get_extension_class(extension_name)
extension = extension_class(
yaml_data=copy.deepcopy(yaml_data), arch=arch, target_arch=target_arch
name=extension_name, yaml_data=copy.deepcopy(yaml_data), arch=arch, target_arch=target_arch
)
extension.validate(extension_name=extension_name)
_apply_extension(yaml_data, declared_extensions[extension_name], extension)
Expand Down
3 changes: 2 additions & 1 deletion snapcraft/extensions/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ class Extension(abc.ABC):
"""

def __init__(
self, *, yaml_data: Dict[str, Any], arch: str, target_arch: str
self, *, name: str, yaml_data: Dict[str, Any], arch: str, target_arch: str
) -> None:
"""Create a new Extension."""
self.name = name
self.yaml_data = yaml_data
self.arch = arch
self.target_arch = target_arch
Expand Down
23 changes: 11 additions & 12 deletions snapcraft/extensions/qt_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@

_SDK_SNAP = {"core22": "qt-framework-sdk"}

_CONTENT_SNAP = {
"qt6-5": {"core22": "qt-framework-6-5-core22"},
"qt6-4": {"core22": "qt-framework-6-4-core22"},
"qt6-2": {"core22": "qt-framework-6-2-core22"},
"qt5-15": {"core22": "qt-framework-5-15-core22"},
}

@dataclasses.dataclass
class ExtensionInfo:
Expand Down Expand Up @@ -86,7 +92,7 @@ def get_app_snippet(self) -> Dict[str, Any]:
"command-chain": ["snap/command-chain/desktop-launch"],
"plugs": ["desktop", "desktop-legacy", "opengl", "wayland", "x11"],
"environment": {
"QT_PLUGIN_PATH": "$SNAP/qt-framework/opt/qt5-15/plugins:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/plugins",
"QT_PLUGIN_PATH": "$SNAP/qt-framework/usr/plugins:$SNAP/usr/lib/plugins",
},
}

Expand All @@ -108,23 +114,16 @@ def qt_snaps(self) -> QTSnaps:
break

# The same except the trailing -sd
content = sdk_snap[:-4]
content = _CONTENT_SNAP[self.name][base]

return QTSnaps(sdk=sdk_snap, content=content, builtin=builtin)

@functools.cached_property
def ext_info(self) -> ExtensionInfo:
"""Return the extension info cmake_args, provider, content, build_snaps."""
prefix_root = f"/snap/{self.qt_snaps.sdk}/current/opt"
versions = ["qt6-5", "qt6-4", "qt6-2", "qt5-15"]
prefix_path = "-DCMAKE_PREFIX_PATH="

for version in versions:
prefix_path += f"{prefix_root}/{version}"

cmake_args = [
f"-DCMAKE_FIND_ROOT_PATH=/snap/{self.qt_snaps.sdk}/current",
prefix_path,
f"-DCMAKE_PREFIX_PATH=/snap/{self.qt_snaps.sdk}/current/usr"
"-DZLIB_INCLUDE_DIR=/lib/x86_64-linux-gnu",
]

Expand Down Expand Up @@ -203,7 +202,7 @@ def get_parts_snippet(self) -> Dict[str, Any]:

if self.qt_snaps.builtin:
return {
"qt-framework/sdk": {
f"{self.name}/sdk": {
"source": str(source),
"plugin": "make",
"make-parameters": [f"PLATFORM_PLUG={self.qt_snaps.content}"],
Expand All @@ -212,7 +211,7 @@ def get_parts_snippet(self) -> Dict[str, Any]:
}

return {
"qt-framework/sdk": {
f"{self.name}/sdk": {
"source": str(source),
"plugin": "make",
"make-parameters": [f"PLATFORM_PLUG={self.qt_snaps.content}"],
Expand Down
5 changes: 4 additions & 1 deletion snapcraft/extensions/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
"gnome": GNOME,
"ros2-humble": ROS2HumbleExtension,
"kde-neon": KDENeon,
"qt-framework": QTFramework,
"qt6-5": None,
"qt6-4": None,
"qt6-2": None,
"qt5-15": QTFramework,
}


Expand Down

0 comments on commit a4c401f

Please sign in to comment.