Skip to content

Commit

Permalink
libice: add new recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Oct 6, 2024
1 parent 6935c2a commit 54a28bc
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 0 deletions.
6 changes: 6 additions & 0 deletions recipes/libice/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sources:
"1.1.1":
url:
- "https://www.x.org/archive/individual/lib/libICE-1.1.1.tar.xz"
- "https://xorg.freedesktop.org/releases/individual/lib/libICE-1.1.1.tar.xz"
sha256: "03e77afaf72942c7ac02ccebb19034e6e20f456dcf8dddadfeb572aa5ad3e451"
95 changes: 95 additions & 0 deletions recipes/libice/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.gnu import PkgConfigDeps, AutotoolsToolchain, Autotools
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc

required_conan_version = ">=1.53.0"


class LibIceConan(ConanFile):
name = "libice"
description = "X11 Inter-Client Exchange library"
license = "MIT-open-group"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://gitlab.freedesktop.org/xorg/lib/libice"
topics = ("xorg", "x11")

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

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

def requirements(self):
self.requires("xorg-proto/2024.1", transitive_headers=True)
self.requires("xtrans/1.5.0")

def validate(self):
if is_msvc(self):
raise ConanInvalidConfiguration("MSVC is not supported.")

def build_requirements(self):
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/[>=2.2 <3]")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
self.tool_requires("xorg-macros/1.20.0")

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

def generate(self):
VirtualBuildEnv(self).generate()
tc = AutotoolsToolchain(self)
tc.generate()
deps = PkgConfigDeps(self)
deps.generate()

def build(self):
autotools = Autotools(self)
autotools.configure()
autotools.make()

def package(self):
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
autotools.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
fix_apple_shared_install_name(self)

def package_info(self):
self.cpp_info.set_property("pkg_config_name", "ice")
self.cpp_info.set_property("cmake_target_name", "X11::ICE")
self.cpp_info.libs = ["ICE"]
32 changes: 32 additions & 0 deletions recipes/libice/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.2.3 <2]")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/[>=2.2 <3]")

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")
5 changes: 5 additions & 0 deletions recipes/libice/all/test_package/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project('test_package', 'c')
package_dep = dependency('ice')
executable('test_package',
sources : ['test_package.c'],
dependencies : [package_dep])
5 changes: 5 additions & 0 deletions recipes/libice/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <X11/ICE/ICElib.h>

int main() {
IceInitThreads();
}
3 changes: 3 additions & 0 deletions recipes/libice/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.1.1":
folder: all

0 comments on commit 54a28bc

Please sign in to comment.