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

libdecor: Add recipe #22387

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
82f14ab
libdecor: Add recipe
jwillikers Jan 16, 2024
2261c07
Update for fixed Pango package
jwillikers Jan 17, 2024
8c6cf3c
Fix typo
jwillikers Jan 31, 2024
025268a
Use def instead of lambda
jwillikers Feb 27, 2024
6184bc5
Bump Meson
jwillikers Feb 27, 2024
9b86c11
Bump Wayland Protocols
jwillikers Feb 27, 2024
f2b08da
Patch to build statically and use wayland-protocols like xkbcommon
jwillikers Mar 4, 2024
9dcc395
Fix test package
jwillikers Mar 4, 2024
008ca6f
Add patch source
jwillikers Mar 4, 2024
59144c6
Remove extra blank line
jwillikers Mar 4, 2024
8a9ea3f
Merge branch 'master' into libdecor
jwillikers Mar 22, 2024
ed5eb39
Merge branch 'master' into libdecor
jwillikers Mar 22, 2024
d5fea0f
Merge branch 'master' into libdecor
jwillikers Apr 1, 2024
883f997
Merge branch 'master' into libdecor
jwillikers Apr 11, 2024
3e55b9b
Merge branch 'master' into libdecor
jwillikers Apr 17, 2024
d39b720
Merge branch 'master' into libdecor
jwillikers Apr 17, 2024
8c35eb1
Merge branch 'master' into libdecor
jwillikers Apr 22, 2024
3e231a9
Merge branch 'master' into libdecor
jwillikers May 6, 2024
b4f7e5b
Default with_gtk option to false for old Gtk in CCI
jwillikers May 6, 2024
5d29776
Update recipes/libdecor/all/test_package/meson.build
jwillikers May 7, 2024
f5d37bb
Update recipes/libdecor/all/conanfile.py
jwillikers May 7, 2024
45fb68b
Bump dependencies
jwillikers May 7, 2024
fc7c136
Use dependencies.build
jwillikers May 7, 2024
70c2c17
Use version 3 of GTK and re-enable with_gtk as the default
jwillikers May 8, 2024
00ac9a7
Default the with_gtk option to false for CCI
jwillikers Jul 11, 2024
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
10 changes: 10 additions & 0 deletions recipes/libdecor/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sources:
"0.2.2":
url: "https://gitlab.freedesktop.org/libdecor/libdecor/-/releases/0.2.2/downloads/libdecor-0.2.2.tar.xz"
sha256: "16a288e24354d461b20dda9cf38e68543569134f04e4b7fa2914aa647907dfac"
patches:
"0.2.2":
- patch_file: "patches/0.2.2-0001-Rename-os_create_anonymous_file-to-avoid-a-conflict-.patch"
patch_description: "Rename os_create_anonymous_file to avoid a conflict in wayland-cursor"
patch_type: "portability"
patch_source: "https://gitlab.freedesktop.org/libdecor/libdecor/-/merge_requests/146"
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
137 changes: 137 additions & 0 deletions recipes/libdecor/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import os
import textwrap

from conan import ConanFile
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir, save
from conan.tools.gnu import PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson, MesonToolchain
from conan.errors import ConanInvalidConfiguration

required_conan_version = ">=1.53.0"


class libdecorConan(ConanFile):
name = "libdecor"
package_type = "shared-library"
description = "libdecor is a library that can help Wayland clients draw window decorations for them."
topics = ("decoration", "wayland", "window")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://gitlab.freedesktop.org/libdecor/libdecor"
license = "MIT"
settings = "os", "arch", "compiler", "build_type"
options = {
"with_dbus": [True, False],
"with_gtk": [True, False],
}
default_options = {
"with_dbus": True,
"with_gtk": False,
}

@property
def _has_build_profile(self):
return hasattr(self, "settings_build")

def export_sources(self):
export_conandata_patches(self)

def configure(self):
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
self.options["pango"].with_cairo = True

def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("cairo/1.18.0")
if self.options.get_safe("with_dbus"):
self.requires("dbus/1.15.8")
if self.options.get_safe("with_gtk"):
self.requires("gtk/system")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a non-system version?

Copy link
Contributor Author

@jwillikers jwillikers May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think those are maintained, are they? I tried using those ones first but ran into a lot of problems.

# Linking the test package results in missing freetype sympols without this.
jwillikers marked this conversation as resolved.
Show resolved Hide resolved
# It appears that this is due to an issue with a dependency such as pango or cairo pulling in the system freetype instead of Conan's.
# Or potentially, it's related to an incorrectly specified dependency.
self.requires("pango/1.51.0", transitive_libs=True)
self.requires("wayland/1.22.0", transitive_headers=True)

def validate(self):
if self.settings.os != "Linux":
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
raise ConanInvalidConfiguration(f"{self.ref} only supports Linux")
if not self.dependencies["pango"].options.with_cairo:
raise ConanInvalidConfiguration(f"{self.ref} requires the with_cairo option of pango to be enabled")

def build_requirements(self):
self.tool_requires("meson/1.3.2")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/2.1.0")
self.tool_requires("wayland/<host_version>")
self.tool_requires("wayland-protocols/1.33")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def _patch_sources(self):
apply_conandata_patches(self)
replace_in_file(
self,
os.path.join(self.source_folder, "src", "plugins", "meson.build"),
"gtk_dep = dependency('gtk+-3.0', required: get_option('gtk'))",
"gtk_dep = dependency('gtk', required: get_option('gtk'))",
)

def generate(self):
def feature(option):
return "enabled" if self.options.get_safe(option) else "disabled"

tc = MesonToolchain(self)
tc.project_options["dbus"] = feature("with_dbus")
tc.project_options["demo"] = False
tc.project_options["gtk"] = feature("with_gtk")
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
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
# 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()
virtual_build_env = VirtualBuildEnv(self)
virtual_build_env.generate()

def build(self):
self._patch_sources()
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):
libdecor_soversion = "0"
self.cpp_info.libs = [f"decor-{libdecor_soversion}"]
self.cpp_info.set_property("pkg_config_name", f"libdecor-{libdecor_soversion}")

self.cpp_info.includedirs = [os.path.join(self.package_folder, "include", f"libdecor-{libdecor_soversion}")]

plugins_soversion = "1"
self.runenv_info.define("LIBDECOR_PLUGIN_DIR", os.path.join(self.package_folder, "lib", "libdecor", f"plugins-{plugins_soversion}"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
From 64638f1affc4fcff1ca07e6544101b7beeecd563 Mon Sep 17 00:00:00 2001
From: Jordan Williams <jordan@jwillikers.com>
Date: Mon, 4 Mar 2024 07:01:04 -0600
Subject: [PATCH] Rename os_create_anonymous_file to avoid a conflict in
wayland-cursor

Fixes #66.
---
demo/c++-demo.cc | 2 +-
demo/demo.c | 2 +-
src/os-compatibility.c | 2 +-
src/os-compatibility.h | 2 +-
src/plugins/cairo/libdecor-cairo.c | 2 +-
src/plugins/gtk/libdecor-gtk.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/demo/c++-demo.cc b/demo/c++-demo.cc
index 72f63db..1a29ec7 100644
--- a/demo/c++-demo.cc
+++ b/demo/c++-demo.cc
@@ -94,7 +94,7 @@ public:
stride = width * 4;
size = stride * height;

- fd = os_create_anonymous_file(size);
+ fd = libdecor_os_create_anonymous_file(size);
if (fd < 0) {
cerr << "Creating a buffer file for " << size <<
" B failed: " << strerror(errno) << endl;
diff --git a/demo/demo.c b/demo/demo.c
index c347845..a736a46 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -1026,7 +1026,7 @@ create_shm_buffer(int width,
stride = width * 4;
size = stride * height;

- fd = os_create_anonymous_file(size);
+ fd = libdecor_os_create_anonymous_file(size);
if (fd < 0) {
fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
size, strerror(errno));
diff --git a/src/os-compatibility.c b/src/os-compatibility.c
index 8287da0..2376647 100644
--- a/src/os-compatibility.c
+++ b/src/os-compatibility.c
@@ -148,7 +148,7 @@ os_resize_anonymous_file(int fd, off_t size)
* XDG_RUNTIME_DIR.
*/
int
-os_create_anonymous_file(off_t size)
+libdecor_os_create_anonymous_file(off_t size)
{
static const char template[] = "/libdecor-shared-XXXXXX";
const char *path;
diff --git a/src/os-compatibility.h b/src/os-compatibility.h
index d0e69ac..6ce49d0 100644
--- a/src/os-compatibility.h
+++ b/src/os-compatibility.h
@@ -29,6 +29,6 @@
#include <sys/types.h>

int
-os_create_anonymous_file(off_t size);
+libdecor_os_create_anonymous_file(off_t size);

#endif /* OS_COMPATIBILITY_H */
diff --git a/src/plugins/cairo/libdecor-cairo.c b/src/plugins/cairo/libdecor-cairo.c
index 765800d..30f6f87 100644
--- a/src/plugins/cairo/libdecor-cairo.c
+++ b/src/plugins/cairo/libdecor-cairo.c
@@ -597,7 +597,7 @@ create_shm_buffer(struct libdecor_plugin_cairo *plugin_cairo,
stride = buffer_width * 4;
size = stride * buffer_height;

- fd = os_create_anonymous_file(size);
+ fd = libdecor_os_create_anonymous_file(size);
if (fd < 0) {
fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
size, strerror(errno));
diff --git a/src/plugins/gtk/libdecor-gtk.c b/src/plugins/gtk/libdecor-gtk.c
index ef638f1..8655d45 100644
--- a/src/plugins/gtk/libdecor-gtk.c
+++ b/src/plugins/gtk/libdecor-gtk.c
@@ -595,7 +595,7 @@ create_shm_buffer(struct libdecor_plugin_gtk *plugin_gtk,
stride = buffer_width * 4;
size = stride * buffer_height;

- fd = os_create_anonymous_file(size);
+ fd = libdecor_os_create_anonymous_file(size);
if (fd < 0) {
fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
size, strerror(errno));
--
2.44.0

32 changes: 32 additions & 0 deletions recipes/libdecor/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "PkgConfigDeps", "MesonToolchain", "VirtualRunEnv", "VirtualBuildEnv"
test_type = "explicit"

def layout(self):
basic_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build_requirements(self):
self.tool_requires("meson/1.3.2")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/2.1.0")

def build(self):
meson = Meson(self)
meson.configure()
meson.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
14 changes: 14 additions & 0 deletions recipes/libdecor/all/test_package/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
project('test_package', 'c')

libdecor_dep = dependency('libdecor-0')

executable('test_package',
sources: [
'test_package.c',
],
dependencies: [
libdecor_dep,
],
jwillikers marked this conversation as resolved.
Show resolved Hide resolved
)


11 changes: 11 additions & 0 deletions recipes/libdecor/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdlib.h>
#include <libdecor.h>

int main(int argc, char **argv) {
struct libdecor_state *state = libdecor_state_new(0, 0);
if (!state) {
return EXIT_FAILURE;
}
libdecor_state_free(state);
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/libdecor/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.2.2":
folder: all
Loading