Skip to content

Commit

Permalink
(conan-io#23301) libinput: Make wayland-protocols a build dependency
Browse files Browse the repository at this point in the history
This aligns with how wayland-protocols is handled in every other package.
  • Loading branch information
jwillikers authored Apr 2, 2024
1 parent 0a5a86d commit 0f00c5f
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions recipes/libinput/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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
from conan.tools.files import copy, 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
import os


required_conan_version = ">=1.53.0"
Expand Down Expand Up @@ -38,6 +40,10 @@ class LibinputConan(ConanFile):
"with_x11": True,
}

@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")
Expand All @@ -58,7 +64,6 @@ def requirements(self):
self.requires("gtk/system")
if self.options.with_wayland:
self.requires("wayland/1.22.0")
self.requires("wayland-protocols/1.33")
if self.options.with_x11:
self.requires("xorg/system")

Expand All @@ -77,14 +82,17 @@ 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")
if self.options.debug_gui and self.options.get_safe("with_wayland"):
self.tool_requires("wayland/<host_version>")
if self.options.get_safe("with_wayland"):
if self._has_build_profile:
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 generate(self):
tc = MesonToolchain(self)
tc.project_options["build.pkg_config_path"] = self.generators_folder
tc.project_options["coverity"] = False
tc.project_options["datadir"] = "res"
tc.project_options["documentation"] = False
Expand All @@ -96,8 +104,27 @@ def generate(self):
tc.project_options["libwacom"] = self.options.with_libwacom
tc.project_options["tests"] = False
tc.generate()
tc = PkgConfigDeps(self)
tc.generate()
pkg_config_deps = PkgConfigDeps(self)
if self.options.get_safe("with_wayland"):
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()
tc = VirtualBuildEnv(self)
tc.generate()

Expand Down

0 comments on commit 0f00c5f

Please sign in to comment.