From acc4d02fb45dcd60cf744b9768f9789db6dfd947 Mon Sep 17 00:00:00 2001 From: Scarlett Moore Date: Fri, 19 May 2023 10:02:48 -0700 Subject: [PATCH 01/11] Plugins: Enable qmake for core22 --- snapcraft/parts/plugins/__init__.py | 2 + snapcraft/parts/plugins/qmake.py | 99 +++++++++++++++++++ snapcraft/parts/plugins/register.py | 2 + .../build-and-run-hello/qmake-hello/hello.c | 7 ++ .../build-and-run-hello/qmake-hello/hello.pro | 4 + .../qmake-hello/snap/snapcraft.yaml | 22 +++++ .../craft-parts/build-and-run-hello/task.yaml | 1 + 7 files changed, 137 insertions(+) create mode 100644 snapcraft/parts/plugins/qmake.py create mode 100644 tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/hello.c create mode 100644 tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/hello.pro create mode 100644 tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/snap/snapcraft.yaml diff --git a/snapcraft/parts/plugins/__init__.py b/snapcraft/parts/plugins/__init__.py index 81fbcd66a3..08a76a1165 100644 --- a/snapcraft/parts/plugins/__init__.py +++ b/snapcraft/parts/plugins/__init__.py @@ -23,6 +23,7 @@ from .kernel import KernelPlugin from .python_plugin import PythonPlugin from .register import register +from .qmake import QmakePlugin __all__ = [ "ColconPlugin", @@ -31,4 +32,5 @@ "KernelPlugin", "PythonPlugin", "register", + "QmakePlugin" ] diff --git a/snapcraft/parts/plugins/qmake.py b/snapcraft/parts/plugins/qmake.py new file mode 100644 index 0000000000..ec2fc9ce9b --- /dev/null +++ b/snapcraft/parts/plugins/qmake.py @@ -0,0 +1,99 @@ +# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- +# +# Copyright (C) 2020 Canonical Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +"""The qmake plugin is useful for building qmake-based parts. + +These are projects that are built using .pro files. + +This plugin uses the common plugin keywords as well as those for "sources". +For more information check the 'plugins' topic for the former and the +'sources' topic for the latter. + +Additionally, this plugin uses the following plugin-specific keywords: + + - qmake-parameters: + (list of strings) + additional options to pass to the qmake invocation. + + - qmake-project-file: + (string) + the qmake project file to use. This is usually only needed if + qmake can not determine what project file to use on its own. +""" + +from typing import Any, Dict, List, Set + +from craft_parts import plugins + + +class QMakePlugin(qmake.QmakePlugin): + @classmethod + def get_schema(cls) -> Dict[str, Any]: + return { + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "additionalProperties": False, + "properties": { + "qmake-parameters": { + "type": "array", + "uniqueItems": True, + "items": {"type": "string"}, + "default": [], + }, + "qmake-project-file": {"type": "string", "default": ""}, + }, + } + + def get_build_snaps(self) -> Set[str]: + return set() + + def get_build_packages(self) -> Set[str]: + return {"g++", "make", "qt5-qmake"} + + def get_build_environment(self) -> Dict[str, str]: + return {"QT_SELECT": "qt5"} + + @property + def out_of_source_build(self): + return True + + def _get_qmake_configure_command(self) -> str: + cmd = [ + "qmake", + 'QMAKE_CFLAGS+="${CFLAGS:-}"', + 'QMAKE_CXXFLAGS+="${CXXFLAGS:-}"', + 'QMAKE_LFLAGS+="${LDFLAGS:-}"', + ] + self.options.qmake_parameters + + if self.options.qmake_project_file: + cmd.append( + '"${{CRAFT_PART_SRC_WORK}}/{}"'.format( + self.options.qmake_project_file + ) + ) + else: + cmd.append('"${CRAFT_PART_SRC_WORK}"') + + return " ".join(cmd) + + def get_build_commands(self) -> List[str]: + return [ + self._get_qmake_configure_command(), + # Avoid overriding the CFLAGS and CXXFLAGS environment + # variables qmake sets in the generated Makefile + 'env -u CFLAGS -u CXXFLAGS make -j"${CRAFT_PARALLEL_BUILD_COUNT}"', + 'make install INSTALL_ROOT="${CRAFT_PART_INSTALL}"', + ] diff --git a/snapcraft/parts/plugins/register.py b/snapcraft/parts/plugins/register.py index 1ed240ed15..3b81c7b53c 100644 --- a/snapcraft/parts/plugins/register.py +++ b/snapcraft/parts/plugins/register.py @@ -23,6 +23,7 @@ from .flutter_plugin import FlutterPlugin from .kernel import KernelPlugin from .python_plugin import PythonPlugin +from .qmake import QmakePlugin def register() -> None: @@ -32,3 +33,4 @@ def register() -> None: craft_parts.plugins.register({"flutter": FlutterPlugin}) craft_parts.plugins.register({"python": PythonPlugin}) craft_parts.plugins.register({"kernel": KernelPlugin}) + craft_parts.plugins.register({"qmake": QmakePlugin}) diff --git a/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/hello.c b/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/hello.c new file mode 100644 index 0000000000..7ac070b52c --- /dev/null +++ b/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/hello.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + printf("hello world\n"); + return 0; +} diff --git a/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/hello.pro b/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/hello.pro new file mode 100644 index 0000000000..1dc9da55e0 --- /dev/null +++ b/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/hello.pro @@ -0,0 +1,4 @@ +CONFIG = console release +SOURCES += hello.c +target.path = /bin/ +INSTALLS += target diff --git a/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/snap/snapcraft.yaml b/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/snap/snapcraft.yaml new file mode 100644 index 0000000000..937a509832 --- /dev/null +++ b/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/snap/snapcraft.yaml @@ -0,0 +1,22 @@ +name: qmake-hello +version: "1.0" +summary: test the qmake plugin +description: | + This is a basic qmake snap. It just prints a hello world. + If you want to add other functionalities to this snap, please don't. + Make a new one. + +grade: devel +base: core20 +confinement: strict + +apps: + qmake-hello: + command: bin/hello + +parts: + hello: + plugin: qmake + qmake-parameters: + - -Wall + source: . diff --git a/tests/spread/plugins/craft-parts/build-and-run-hello/task.yaml b/tests/spread/plugins/craft-parts/build-and-run-hello/task.yaml index 7769e0ed98..74f4c57e86 100644 --- a/tests/spread/plugins/craft-parts/build-and-run-hello/task.yaml +++ b/tests/spread/plugins/craft-parts/build-and-run-hello/task.yaml @@ -8,6 +8,7 @@ environment: SNAP/colcon_ros2_wrapper: colcon-ros2-wrapper SNAP/flutter: flutter-hello SNAP/python: python-hello + SNAP/qmake: qmake-hello prepare: | #shellcheck source=tests/spread/tools/snapcraft-yaml.sh From bfa37ac1da1548a7fdbd40be9be52ae257abdad6 Mon Sep 17 00:00:00 2001 From: Scarlett Gately Moore Date: Mon, 22 May 2023 06:15:07 -0700 Subject: [PATCH 02/11] Update tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/snap/snapcraft.yaml Co-authored-by: Alex Lowe --- .../build-and-run-hello/qmake-hello/snap/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/snap/snapcraft.yaml b/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/snap/snapcraft.yaml index 937a509832..5843ceb255 100644 --- a/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/snap/snapcraft.yaml +++ b/tests/spread/plugins/craft-parts/build-and-run-hello/qmake-hello/snap/snapcraft.yaml @@ -7,7 +7,7 @@ description: | Make a new one. grade: devel -base: core20 +base: core22 confinement: strict apps: From a173e08fb53cb2fd56147c07db5b0af6085709d3 Mon Sep 17 00:00:00 2001 From: Scarlett Gately Moore Date: Mon, 22 May 2023 06:15:35 -0700 Subject: [PATCH 03/11] Update snapcraft/parts/plugins/qmake.py Co-authored-by: Alex Lowe --- snapcraft/parts/plugins/qmake.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snapcraft/parts/plugins/qmake.py b/snapcraft/parts/plugins/qmake.py index ec2fc9ce9b..1f34e3bde2 100644 --- a/snapcraft/parts/plugins/qmake.py +++ b/snapcraft/parts/plugins/qmake.py @@ -39,7 +39,9 @@ from craft_parts import plugins -class QMakePlugin(qmake.QmakePlugin): +class QMakePlugin(plugins.Plugin): + + properties_class = QMakePluginProperties @classmethod def get_schema(cls) -> Dict[str, Any]: return { From 1eb710cee92b7e3ce66e87f1e1ad50dd84cc75eb Mon Sep 17 00:00:00 2001 From: Scarlett Gately Moore Date: Mon, 22 May 2023 06:15:48 -0700 Subject: [PATCH 04/11] Update snapcraft/parts/plugins/qmake.py Co-authored-by: Alex Lowe --- snapcraft/parts/plugins/qmake.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/snapcraft/parts/plugins/qmake.py b/snapcraft/parts/plugins/qmake.py index 1f34e3bde2..0c442b36ca 100644 --- a/snapcraft/parts/plugins/qmake.py +++ b/snapcraft/parts/plugins/qmake.py @@ -42,22 +42,6 @@ class QMakePlugin(plugins.Plugin): properties_class = QMakePluginProperties - @classmethod - def get_schema(cls) -> Dict[str, Any]: - return { - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "additionalProperties": False, - "properties": { - "qmake-parameters": { - "type": "array", - "uniqueItems": True, - "items": {"type": "string"}, - "default": [], - }, - "qmake-project-file": {"type": "string", "default": ""}, - }, - } def get_build_snaps(self) -> Set[str]: return set() From 0ab21d1e1bdefe7639dd91d1461448f5f66bc504 Mon Sep 17 00:00:00 2001 From: Scarlett Gately Moore Date: Mon, 22 May 2023 06:16:00 -0700 Subject: [PATCH 05/11] Update snapcraft/parts/plugins/qmake.py Co-authored-by: Alex Lowe --- snapcraft/parts/plugins/qmake.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snapcraft/parts/plugins/qmake.py b/snapcraft/parts/plugins/qmake.py index 0c442b36ca..c39445f02c 100644 --- a/snapcraft/parts/plugins/qmake.py +++ b/snapcraft/parts/plugins/qmake.py @@ -80,6 +80,6 @@ def get_build_commands(self) -> List[str]: self._get_qmake_configure_command(), # Avoid overriding the CFLAGS and CXXFLAGS environment # variables qmake sets in the generated Makefile - 'env -u CFLAGS -u CXXFLAGS make -j"${CRAFT_PARALLEL_BUILD_COUNT}"', - 'make install INSTALL_ROOT="${CRAFT_PART_INSTALL}"', + f'env -u CFLAGS -u CXXFLAGS make "-j{self._part_info.parallel_build_count}"', + f'make install INSTALL_ROOT="{self._part_info.part_install_dir}"', ] From 41f682d0382d8d8096ba094a00e9f27385bf0450 Mon Sep 17 00:00:00 2001 From: Scarlett Gately Moore Date: Mon, 22 May 2023 06:16:11 -0700 Subject: [PATCH 06/11] Update snapcraft/parts/plugins/qmake.py Co-authored-by: Alex Lowe --- snapcraft/parts/plugins/qmake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snapcraft/parts/plugins/qmake.py b/snapcraft/parts/plugins/qmake.py index c39445f02c..d803e0afee 100644 --- a/snapcraft/parts/plugins/qmake.py +++ b/snapcraft/parts/plugins/qmake.py @@ -62,7 +62,7 @@ def _get_qmake_configure_command(self) -> str: 'QMAKE_CFLAGS+="${CFLAGS:-}"', 'QMAKE_CXXFLAGS+="${CXXFLAGS:-}"', 'QMAKE_LFLAGS+="${LDFLAGS:-}"', - ] + self.options.qmake_parameters + ] + self._options.qmake_parameters if self.options.qmake_project_file: cmd.append( From 747f2a6a9d566c36fa4ac0cea951d626391caa33 Mon Sep 17 00:00:00 2001 From: Scarlett Gately Moore Date: Mon, 22 May 2023 06:16:24 -0700 Subject: [PATCH 07/11] Update snapcraft/parts/plugins/qmake.py Co-authored-by: Alex Lowe --- snapcraft/parts/plugins/qmake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snapcraft/parts/plugins/qmake.py b/snapcraft/parts/plugins/qmake.py index d803e0afee..9a8da62092 100644 --- a/snapcraft/parts/plugins/qmake.py +++ b/snapcraft/parts/plugins/qmake.py @@ -64,7 +64,7 @@ def _get_qmake_configure_command(self) -> str: 'QMAKE_LFLAGS+="${LDFLAGS:-}"', ] + self._options.qmake_parameters - if self.options.qmake_project_file: + if self._options.qmake_project_file: cmd.append( '"${{CRAFT_PART_SRC_WORK}}/{}"'.format( self.options.qmake_project_file From e7517454f76f039b1a9ac72fdc09b7c4c5e8cf4c Mon Sep 17 00:00:00 2001 From: Scarlett Gately Moore Date: Mon, 22 May 2023 06:16:35 -0700 Subject: [PATCH 08/11] Update snapcraft/parts/plugins/qmake.py Co-authored-by: Alex Lowe --- snapcraft/parts/plugins/qmake.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/snapcraft/parts/plugins/qmake.py b/snapcraft/parts/plugins/qmake.py index 9a8da62092..f1384be5f4 100644 --- a/snapcraft/parts/plugins/qmake.py +++ b/snapcraft/parts/plugins/qmake.py @@ -66,9 +66,7 @@ def _get_qmake_configure_command(self) -> str: if self._options.qmake_project_file: cmd.append( - '"${{CRAFT_PART_SRC_WORK}}/{}"'.format( - self.options.qmake_project_file - ) + f'"{self._part_info.part_src_dir}/{self._options.qmake_project_file}"' ) else: cmd.append('"${CRAFT_PART_SRC_WORK}"') From 466e74b56f86cbc38696711f4545ee24b142d76b Mon Sep 17 00:00:00 2001 From: Scarlett Gately Moore Date: Mon, 22 May 2023 06:16:45 -0700 Subject: [PATCH 09/11] Update snapcraft/parts/plugins/qmake.py Co-authored-by: Alex Lowe --- snapcraft/parts/plugins/qmake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snapcraft/parts/plugins/qmake.py b/snapcraft/parts/plugins/qmake.py index f1384be5f4..ebe0339e8d 100644 --- a/snapcraft/parts/plugins/qmake.py +++ b/snapcraft/parts/plugins/qmake.py @@ -69,7 +69,7 @@ def _get_qmake_configure_command(self) -> str: f'"{self._part_info.part_src_dir}/{self._options.qmake_project_file}"' ) else: - cmd.append('"${CRAFT_PART_SRC_WORK}"') + cmd.append(self._part_info.part_build_dir) return " ".join(cmd) From da7f19a1968109c236cea72c97ce1b76c0858915 Mon Sep 17 00:00:00 2001 From: Scarlett Moore Date: Wed, 24 May 2023 10:20:15 -0700 Subject: [PATCH 10/11] Remove qmake plugin as it is now in craft-parts. --- snapcraft/parts/plugins/__init__.py | 2 - snapcraft/parts/plugins/qmake.py | 83 ----------------------------- snapcraft/parts/plugins/register.py | 2 - 3 files changed, 87 deletions(-) delete mode 100644 snapcraft/parts/plugins/qmake.py diff --git a/snapcraft/parts/plugins/__init__.py b/snapcraft/parts/plugins/__init__.py index 08a76a1165..81fbcd66a3 100644 --- a/snapcraft/parts/plugins/__init__.py +++ b/snapcraft/parts/plugins/__init__.py @@ -23,7 +23,6 @@ from .kernel import KernelPlugin from .python_plugin import PythonPlugin from .register import register -from .qmake import QmakePlugin __all__ = [ "ColconPlugin", @@ -32,5 +31,4 @@ "KernelPlugin", "PythonPlugin", "register", - "QmakePlugin" ] diff --git a/snapcraft/parts/plugins/qmake.py b/snapcraft/parts/plugins/qmake.py deleted file mode 100644 index ebe0339e8d..0000000000 --- a/snapcraft/parts/plugins/qmake.py +++ /dev/null @@ -1,83 +0,0 @@ -# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# -# Copyright (C) 2020 Canonical Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -"""The qmake plugin is useful for building qmake-based parts. - -These are projects that are built using .pro files. - -This plugin uses the common plugin keywords as well as those for "sources". -For more information check the 'plugins' topic for the former and the -'sources' topic for the latter. - -Additionally, this plugin uses the following plugin-specific keywords: - - - qmake-parameters: - (list of strings) - additional options to pass to the qmake invocation. - - - qmake-project-file: - (string) - the qmake project file to use. This is usually only needed if - qmake can not determine what project file to use on its own. -""" - -from typing import Any, Dict, List, Set - -from craft_parts import plugins - - -class QMakePlugin(plugins.Plugin): - - properties_class = QMakePluginProperties - - def get_build_snaps(self) -> Set[str]: - return set() - - def get_build_packages(self) -> Set[str]: - return {"g++", "make", "qt5-qmake"} - - def get_build_environment(self) -> Dict[str, str]: - return {"QT_SELECT": "qt5"} - - @property - def out_of_source_build(self): - return True - - def _get_qmake_configure_command(self) -> str: - cmd = [ - "qmake", - 'QMAKE_CFLAGS+="${CFLAGS:-}"', - 'QMAKE_CXXFLAGS+="${CXXFLAGS:-}"', - 'QMAKE_LFLAGS+="${LDFLAGS:-}"', - ] + self._options.qmake_parameters - - if self._options.qmake_project_file: - cmd.append( - f'"{self._part_info.part_src_dir}/{self._options.qmake_project_file}"' - ) - else: - cmd.append(self._part_info.part_build_dir) - - return " ".join(cmd) - - def get_build_commands(self) -> List[str]: - return [ - self._get_qmake_configure_command(), - # Avoid overriding the CFLAGS and CXXFLAGS environment - # variables qmake sets in the generated Makefile - f'env -u CFLAGS -u CXXFLAGS make "-j{self._part_info.parallel_build_count}"', - f'make install INSTALL_ROOT="{self._part_info.part_install_dir}"', - ] diff --git a/snapcraft/parts/plugins/register.py b/snapcraft/parts/plugins/register.py index 3b81c7b53c..1ed240ed15 100644 --- a/snapcraft/parts/plugins/register.py +++ b/snapcraft/parts/plugins/register.py @@ -23,7 +23,6 @@ from .flutter_plugin import FlutterPlugin from .kernel import KernelPlugin from .python_plugin import PythonPlugin -from .qmake import QmakePlugin def register() -> None: @@ -33,4 +32,3 @@ def register() -> None: craft_parts.plugins.register({"flutter": FlutterPlugin}) craft_parts.plugins.register({"python": PythonPlugin}) craft_parts.plugins.register({"kernel": KernelPlugin}) - craft_parts.plugins.register({"qmake": QmakePlugin}) From d3b9e2abad365c4b88444a9c136fad850735a9aa Mon Sep 17 00:00:00 2001 From: Scarlett Moore Date: Tue, 30 May 2023 07:47:08 -0700 Subject: [PATCH 11/11] kde-neon-extension: only test core22. core18 and core20 is no longer supported. --- tests/spread/extensions/kde-neon/task.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/spread/extensions/kde-neon/task.yaml b/tests/spread/extensions/kde-neon/task.yaml index 9b69a4de5d..40b26b1142 100644 --- a/tests/spread/extensions/kde-neon/task.yaml +++ b/tests/spread/extensions/kde-neon/task.yaml @@ -4,9 +4,6 @@ summary: Build and run a basic kde snap using extensions # available on a subset of all the architectures this testbed # can run on. systems: - - ubuntu-20.04 - - ubuntu-20.04-64 - - ubuntu-20.04-amd64 - ubuntu-22.04 - ubuntu-22.04-64 - ubuntu-22.04-amd64 @@ -45,13 +42,10 @@ execute: | # Verify content snap was installed for dependency checks. snap list gtk-common-themes - if [[ "$SPREAD_SYSTEM" =~ ubuntu-20.04 ]]; then - snap list kde-frameworks-5-99-qt-5-15-7-core20 - elif [[ "$SPREAD_SYSTEM" =~ ubuntu-22.04 ]]; then + if [[ "$SPREAD_SYSTEM" =~ ubuntu-22.04 ]]; then snap list kf5-5-105-qt-5-15-9-core22 fi - # Verify all dependencies were found. if echo "$output" | grep -q "part is missing libraries"; then echo "failed to find content snaps' libraries"