forked from libbitcoin/libbitcoin-database
-
Notifications
You must be signed in to change notification settings - Fork 3
/
conanfile.py
248 lines (213 loc) · 12 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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#
# Copyright (c) 2017-2018 Bitprim Inc.
#
# This file is part of Bitprim.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
from conans import CMake
from ci_utils import option_on_off, get_version, get_conan_req_version, march_conan_manip, pass_march_to_compiler
from ci_utils import BitprimConanFile
class BitprimDatabaseConan(BitprimConanFile):
name = "bitprim-database"
# version = get_version()
license = "http://www.boost.org/users/license.html"
url = "https://github.com/bitprim/bitprim-database/tree/conan-build/conanfile.py"
description = "Bitcoin High Performance Blockchain Database"
settings = "os", "compiler", "build_type", "arch"
# if Version(conan_version) < Version(get_conan_req_version()):
# raise Exception ("Conan version should be greater or equal than %s. Detected: %s." % (get_conan_req_version(), conan_version))
options = {"shared": [True, False],
"fPIC": [True, False],
"with_tests": [True, False],
"with_tools": [True, False],
"currency": ['BCH', 'BTC', 'LTC'],
"microarchitecture": "ANY", #["x86_64", "haswell", "ivybridge", "sandybridge", "bulldozer", ...]
"fix_march": [True, False],
"verbose": [True, False],
"measurements": [True, False],
"use_domain": [True, False],
"db": ['legacy', 'legacy_full', 'pruned', 'default', 'full'],
"cached_rpc_data": [True, False],
"cxxflags": "ANY",
"cflags": "ANY",
"glibcxx_supports_cxx11_abi": "ANY",
}
default_options = "shared=False", \
"fPIC=True", \
"with_tests=False", \
"with_tools=False", \
"currency=BCH", \
"microarchitecture=_DUMMY_", \
"fix_march=False", \
"verbose=False", \
"measurements=False", \
"use_domain=True", \
"db=default", \
"cached_rpc_data=False", \
"cxxflags=_DUMMY_", \
"cflags=_DUMMY_", \
"glibcxx_supports_cxx11_abi=_DUMMY_"
generators = "cmake"
exports = "conan_*", "ci_utils/*"
exports_sources = "src/*", "CMakeLists.txt", "cmake/*", "bitprim-databaseConfig.cmake.in", "bitprimbuildinfo.cmake", "include/*", "test/*", "tools/*"
package_files = "build/lbitprim-database.a"
build_policy = "missing"
def requirements(self):
if self.options.db == "pruned" or self.options.db == "default" or self.options.db == "full":
self.requires("lmdb/0.9.22@bitprim/stable")
if self.options.use_domain:
self.requires("boost/1.69.0@bitprim/stable")
self.requires("bitprim-domain/0.X@%s/%s" % (self.user, self.channel))
else:
self.requires("boost/1.66.0@bitprim/stable")
self.requires("bitprim-core/0.X@%s/%s" % (self.user, self.channel))
def config_options(self):
if self.settings.arch != "x86_64":
self.output.info("microarchitecture is disabled for architectures other than x86_64, your architecture: %s" % (self.settings.arch,))
self.options.remove("microarchitecture")
self.options.remove("fix_march")
if self.settings.compiler == "Visual Studio":
self.options.remove("fPIC")
if self.options.shared and self.msvc_mt_build:
self.options.remove("shared")
def configure(self):
BitprimConanFile.configure(self)
if self.settings.arch == "x86_64" and self.options.microarchitecture == "_DUMMY_":
del self.options.fix_march
# self.options.remove("fix_march")
# raise Exception ("fix_march option is for using together with microarchitecture option.")
if self.settings.arch == "x86_64":
march_conan_manip(self)
self.options["*"].microarchitecture = self.options.microarchitecture
self.options["*"].cached_rpc_data = self.options.cached_rpc_data
self.options["*"].measurements = self.options.measurements
self.options["*"].currency = self.options.currency
self.output.info("Compiling for currency: %s" % (self.options.currency,))
self.output.info("Compiling with measurements: %s" % (self.options.measurements,))
self.output.info("Compiling for DB: %s" % (self.options.db,))
def package_id(self):
BitprimConanFile.package_id(self)
self.info.options.with_tests = "ANY"
self.info.options.with_tools = "ANY"
self.info.options.verbose = "ANY"
self.info.options.fix_march = "ANY"
self.info.options.cxxflags = "ANY"
self.info.options.cflags = "ANY"
# #For Bitprim Packages libstdc++ and libstdc++11 are the same
# if self.settings.compiler == "gcc" or self.settings.compiler == "clang":
# if str(self.settings.compiler.libcxx) == "libstdc++" or str(self.settings.compiler.libcxx) == "libstdc++11":
# self.info.settings.compiler.libcxx = "ANY"
def build(self):
cmake = CMake(self)
cmake.definitions["USE_CONAN"] = option_on_off(True)
cmake.definitions["NO_CONAN_AT_ALL"] = option_on_off(False)
cmake.verbose = self.options.verbose
cmake.definitions["ENABLE_SHARED"] = option_on_off(self.is_shared)
cmake.definitions["ENABLE_POSITION_INDEPENDENT_CODE"] = option_on_off(self.fPIC_enabled)
cmake.definitions["WITH_TESTS"] = option_on_off(self.options.with_tests)
cmake.definitions["WITH_TOOLS"] = option_on_off(self.options.with_tools)
cmake.definitions["CURRENCY"] = self.options.currency
cmake.definitions["WITH_MEASUREMENTS"] = option_on_off(self.options.measurements)
cmake.definitions["USE_DOMAIN"] = option_on_off(self.options.use_domain)
cmake.definitions["WITH_CACHED_RPC_DATA"] = option_on_off(self.options.cached_rpc_data)
if self.options.db == "legacy":
cmake.definitions["DB_TRANSACTION_UNCONFIRMED"] = option_on_off(False)
cmake.definitions["DB_SPENDS"] = option_on_off(False)
cmake.definitions["DB_HISTORY"] = option_on_off(False)
cmake.definitions["DB_STEALTH"] = option_on_off(False)
cmake.definitions["DB_UNSPENT_LIBBITCOIN"] = option_on_off(True)
cmake.definitions["DB_LEGACY"] = option_on_off(True)
cmake.definitions["DB_NEW"] = option_on_off(False)
cmake.definitions["DB_NEW_BLOCKS"] = option_on_off(False)
cmake.definitions["DB_NEW_FULL"] = option_on_off(False)
elif self.options.db == "legacy_full":
cmake.definitions["DB_TRANSACTION_UNCONFIRMED"] = option_on_off(True)
cmake.definitions["DB_SPENDS"] = option_on_off(True)
cmake.definitions["DB_HISTORY"] = option_on_off(True)
cmake.definitions["DB_STEALTH"] = option_on_off(True)
cmake.definitions["DB_UNSPENT_LIBBITCOIN"] = option_on_off(True)
cmake.definitions["DB_LEGACY"] = option_on_off(True)
cmake.definitions["DB_NEW"] = option_on_off(False)
cmake.definitions["DB_NEW_BLOCKS"] = option_on_off(False)
cmake.definitions["DB_NEW_FULL"] = option_on_off(False)
elif self.options.db == "pruned":
cmake.definitions["DB_TRANSACTION_UNCONFIRMED"] = option_on_off(False)
cmake.definitions["DB_SPENDS"] = option_on_off(False)
cmake.definitions["DB_HISTORY"] = option_on_off(False)
cmake.definitions["DB_STEALTH"] = option_on_off(False)
cmake.definitions["DB_UNSPENT_LIBBITCOIN"] = option_on_off(False)
cmake.definitions["DB_LEGACY"] = option_on_off(False)
cmake.definitions["DB_NEW"] = option_on_off(True)
cmake.definitions["DB_NEW_BLOCKS"] = option_on_off(False)
cmake.definitions["DB_NEW_FULL"] = option_on_off(False)
elif self.options.db == "default":
cmake.definitions["DB_TRANSACTION_UNCONFIRMED"] = option_on_off(False)
cmake.definitions["DB_SPENDS"] = option_on_off(False)
cmake.definitions["DB_HISTORY"] = option_on_off(False)
cmake.definitions["DB_STEALTH"] = option_on_off(False)
cmake.definitions["DB_UNSPENT_LIBBITCOIN"] = option_on_off(False)
cmake.definitions["DB_LEGACY"] = option_on_off(False)
cmake.definitions["DB_NEW"] = option_on_off(True)
cmake.definitions["DB_NEW_BLOCKS"] = option_on_off(True)
cmake.definitions["DB_NEW_FULL"] = option_on_off(False)
elif self.options.db == "full":
cmake.definitions["DB_TRANSACTION_UNCONFIRMED"] = option_on_off(False)
cmake.definitions["DB_SPENDS"] = option_on_off(False)
cmake.definitions["DB_HISTORY"] = option_on_off(False)
cmake.definitions["DB_STEALTH"] = option_on_off(False)
cmake.definitions["DB_UNSPENT_LIBBITCOIN"] = option_on_off(False)
cmake.definitions["DB_LEGACY"] = option_on_off(False)
cmake.definitions["DB_NEW"] = option_on_off(True)
cmake.definitions["DB_NEW_BLOCKS"] = option_on_off(False)
cmake.definitions["DB_NEW_FULL"] = option_on_off(True)
if self.settings.compiler != "Visual Studio":
# cmake.definitions["CONAN_CXX_FLAGS"] += " -Wno-deprecated-declarations"
cmake.definitions["CONAN_CXX_FLAGS"] = cmake.definitions.get("CONAN_CXX_FLAGS", "") + " -Wno-deprecated-declarations"
if self.settings.compiler == "Visual Studio":
cmake.definitions["CONAN_CXX_FLAGS"] = cmake.definitions.get("CONAN_CXX_FLAGS", "") + " /DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE"
if self.options.cxxflags != "_DUMMY_":
cmake.definitions["CONAN_CXX_FLAGS"] = cmake.definitions.get("CONAN_CXX_FLAGS", "") + " " + str(self.options.cxxflags)
if self.options.cflags != "_DUMMY_":
cmake.definitions["CONAN_C_FLAGS"] = cmake.definitions.get("CONAN_C_FLAGS", "") + " " + str(self.options.cflags)
cmake.definitions["MICROARCHITECTURE"] = self.options.microarchitecture
cmake.definitions["BITPRIM_PROJECT_VERSION"] = self.version
if self.settings.compiler == "gcc":
if float(str(self.settings.compiler.version)) >= 5:
cmake.definitions["NOT_USE_CPP11_ABI"] = option_on_off(False)
else:
cmake.definitions["NOT_USE_CPP11_ABI"] = option_on_off(True)
elif self.settings.compiler == "clang":
if str(self.settings.compiler.libcxx) == "libstdc++" or str(self.settings.compiler.libcxx) == "libstdc++11":
cmake.definitions["NOT_USE_CPP11_ABI"] = option_on_off(False)
pass_march_to_compiler(self, cmake)
cmake.configure(source_dir=self.source_folder)
cmake.build()
if self.options.with_tests:
cmake.test()
def imports(self):
self.copy("*.h", "", "include")
def package(self):
self.copy("*.h", dst="include", src="include")
self.copy("*.hpp", dst="include", src="include")
self.copy("*.ipp", dst="include", src="include")
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.dll", dst="bin", keep_path=False)
self.copy("*.dylib*", dst="lib", keep_path=False)
self.copy("*.so", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.includedirs = ['include']
self.cpp_info.libs = ["bitprim-database"]