forked from basiliscos/cpp-rotor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
128 lines (109 loc) · 4.82 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import os
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, rmdir, copy
from conan.tools.cmake import CMakeToolchain, CMake, CMakeDeps, cmake_layout
required_conan_version = ">=1.52.0"
class RotorConan(ConanFile):
name = "rotor"
license = "MIT"
homepage = "https://github.com/basiliscos/cpp-rotor"
url = "https://github.com/conan-io/conan-center-index"
description = (
"Event loop friendly C++ actor micro-framework, supervisable"
)
topics = ("concurrency", "actor-framework", "actors", "actor-model", "erlang", "supervising", "supervisor")
exports_sources = "CMakeLists.txt", "src/*", "include/*", "test_package/*", "cmake/*", "tests/*", "examples/*"
test_requires = "catch2/3.4.0"
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
"shared": [True, False],
"enable_asio": [True, False],
"enable_ev" : [True, False],
"enable_thread": [True, False],
"multithreading": [True, False], # enables multithreading support
}
default_options = {
"fPIC": True,
"shared": False,
"enable_asio": True,
"enable_ev" : False,
"enable_thread": True,
"multithreading": True,
}
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
try:
del self.options.fPIC
except Exception:
pass
def requirements(self):
self.requires("boost/1.83.0", transitive_headers=True)
if self.options.enable_ev:
self.requires("libev/4.33")
def layout(self):
cmake_layout(self)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_BOOST_ASIO"] = self.options.enable_asio
tc.variables["BUILD_THREAD"] = self.options.enable_thread
tc.variables["BUILD_EV"] = self.options.enable_ev
tc.variables["BUILD_EXAMPLES"] = os.environ.get('ROTOR_BUILD_EXAMPLES', 'OFF')
tc.variables["BUILD_THREAD_UNSAFE"] = not self.options.multithreading
tc.variables["BUILD_TESTING"] = not self.conf.get("tools.build:skip_test", default=True, check_type=bool)
tc.generate()
tc = CMakeDeps(self)
tc.generate()
def validate(self):
minimal_cpp_standard = "17"
# if self.settings.compiler.get_safe("cppstd"):
# check_min_cppstd(self, minimal_cpp_standard)
minimal_version = {
"gcc": "7",
"clang": "6",
"apple-clang": "10",
"Visual Studio": "15"
}
compiler = str(self.settings.compiler)
if compiler not in minimal_version:
print(
f"{self.ref} recipe lacks information about the {compiler} compiler standard version support")
print(
f"{self.ref} requires a compiler that supports at least C++{minimal_cpp_standard}")
return
compiler_version = Version(self.settings.compiler.version)
if compiler_version < minimal_version[compiler]:
raise ConanInvalidConfiguration(f"{self.ref} requires a compiler that supports at least C++{minimal_cpp_standard}")
if self.options.shared and Version(self.version) < "0.23":
raise ConanInvalidConfiguration("shared option is available from v0.23")
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
if not self.conf.get("tools.build:skip_test", default=True):
cmake.test()
def package(self):
copy(self, pattern="LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
def package_info(self):
self.cpp_info.components["core"].libs = ["rotor"]
self.cpp_info.components["core"].requires = ["boost::date_time", "boost::system", "boost::regex"]
if not self.options.multithreading:
self.cpp_info.components["core"].defines.append("BUILD_THREAD_UNSAFE")
if self.options.enable_asio:
self.cpp_info.components["asio"].libs = ["rotor_asio"]
self.cpp_info.components["asio"].requires = ["core"]
if self.options.enable_thread:
self.cpp_info.components["thread"].libs = ["rotor_thread"]
self.cpp_info.components["thread"].requires = ["core"]
if self.options.enable_ev:
self.cpp_info.components["ev"].libs = ["rotor_ev"]
self.cpp_info.components["ev"].requires = ["core", "libev::libev"]