-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconanfile.py
More file actions
199 lines (172 loc) · 6.95 KB
/
Copy pathconanfile.py
File metadata and controls
199 lines (172 loc) · 6.95 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
from conans import tools, ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.layout import cmake_layout
from conan.tools.apple.apple import is_apple_os
import os
class TankerConan(ConanFile):
name = "tanker"
version = "dev"
settings = "os", "compiler", "build_type", "arch"
options = {
"tankerlib_shared": [True, False],
"fPIC": [True, False],
"with_tracer": [True, False],
"warn_as_error": [True, False],
"sanitizer": ["address", "leak", "memory", "thread", "undefined", None],
"coverage": [True, False],
"with_coroutines_ts": [True, False],
"with_http_backend": ["libcurl", None],
"with_sqlite": [True, False],
}
default_options = {
"tankerlib_shared": False,
"fPIC": True,
"with_tracer": False,
"warn_as_error": False,
"sanitizer": None,
"coverage": False,
"with_coroutines_ts": False,
"with_http_backend": "libcurl",
"with_sqlite": True,
}
generators = "CMakeDeps", "VirtualBuildEnv"
exports_sources = "CMakeLists.txt", "modules/*", "cmake/*"
@property
def cross_building(self):
return tools.cross_building(self)
@property
def should_build_tests(self):
# develop is false when the package is used as a requirement,
# so don't bother compiling tests in that case
if not self.develop:
return False
# Usually, tests cannot be run when cross-compiling,
# _except_ when cross-compiling from win64 to win32 with mingw
# on Windows, so check for the special use case before
# reading the value of `self.cross_building`
if self.is_mingw and tools.os_info.is_windows:
return True
if self.cross_building:
return False
if not self.options.with_http_backend or not self.options.with_sqlite:
return False
return True
@property
def should_build_tools(self):
# develop is false when the package is used as a requirement,
# so don't bother compiling tools in that case
if not self.develop:
return False
# mingw64 is not detected as cross-building
if self.cross_building or self.is_mingw:
return False
return True
@property
def should_build_tracer(self):
return self.options.with_tracer
@property
def sanitizer_flag(self):
if self.options.sanitizer:
return " -fsanitize=%s " % self.options.sanitizer
return None
@property
def is_mingw(self):
return self.settings.os == "Windows" and self.settings.compiler == "gcc"
def requirements(self):
private = self.options.tankerlib_shared
self.requires("boost/1.88.0-r3", private=private)
self.requires("libressl/4.1.0-r1", private=private)
self.requires("libcurl/8.4.0-r2", private=private)
if self.options.with_sqlite:
self.requires("sqlpp11/0.60-r6", private=private)
self.requires("sqlpp11-connector-sqlite3/0.30-r7", private=private)
self.requires("mgs/0.2.1-r1", private=private)
self.requires("enum-flags/0.1a-r3", private=private)
self.requires("range-v3/0.12.0-r1", private=private)
self.requires("fmt/7.1.3-r3", private=private)
self.requires("gsl-lite/0.37.0-r1", private=private)
self.requires("nlohmann_json/3.12.0-r1", private=private)
self.requires("libsodium/1.0.19-r1", private=private)
self.requires("tconcurrent/0.40.2-r2", private=private)
self.requires("date/3.0.0-r5", private=private)
# catch2 is needed to export datastore tests
self.requires("catch2/3.4.0-r1", private=private)
if is_apple_os(self):
self.requires("libcxx/15.0.7-r1", private=private)
def build_requirements(self):
if self.should_build_tools:
self.test_requires("docopt.cpp/0.6.2-r2")
if self.should_build_tests:
self.test_requires("catch2-async/3.4.0-r6")
self.test_requires("trompeloeil/49-r1")
def generate(self):
ct = CMakeToolchain(self)
if self.options.sanitizer:
ct.variables["CONAN_C_FLAGS"] += self.sanitizer_flag
ct.variables["CONAN_CXX_FLAGS"] += self.sanitizer_flag
if self.options.with_coroutines_ts:
ct.variables["CONAN_CXX_FLAGS"] += " -fcoroutines-ts "
ct.variables["BUILD_TESTS"] = self.should_build_tests
ct.variables["WITH_TRACER"] = self.should_build_tracer
ct.variables["WARN_AS_ERROR"] = self.options.warn_as_error
ct.variables["BUILD_TANKER_TOOLS"] = self.should_build_tools
ct.variables["TANKERLIB_SHARED"] = self.options.tankerlib_shared
ct.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.fPIC
ct.variables["WITH_COVERAGE"] = self.options.coverage
ct.variables["WITH_CURL"] = self.options.with_http_backend == "libcurl"
ct.variables["WITH_SQLITE"] = self.options.with_sqlite
ct.generate()
def build(self):
cmake = CMake(self)
if self.should_configure:
cmake.configure()
if self.should_build:
cmake.build()
if self.should_install and self.develop:
cmake.install()
def deploy(self):
self.copy("include/*")
self.copy("*.a")
self.copy("*.lib")
self.copy("*.dll")
self.copy("*.so")
self.copy("*.dylib")
if not self.options.tankerlib_shared:
self.copy_deps("*.lib", dst="lib", keep_path=False)
self.copy_deps("*.a", dst="lib", keep_path=False)
def package(self):
cmake = CMake(self)
if self.settings.build_type == "Release" and not self.settings.os == "Windows":
cmake.build(target="install/strip")
else:
cmake.install()
def package_id(self):
del self.info.options.warn_as_error
def package_info(self):
libs = ["ctanker", "tankerdatastoretests"]
if not self.options.tankerlib_shared:
libs.extend(
[
"ctankerdatastore",
"tanker_async",
"tankerfunctionalhelpers",
"tankeradmin",
"tankertesthelpers",
"tankercore",
"tankerencryptor",
"tankerstreams",
"tankertrustchain",
"tankeridentity",
"tankercrypto",
"tankerserialization",
"tankererrors",
"tankerlog",
"tankerformat",
"tcurl",
]
)
if self.sanitizer_flag:
self.cpp_info.sharedlinkflags = [self.sanitizer_flag]
self.cpp_info.exelinkflags = [self.sanitizer_flag]
self.cpp_info.includedirs = ["include"]
self.cpp_info.libs = libs