From b57cdba4b18c1ba621b451edb733cb03af39154e Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 12 Oct 2023 13:46:06 -0500 Subject: [PATCH] cage: Add recipe --- recipes/cage/all/conandata.yml | 7 ++ recipes/cage/all/conanfile.py | 119 +++++++++++++++++++++ recipes/cage/all/test_package/conanfile.py | 15 +++ recipes/cage/config.yml | 3 + 4 files changed, 144 insertions(+) create mode 100644 recipes/cage/all/conandata.yml create mode 100644 recipes/cage/all/conanfile.py create mode 100644 recipes/cage/all/test_package/conanfile.py create mode 100644 recipes/cage/config.yml diff --git a/recipes/cage/all/conandata.yml b/recipes/cage/all/conandata.yml new file mode 100644 index 0000000000000..ff96271d3d2f3 --- /dev/null +++ b/recipes/cage/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "cci.20240226": + url: "https://github.com/cage-kiosk/cage/archive/e7d8780f46277af87881e0be91cb2092541bb1d5.zip" + sha256: "3f1d1a77b45188ff47c9f3f80e47fb2dd8c91b59baf0bd0112f8b932d20466b1" + # "0.1.5": + # url: "https://github.com/cage-kiosk/cage/releases/download/v0.1.5/cage-0.1.5.tar.gz" + # sha256: "ece0312e559289df0238289ea6c60e9fed32d27fe3ae8a8f83eeff26ddc239e1" diff --git a/recipes/cage/all/conanfile.py b/recipes/cage/all/conanfile.py new file mode 100644 index 0000000000000..ba76baf200eb1 --- /dev/null +++ b/recipes/cage/all/conanfile.py @@ -0,0 +1,119 @@ +import os +import textwrap + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rmdir, save +from conan.tools.gnu import PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain + +required_conan_version = ">=1.53.0" + + +class CageConan(ConanFile): + name = "cage" + description = "Cage is a kiosk compositor for Wayland." + topics = ("compositor", "display", "kiosk", "wayland") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.hjdskes.nl/projects/cage/" + license = "MIT" + package_type = "application" + settings = "os", "arch", "compiler", "build_type" + options = { + "xwayland": [True, False], + } + default_options = { + "xwayland": False, + } + + @property + def _has_build_profile(self): + return hasattr(self, "settings_build") + + def configure(self): + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + self.options["wlroots"].xwayland = self.options.xwayland + self.options["xkbcommon"].with_wayland = True + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("pixman/0.43.0") + self.requires("wayland/1.22.0") + self.requires("wlroots/0.17.1") + self.requires("xkbcommon/1.6.0") + + def validate(self): + if self.settings.os != "Linux": + raise ConanInvalidConfiguration(f"{self.ref} only supports Linux") + if self.options.xwayland and not self.dependencies["wlroots"].options.xwayland: + raise ConanInvalidConfiguration( + "The xwayland option requires the wlroots xwayland option to be enabled" + ) + + def build_requirements(self): + self.tool_requires("meson/1.3.2") + self.tool_requires("wayland/") + self.tool_requires("wayland-protocols/1.33") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/2.1.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = MesonToolchain(self) + tc.project_options["xwayland"] = "enabled" if self.options.xwayland else "disabled" + tc.project_options["man-pages"] = "disabled" + tc.generate() + pkg_config_deps = PkgConfigDeps(self) + if self._has_build_profile: + pkg_config_deps.build_context_activated = ["wayland-protocols"] + else: + # Manually generate pkgconfig file of wayland-protocols since + # PkgConfigDeps.build_context_activated can't work with legacy 1 profile + # We must use legacy conan v1 deps_cpp_info because self.dependencies doesn't + # contain build requirements when using 1 profile. + wp_prefix = self.deps_cpp_info["wayland-protocols"].rootpath + wp_version = self.deps_cpp_info["wayland-protocols"].version + wp_pkg_content = textwrap.dedent(f"""\ + prefix={wp_prefix} + datarootdir=${{prefix}}/res + pkgdatadir=${{datarootdir}}/wayland-protocols + Name: Wayland Protocols + Description: Wayland protocol files + Version: {wp_version} + """) + save( + self, + os.path.join(self.generators_folder, "wayland-protocols.pc"), + wp_pkg_content, + ) + pkg_config_deps.generate() + env = VirtualBuildEnv(self) + env.generate() + + def build(self): + meson = Meson(self) + meson.configure() + meson.build() + + def package(self): + copy( + self, + "LICENSE", + self.source_folder, + os.path.join(self.package_folder, "licenses"), + ) + meson = Meson(self) + meson.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.system_libs = ["m"] diff --git a/recipes/cage/all/test_package/conanfile.py b/recipes/cage/all/test_package/conanfile.py new file mode 100644 index 0000000000000..387bd213d77db --- /dev/null +++ b/recipes/cage/all/test_package/conanfile.py @@ -0,0 +1,15 @@ +from conan import ConanFile +from conan.tools.build import can_run + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def test(self): + if can_run(self): + self.run("cage -v", env="conanrun") diff --git a/recipes/cage/config.yml b/recipes/cage/config.yml new file mode 100644 index 0000000000000..105fbe6df4cac --- /dev/null +++ b/recipes/cage/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20240226": + folder: all