Repository: conan-io/conan-center-index

Issue:
wayland-protocols 1.21
Specify library name and version:  **wayland-protocols/1.21**

close #6946

- [X] I've read the [guidelines](https://github.com/conan-io/conan-center-index/blob/master/docs/how_to_add_packages.md) for contributing.
- [X] I've followed the [PEP8](https://www.python.org/dev/peps/pep-0008/) style guides for Python code in the recipes.
- [X] I've used the [latest](https://github.com/conan-io/conan/releases/latest) Conan client version.
- [X] I've tried at least one configuration locally with the
      [conan-center hook](https://github.com/conan-io/hooks.git) activated.



Discussion:

Resolving patch:
diff --git a/recipes/wayland-protocols/all/conanfile.py b/recipes/wayland-protocols/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/wayland-protocols/all/conanfile.py
@@ -0,0 +1,75 @@
+from conans import ConanFile, Meson, tools
+from conans.errors import ConanInvalidConfiguration
+import os
+
+required_conan_version = ">=1.33.0"
+
+
+class WaylandProtocolsConan(ConanFile):
+    name = "wayland-protocols"
+    description = "Wayland is a project to define a protocol for a compositor to talk to its clients as well as a library implementation of the protocol"
+    topics = ("wayland")
+    url = "https://github.com/conan-io/conan-center-index"
+    homepage = "https://gitlab.freedesktop.org/wayland/wayland-protocols"
+    license = "MIT"
+
+    settings = "os", "arch", "compiler", "build_type"
+
+    _meson = None
+
+    def package_id(self):
+        self.info.header_only()
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    @property
+    def _build_subfolder(self):
+        return "build_subfolder"
+
+    def build_requirements(self):
+        self.build_requires("meson/0.59.1")
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version],
+                  strip_root=True, destination=self._source_subfolder)
+
+    def _patch_sources(self):
+        tools.replace_in_file(os.path.join(self._source_subfolder, "meson.build"),
+                              "dep_scanner = dependency('wayland-scanner', native: true)",
+                              "#dep_scanner = dependency('wayland-scanner', native: true)")
+
+    def _configure_meson(self):
+        if not self._meson:
+            defs = {
+                "tests": "false",
+            }
+            self._meson = Meson(self)
+            self._meson.configure(
+                source_folder=self._source_subfolder,
+                build_folder=self._build_subfolder,
+                defs=defs,
+                args=['--datadir=%s' % os.path.join(self.package_folder, "res")],
+            )
+        return self._meson
+
+    def build(self):
+        self._patch_sources()
+        meson = self._configure_meson()
+        meson.build()
+
+    def package(self):
+        self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
+        meson = self._configure_meson()
+        meson.install()
+        tools.rmdir(os.path.join(self.package_folder, "res", "pkgconfig"))
+
+    def package_info(self):
+        pkgconfig_variables = {
+            'datarootdir': '${prefix}/res',
+            'pkgdatadir': '${datarootdir}/wayland-protocols',
+        }
+        self.cpp_info.set_property(
+            "pkg_config_custom_content",
+            "\n".join("%s=%s" % (key, value) for key,value in pkgconfig_variables.items()))


Test patch:
diff --git a/recipes/wayland-protocols/all/test_package/conanfile.py b/recipes/wayland-protocols/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/wayland-protocols/all/test_package/conanfile.py
@@ -0,0 +1,23 @@
+from conans import ConanFile, Meson, tools
+import os
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "pkg_config"
+
+    def build_requirements(self):
+        self.build_requires("wayland/1.19.0")
+        self.build_requires("meson/0.59.1")
+
+    def requirements(self):
+        self.requires("wayland/1.19.0")
+
+    def build(self):
+        meson = Meson(self)
+        meson.configure()
+        meson.build()
+
+    def test(self):
+        if not tools.cross_building(self.settings):
+            self.run(os.path.join(".", "test_package"), run_environment=True)
diff --git a/recipes/wayland-protocols/all/test_package/meson.build b/recipes/wayland-protocols/all/test_package/meson.build
new file mode 100644
--- /dev/null
+++ b/recipes/wayland-protocols/all/test_package/meson.build
@@ -0,0 +1,30 @@
+project('test_wayland_protocols', 'c')
+
+wayland_client_dep = dependency('wayland-client', version: '>=1.2.0', required: true)
+wayland_protocols_dep = dependency('wayland-protocols', required: true)
+wayland_protocols_datadir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir')
+
+wayland_scanner = find_program('wayland-scanner')
+wayland_scanner_code_gen = generator(
+    wayland_scanner,
+    output: '@BASENAME@-protocol.c',
+    arguments: ['code', '@INPUT@', '@OUTPUT@'],
+)
+wayland_scanner_client_header_gen = generator(
+    wayland_scanner,
+    output: '@BASENAME@-client-protocol.h',
+    arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
+)
+
+xdg_shell_xml = wayland_protocols_datadir/'stable/xdg-shell/xdg-shell.xml'
+
+xdg_shell_sources = [
+    wayland_scanner_code_gen.process(xdg_shell_xml),
+    wayland_scanner_client_header_gen.process(xdg_shell_xml),
+]
+
+executable('test_package',
+            'test_package.c',
+            xdg_shell_sources,
+            dependencies: [wayland_client_dep],
+            link_args : '-lrt')
diff --git a/recipes/wayland-protocols/all/test_package/test_package.c b/recipes/wayland-protocols/all/test_package/test_package.c
new file mode 100644
--- /dev/null
+++ b/recipes/wayland-protocols/all/test_package/test_package.c
@@ -0,0 +1,18 @@
+
+#include <stdio.h>
+#include <wayland-client.h>
+#include "xdg-shell-client-protocol.h"
+
+// TODO: Need help to write actual test here 
+
+int main(void)
+{
+    struct wl_display *display = wl_display_connect(NULL);
+    if (display) {
+        printf("Connected!\n");
+        wl_display_disconnect(display);
+    } else {
+        printf("Error connecting ;(\n");
+    }
+    return 0;
+}