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

xorg/system: Modernize #11698

Merged
Merged
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
130 changes: 57 additions & 73 deletions recipes/xorg/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from conans import ConanFile, tools
from conans.errors import ConanException, ConanInvalidConfiguration
from conan import ConanFile
from conan.tools.gnu import PkgConfig
from conan.tools.system.package_manager import Apt, Dnf, PacMan, Pkg, Yum, Zypper
from conan.errors import ConanInvalidConfiguration

required_conan_version = ">=1.32"
required_conan_version = ">=1.47"

class ConanXOrg(ConanFile):
name = "xorg"
Expand All @@ -12,81 +14,56 @@ class ConanXOrg(ConanFile):
settings = "os"
topics = ("x11", "xorg")

def configure(self):
def validate(self):
if self.settings.os not in ["Linux", "FreeBSD"]:
raise ConanInvalidConfiguration("This recipe supports only Linux and FreeBSD")

def package_id(self):
self.info.header_only()

def _fill_cppinfo_from_pkgconfig(self, name):
pkg_config = tools.PkgConfig(name)
if not pkg_config.provides:
raise ConanException("OpenGL development files aren't available, give up")
libs = [lib[2:] for lib in pkg_config.libs_only_l]
lib_dirs = [lib[2:] for lib in pkg_config.libs_only_L]
ldflags = [flag for flag in pkg_config.libs_only_other]
include_dirs = [include[2:] for include in pkg_config.cflags_only_I]
cflags = [flag for flag in pkg_config.cflags_only_other if not flag.startswith("-D")]
defines = [flag[2:] for flag in pkg_config.cflags_only_other if flag.startswith("-D")]
variables = pkg_config.variables
def system_requirements(self):
apt = Apt(self)
apt.install(["libx11-dev", "libx11-xcb-dev", "libfontenc-dev", "libice-dev", "libsm-dev", "libxau-dev", "libxaw7-dev",
"libxcomposite-dev", "libxcursor-dev", "libxdamage-dev", "libxdmcp-dev", "libxext-dev", "libxfixes-dev",
"libxi-dev", "libxinerama-dev", "libxkbfile-dev", "libxmu-dev", "libxmuu-dev",
"libxpm-dev", "libxrandr-dev", "libxrender-dev", "libxres-dev", "libxss-dev", "libxt-dev", "libxtst-dev",
"libxv-dev", "libxvmc-dev", "libxxf86vm-dev", "xtrans-dev", "libxcb-render0-dev",
"libxcb-render-util0-dev", "libxcb-xkb-dev", "libxcb-icccm4-dev", "libxcb-image0-dev",
"libxcb-keysyms1-dev", "libxcb-randr0-dev", "libxcb-shape0-dev", "libxcb-sync-dev", "libxcb-xfixes0-dev",
"libxcb-xinerama0-dev", "xkb-data", "libxcb-dri3-dev", "uuid-dev"], update=True, check=True)
apt.install_substitutes(
["libxcb-util-dev"], ["libxcb-util0-dev"], update=True, check=True)

self.cpp_info.components[name].system_libs = libs
self.cpp_info.components[name].libdirs = lib_dirs
self.cpp_info.components[name].sharedlinkflags = ldflags
self.cpp_info.components[name].exelinkflags = ldflags
self.cpp_info.components[name].defines = defines
self.cpp_info.components[name].includedirs = include_dirs
self.cpp_info.components[name].cflags = cflags
self.cpp_info.components[name].cxxflags = cflags
self.cpp_info.components[name].version = pkg_config.version[0]
self.cpp_info.components[name].set_property("component_version", pkg_config.version[0])
self.cpp_info.components[name].set_property(
"pkg_config_custom_content",
"\n".join(f"{key}={value}" for key,value in variables.items() if key not in ["pcfiledir","prefix", "includedir"]))
Yum(self).install(["libxcb-devel", "libfontenc-devel", "libXaw-devel", "libXcomposite-devel",
"libXcursor-devel", "libXdmcp-devel", "libXtst-devel", "libXinerama-devel",
"libxkbfile-devel", "libXrandr-devel", "libXres-devel", "libXScrnSaver-devel", "libXvMC-devel",
"xorg-x11-xtrans-devel", "xcb-util-wm-devel", "xcb-util-image-devel", "xcb-util-keysyms-devel",
"xcb-util-renderutil-devel", "libXdamage-devel", "libXxf86vm-devel", "libXv-devel",
"xcb-util-devel", "libuuid-devel", "xkeyboard-config-devel"], update=True, check=True)

jwillikers marked this conversation as resolved.
Show resolved Hide resolved
def system_requirements(self):
packages = []
if tools.os_info.is_linux and self.settings.os == "Linux":
if tools.os_info.with_apt:
packages = ["libx11-dev", "libx11-xcb-dev", "libfontenc-dev", "libice-dev", "libsm-dev", "libxau-dev", "libxaw7-dev",
"libxcomposite-dev", "libxcursor-dev", "libxdamage-dev", "libxdmcp-dev", "libxext-dev", "libxfixes-dev",
"libxi-dev", "libxinerama-dev", "libxkbfile-dev", "libxmu-dev", "libxmuu-dev",
"libxpm-dev", "libxrandr-dev", "libxrender-dev", "libxres-dev", "libxss-dev", "libxt-dev", "libxtst-dev",
"libxv-dev", "libxvmc-dev", "libxxf86vm-dev", "xtrans-dev", "libxcb-render0-dev",
"libxcb-render-util0-dev", "libxcb-xkb-dev", "libxcb-icccm4-dev", "libxcb-image0-dev",
"libxcb-keysyms1-dev", "libxcb-randr0-dev", "libxcb-shape0-dev", "libxcb-sync-dev", "libxcb-xfixes0-dev",
"libxcb-xinerama0-dev", "xkb-data", "libxcb-dri3-dev", "uuid-dev"]
if (tools.os_info.linux_distro == "ubuntu" and tools.os_info.os_version < "15") or\
(tools.os_info.linux_distro == "debian" and tools.os_info.os_version < "12") or\
(tools.os_info.linux_distro == "raspbian" and tools.os_info.os_version < "12"):
packages.append( "libxcb-util0-dev" )
else:
packages.append( "libxcb-util-dev" )
elif tools.os_info.with_yum or tools.os_info.with_dnf or tools.os_info.with_zypper:
packages = ["libxcb-devel", "libfontenc-devel", "libXaw-devel", "libXcomposite-devel",
"libXcursor-devel", "libXdmcp-devel", "libXtst-devel", "libXinerama-devel",
"libxkbfile-devel", "libXrandr-devel", "libXres-devel", "libXScrnSaver-devel", "libXvMC-devel",
"xorg-x11-xtrans-devel", "xcb-util-wm-devel", "xcb-util-image-devel", "xcb-util-keysyms-devel",
"xcb-util-renderutil-devel", "libXdamage-devel", "libXxf86vm-devel", "libXv-devel",
"xcb-util-devel", "libuuid-devel"]
packages.append("xkeyboard-config" if tools.os_info.with_zypper else "xkeyboard-config-devel")
elif tools.os_info.with_pacman:
packages = ["libxcb", "libfontenc", "libice", "libsm", "libxaw", "libxcomposite", "libxcursor",
"libxdamage", "libxdmcp", "libxtst", "libxinerama", "libxkbfile", "libxrandr", "libxres",
"libxss", "libxvmc", "xtrans", "xcb-util-wm", "xcb-util-image","xcb-util-keysyms", "xcb-util-renderutil",
"libxxf86vm", "libxv", "xkeyboard-config", "xcb-util", "util-linux-libs"]
else:
self.output.warn("Do not know how to install 'xorg' for {}.".format(tools.os_info.linux_distro))

elif tools.os_info.is_freebsd and self.settings.os == "FreeBSD":
packages = ["libX11", "libfontenc", "libice", "libsm", "libxaw", "libxcomposite", "libxcursor",
"libxdamage", "libxdmcp", "libxtst", "libxinerama", "libxkbfile", "libxrandr", "libxres",
"libXScrnSaver", "libxvmc", "xtrans", "xcb-util-wm", "xcb-util-image", "xcb-util-keysyms", "xcb-util-renderutil",
"libxxf86vm", "libxv", "xkeyboard-config", "xcb-util"]
if packages:
package_tool = tools.SystemPackageTool(conanfile=self, default_mode="verify")
package_tool.install_packages(update=True, packages=packages)
Dnf(self).install(["libxcb-devel", "libfontenc-devel", "libXaw-devel", "libXcomposite-devel",
"libXcursor-devel", "libXdmcp-devel", "libXtst-devel", "libXinerama-devel",
"libxkbfile-devel", "libXrandr-devel", "libXres-devel", "libXScrnSaver-devel", "libXvMC-devel",
"xorg-x11-xtrans-devel", "xcb-util-wm-devel", "xcb-util-image-devel", "xcb-util-keysyms-devel",
"xcb-util-renderutil-devel", "libXdamage-devel", "libXxf86vm-devel", "libXv-devel",
"xcb-util-devel", "libuuid-devel", "xkeyboard-config-devel"], update=True, check=True)

Zypper(self).install(["libxcb-devel", "libfontenc-devel", "libXaw-devel", "libXcomposite-devel",
"libXcursor-devel", "libXdmcp-devel", "libXtst-devel", "libXinerama-devel",
"libxkbfile-devel", "libXrandr-devel", "libXres-devel", "libXScrnSaver-devel", "libXvMC-devel",
"xorg-x11-xtrans-devel", "xcb-util-wm-devel", "xcb-util-image-devel", "xcb-util-keysyms-devel",
"xcb-util-renderutil-devel", "libXdamage-devel", "libXxf86vm-devel", "libXv-devel",
"xcb-util-devel", "libuuid-devel", "xkeyboard-config"], update=True, check=True)

PacMan(self).install(["libxcb", "libfontenc", "libice", "libsm", "libxaw", "libxcomposite", "libxcursor",
"libxdamage", "libxdmcp", "libxtst", "libxinerama", "libxkbfile", "libxrandr", "libxres",
"libxss", "libxvmc", "xtrans", "xcb-util-wm", "xcb-util-image", "xcb-util-keysyms", "xcb-util-renderutil",
"libxxf86vm", "libxv", "xkeyboard-config", "xcb-util", "util-linux-libs"], update=True, check=True)

Pkg(self).install(["libX11", "libfontenc", "libice", "libsm", "libxaw", "libxcomposite", "libxcursor",
"libxdamage", "libxdmcp", "libxtst", "libxinerama", "libxkbfile", "libxrandr", "libxres",
"libXScrnSaver", "libxvmc", "xtrans", "xcb-util-wm", "xcb-util-image", "xcb-util-keysyms", "xcb-util-renderutil",
"libxxf86vm", "libxv", "xkeyboard-config", "xcb-util"], update=True, check=True)

def package_info(self):
for name in ["x11", "x11-xcb", "fontenc", "ice", "sm", "xau", "xaw7",
Expand All @@ -97,9 +74,16 @@ def package_info(self):
"xcb-renderutil", "xcb-shape", "xcb-shm", "xcb-sync", "xcb-xfixes",
"xcb-xinerama", "xcb", "xkeyboard-config", "xcb-atom", "xcb-aux", "xcb-event", "xcb-util",
"xcb-dri3"] + ([] if self.settings.os == "FreeBSD" else ["uuid"]):
self._fill_cppinfo_from_pkgconfig(name)
self.cpp_info.components[name].set_property("pkg_config_name", name)
pkg_config = PkgConfig(self, name)
pkg_config.fill_cpp_info(
self.cpp_info.components[name], is_system=self.settings.os != "FreeBSD")
self.cpp_info.components[name].version = pkg_config.version
self.cpp_info.components[name].set_property(
"pkg_config_name", name)
self.cpp_info.components[name].set_property(
"component_version", pkg_config.version)
self.cpp_info.components[name].set_property("pkg_config_custom_content",
"\n".join("f{key}={value}" for key, value in pkg_config.variables.items() if key not in ["pcfiledir","prefix", "includedir"]))

if self.settings.os == "Linux":
self.cpp_info.components["sm"].requires.append("uuid")

12 changes: 5 additions & 7 deletions recipes/xorg/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
cmake_minimum_required(VERSION 3.15)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
project(test_package LANGUAGES C)

set(SOURCES test_package.c)
find_package(xorg REQUIRED)

add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
add_executable(test_package test_package.c)
target_link_libraries(test_package PRIVATE xorg::xorg)
27 changes: 21 additions & 6 deletions recipes/xorg/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
import os

from conan import ConanFile
from conan.tools.build import cross_building
from conans import CMake
import os
from conan.tools.cmake import CMake
from conan.tools.gnu import PkgConfigDeps
from conan.tools.layout import cmake_layout


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "pkg_config"
generators = "CMakeToolchain", "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv"

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

def layout(self):
cmake_layout(self)

def generate(self):
pkg_config_deps = PkgConfigDeps(self)
pkg_config_deps.generate()
pkg_config = self.conf_info.get("tools.gnu:pkg_config", default="pkg-config")
uuid_pkg_config_file = os.path.join(self.generators_folder, "uuid.pc")
self.run(f"{pkg_config} --validate {uuid_pkg_config_file}")

def build(self):
self.run("pkg-config --validate ./uuid.pc")
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
cmd = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(cmd, env="conanrun")