-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libunifex: migrate to Conan v2, add v0.3.0
- Loading branch information
Showing
8 changed files
with
99 additions
and
74 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
sources: | ||
"0.3.0": | ||
url: "https://github.com/facebookexperimental/libunifex/archive/refs/tags/v0.3.0.tar.gz" | ||
sha256: "da6b65227adcf1ce3e3410865cc2974b1aacaa20d0f03905bd3bd4fb4e6e4d44" | ||
"cci.20220430": | ||
url: "https://github.com/facebookexperimental/libunifex/archive/c359fd8e7d97d91359cf4a6c1dbef99b0b1767b6.tar.gz" | ||
sha256: "c306891967fa4cc1a22f3401581d35ceea41eb1dbdac3e6157ecf3defaa4b15d" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,106 @@ | ||
from conans import ConanFile, CMake, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
import functools | ||
import os | ||
|
||
required_conan_version = ">=1.43.0" | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout | ||
from conan.tools.files import copy, get, rmdir | ||
from conan.tools.microsoft import is_msvc | ||
|
||
required_conan_version = ">=1.52.0" | ||
|
||
|
||
class LibunifexConan(ConanFile): | ||
name = "libunifex" | ||
description = "A prototype implementation of the C++ sender/receiver async programming model" | ||
license = ("Apache-2.0", "LLVM-exception") | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/facebookexperimental/libunifex" | ||
description = "A prototype implementation of the C++ sender/receiver async programming model" | ||
topics = ("async", "cpp") | ||
|
||
package_type = "static-library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
|
||
generators = "cmake", "cmake_find_package_multi" | ||
no_copy_source = True | ||
exports_sources = ["CMakeLists.txt"] | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
def _minimum_standard(self): | ||
return 17 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "9", | ||
"Visual Studio": "16", | ||
"clang": "10", | ||
"apple-clang": "11", | ||
"Visual Studio": "16", | ||
"msvc": "193", | ||
} | ||
|
||
@property | ||
def _minimum_standard(self): | ||
return "17" | ||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
# FIXME: Add support for liburing | ||
# def requirements(self): | ||
# TODO: Make an option to opt-out of liburing for old kernel versions | ||
# if self.settings.os == "Linux": | ||
# self.requires("liburing/2.1") | ||
def requirements(self): | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.requires("liburing/2.2", transitive_headers=True) | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
tools.check_min_cppstd( | ||
self, self._minimum_standard) | ||
check_min_cppstd(self, self._minimum_standard) | ||
|
||
def lazy_lt_semver(v1, v2): | ||
lv1 = [int(v) for v in v1.split(".")] | ||
lv2 = [int(v) for v in v2.split(".")] | ||
min_length = min(len(lv1), len(lv2)) | ||
return lv1[:min_length] < lv2[:min_length] | ||
|
||
minimum_version = self._compilers_minimum_version.get( | ||
str(self.settings.compiler), False) | ||
if not minimum_version: | ||
self.output.warn( | ||
"{0} {1} requires C++{2}. Your compiler is unknown. Assuming it supports C++{2}." | ||
.format(self.name, self.version, self._minimum_standard)) | ||
elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): | ||
return all(int(p1) < int(p2) for p1, p2 in zip(v1.split("."), v2.split("."))) | ||
|
||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version and lazy_lt_semver(self.settings.compiler.version, minimum_version): | ||
raise ConanInvalidConfiguration( | ||
"{} {} requires C++{}, which your compiler does not support." | ||
.format(self.name, self.version, self._minimum_standard)) | ||
f"{self.ref} requires C++{self._minimum_standard}, which your compiler does not support." | ||
) | ||
|
||
if self.version == "cci.20220430" and is_msvc(self): | ||
raise ConanInvalidConfiguration(f"{self.ref} is not supported on MSVC") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], | ||
destination=self._source_subfolder, strip_root=True) | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
@functools.lru_cache(1) | ||
def _configure_cmake(self): | ||
cmake = CMake(self) | ||
cmake.definitions["BUILD_TESTING"] = "OFF" | ||
cmake.configure() | ||
return cmake | ||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.variables["BUILD_TESTING"] = False | ||
tc.generate() | ||
tc = CMakeDeps(self) | ||
tc.generate() | ||
|
||
def build(self): | ||
cmake = self._configure_cmake() | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) | ||
cmake = self._configure_cmake() | ||
copy(self, "LICENSE.txt", | ||
dst=os.path.join(self.package_folder, "licenses"), | ||
src=self.source_folder) | ||
cmake = CMake(self) | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
|
||
def package_info(self): | ||
self.cpp_info.bindirs = [] | ||
self.cpp_info.libdirs = [] | ||
|
||
self.cpp_info.set_property("cmake_file_name", "unifex") | ||
self.cpp_info.set_property("cmake_target_name", "unifex::unifex") | ||
self.cpp_info.set_property("pkg_config_name", "unifex") | ||
|
||
self.cpp_info.components["unifex"].libs = ["unifex"] | ||
self.cpp_info.components["unifex"].set_property("cmake_target_name", "unifex::unifex") | ||
|
||
# TODO: to remove in conan v2 once cmake_find_package_* generators removed | ||
self.cpp_info.filenames["cmake_find_package"] = "unifex" | ||
self.cpp_info.filenames["cmake_find_package_multi"] = "unifex" | ||
self.cpp_info.names["cmake_find_package"] = "unifex" | ||
self.cpp_info.names["cmake_find_package_multi"] = "unifex" | ||
self.cpp_info.names["pkg_config"] = "unifex" | ||
self.cpp_info.components["unifex"].names["cmake_find_package"] = "unifex" | ||
self.cpp_info.components["unifex"].names["cmake_find_package_multi"] = "unifex" | ||
self.cpp_info.components["unifex"].set_property( | ||
"cmake_target_name", "unifex::unifex") | ||
self.cpp_info.components["unifex"].libs = ["unifex"] | ||
|
||
if self.settings.os == "Linux": | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.components["unifex"].system_libs = ["pthread"] | ||
# self.cpp_info.components["unifex"].requires.append( | ||
# "liburing::liburing") | ||
self.cpp_info.components["unifex"].requires.append("liburing::liburing") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
from conans import ConanFile, CMake, tools | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
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) | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", "arch", "compiler", "build_type" | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
versions: | ||
"0.3.0": | ||
folder: all | ||
"cci.20220430": | ||
folder: "all" | ||
folder: all |