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

liburing: Add 2.3+2.4 and update to Conan 2 #21061

Merged
merged 13 commits into from
Nov 14, 2023
9 changes: 7 additions & 2 deletions recipes/liburing/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
sources:
"2.4":
url: "https://github.com/axboe/liburing/archive/liburing-2.4.tar.gz"
sha256: "2398ec82d967a6f903f3ae1fd4541c754472d3a85a584dc78c5da2fabc90706b"
"2.3":
url: "https://github.com/axboe/liburing/archive/liburing-2.3.tar.gz"
sha256: "60b367dbdc6f2b0418a6e0cd203ee0049d9d629a36706fcf91dfb9428bae23c8"
"2.2":
url: "https://github.com/axboe/liburing/archive/liburing-2.2.tar.gz"
sha256: "e092624af6aa244ade2d52181cc07751ac5caba2f3d63e9240790db9ed130bbc"
Expand All @@ -13,6 +19,5 @@
sha256: "8e2842cfe947f3a443af301bdd6d034455536c38a455c7a700d0c1ad165a7543"

patches:
"2.1":
- base_path: "source_subfolder"
patch_file: "patches/0001-liburing-2.1-memfd-create.patch"
- patch_file: "patches/0001-liburing-2.1-memfd-create.patch"

Check warning on line 23 in recipes/liburing/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0001-lib ... ^ (line: 23)
100 changes: 52 additions & 48 deletions recipes/liburing/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from conans import AutoToolsBuildEnvironment
from conan import ConanFile
from conan.tools.files import get, patch, chdir, rmdir, copy
from conan.tools.files import get, rmdir, copy, apply_conandata_patches, chdir, export_conandata_patches, symlinks
from conan.tools.scm import Version
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.54.0"


class LiburingConan(ConanFile):
class Liburing(ConanFile):
name = "liburing"
license = "GPL-2.0-or-later"
homepage = "https://github.com/axboe/liburing"
Expand All @@ -29,13 +30,12 @@ class LiburingConan(ConanFile):
"with_libc": True,
}

exports_sources = ["patches/*"]
def export_sources(self):
export_conandata_patches(self)

_autotools = None

@property
def _source_subfolder(self):
return "source_subfolder"
def requirements(self):
if Version(self.version) < "2.3":
self.requires("linux-headers-generic/5.13.9")

def config_options(self):
if self.settings.os == "Windows":
Expand All @@ -45,13 +45,9 @@ def config_options(self):

def configure(self):
if self.options.shared:
del self.options.fPIC

del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def requirements(self):
self.requires("linux-headers-generic/5.13.9")
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

def validate(self):
# FIXME: use kernel version of build/host machine.
Expand All @@ -60,49 +56,57 @@ def validate(self):
raise ConanInvalidConfiguration(
"liburing is supported only on linux")

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

def _configure_autotools(self):
if self._autotools:
return self._autotools
def layout(self):
basic_layout(self, src_folder='src')

self._autotools = AutoToolsBuildEnvironment(self)
args = []
if self.options.get_safe("with_libc") == False:
args.append("--nolibc")
self._autotools.configure(args=args)
self._autotools.flags.append("-std=gnu99")
return self._autotools

def _patch_sources(self):
for data in self.conan_data.get("patches", {}).get(self.version, []):
patch(self, **data)
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = AutotoolsToolchain(self)
def whether(condition):
return "" if condition else None
tc.update_configure_args({
franramirez688 marked this conversation as resolved.
Show resolved Hide resolved
"--nolibc": whether(not self.options.get_safe("with_libc", default=True)),
"--enable-shared": None,
franramirez688 marked this conversation as resolved.
Show resolved Hide resolved
"--disable-shared": None,
"--enable-static": None,
"--disable-static": None,
"--bindir": None,
"--sbindir": None,
"--oldincludedir": None,
})
tc.generate()

def build(self):
self._patch_sources()
with chdir(self, self._source_subfolder):
autotools = self._configure_autotools()
autotools.make()
apply_conandata_patches(self)
with chdir(self, self.source_folder):
at = Autotools(self)
at.configure()
at.make(target="src")

def package(self):
copy(self, "COPYING*", src=self._source_subfolder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "LICENSE", src=self._source_subfolder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "COPYING*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))

with chdir(self, self._source_subfolder):
autotools = self._configure_autotools()
install_args = [
"ENABLE_SHARED={}".format(1 if self.options.shared else 0)
]
autotools.install(args=install_args)
with chdir(self, self.source_folder):
at = Autotools(self)
at.install(
args=[f"ENABLE_SHARED={1 if self.options.shared else 0}"]
)

rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "man"))

if self.options.shared:
os.remove(os.path.join(self.package_folder, "lib", "liburing.a"))

# FIXME: The liburing.so symlink ends up broken. Remove and replace.
symlinks.remove_broken_symlinks(self, self.package_folder)
source_file_suffix = "1" if self.version < Version("2.0") else "2"
os.symlink(src=f"liburing.so.{source_file_suffix}",
dst=os.path.join(self.package_folder, "lib", "liburing.so"))

franramirez688 marked this conversation as resolved.
Show resolved Hide resolved
def package_info(self):
self.cpp_info.names["pkg_config"] = "liburing"
self.cpp_info.set_property("pkg_config_name", "liburing")
self.cpp_info.libs = ["uring"]
3 changes: 0 additions & 3 deletions recipes/liburing/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(liburing REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
Expand Down
18 changes: 12 additions & 6 deletions recipes/liburing/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conans import CMake
from conan import ConanFile
from conan.tools.build import cross_building
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.scm import Version
import platform
import re
Expand All @@ -9,7 +9,13 @@

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

def layout(self):
cmake_layout(self)

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

def build(self):
cmake = CMake(self)
Expand All @@ -23,6 +29,6 @@ def _sufficient_linux_kernel_version(self):
return Version(linux_kernel_version) >= "5.1"

def test(self):
if not cross_building(self) and self._sufficient_linux_kernel_version:
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self) and self._sufficient_linux_kernel_version:
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
8 changes: 8 additions & 0 deletions recipes/liburing/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
17 changes: 17 additions & 0 deletions recipes/liburing/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
4 changes: 4 additions & 0 deletions recipes/liburing/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
versions:
"2.4":
folder: all
"2.3":
folder: all
"2.2":
folder: all
"2.1":
Expand Down