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

cage: Add recipe #20547

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions recipes/cage/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
"cci.20240226":
url: "https://github.com/cage-kiosk/cage/archive/e7d8780f46277af87881e0be91cb2092541bb1d5.zip"
sha256: "3f1d1a77b45188ff47c9f3f80e47fb2dd8c91b59baf0bd0112f8b932d20466b1"
# "0.1.5":

Check failure on line 5 in recipes/cage/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

comment not indented like content
# url: "https://github.com/cage-kiosk/cage/releases/download/v0.1.5/cage-0.1.5.tar.gz"
# sha256: "ece0312e559289df0238289ea6c60e9fed32d27fe3ae8a8f83eeff26ddc239e1"
119 changes: 119 additions & 0 deletions recipes/cage/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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/<host_version>")
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"]
15 changes: 15 additions & 0 deletions recipes/cage/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 3 additions & 0 deletions recipes/cage/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20240226":
folder: all
Loading