forked from libbitcoin/libbitcoin-node
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconanfile.py
275 lines (233 loc) · 12.9 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#
# 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/>.
#
from conans import CMake
from ci_utils import option_on_off, march_conan_manip, pass_march_to_compiler
from ci_utils import BitprimConanFile
class BitprimNodeConan(BitprimConanFile):
name = "bitprim-node"
# version = get_version()
license = "http://www.boost.org/users/license.html"
url = "https://github.com/bitprim/bitprim-node"
description = "Bitcoin full node"
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],
"currency": ['BCH', 'BTC', 'LTC'],
"microarchitecture": "ANY", #["x86_64", "haswell", "ivybridge", "sandybridge", "bulldozer", ...]
"fix_march": [True, False],
"verbose": [True, False],
"keoken": [True, False],
"mempool": [True, False],
"use_domain": [True, False],
"db": ['legacy', 'legacy_full', 'pruned', 'default', 'full'],
"cxxflags": "ANY",
"cflags": "ANY",
"glibcxx_supports_cxx11_abi": "ANY",
}
# "with_remote_blockchain": [True, False],
# "with_remote_database": [True, False],
# "with_console": [True, False],
default_options = "shared=False", \
"fPIC=True", \
"with_tests=False", \
"currency=BCH", \
"microarchitecture=_DUMMY_", \
"fix_march=False", \
"verbose=False", \
"keoken=False", \
"mempool=False", \
"use_domain=True", \
"db=default", \
"cxxflags=_DUMMY_", \
"cflags=_DUMMY_", \
"glibcxx_supports_cxx11_abi=_DUMMY_"
# "with_remote_blockchain=False", \
# "with_remote_database=False", \
# "with_console=True", \
with_remote_blockchain = False
with_remote_database = False
# with_console = False
generators = "cmake"
exports = "conan_*", "ci_utils/*"
exports_sources = "src/*", "CMakeLists.txt", "cmake/*", "bitprim-nodeConfig.cmake.in", "bitprimbuildinfo.cmake", "include/*", "test/*", "console/*"
package_files = "build/lbitprim-node.a"
build_policy = "missing"
@property
def is_keoken(self):
return self.options.currency == "BCH" and self.options.get_safe("keoken")
def requirements(self):
if self.options.use_domain:
self.requires("boost/1.69.0@bitprim/stable")
else:
self.requires("boost/1.66.0@bitprim/stable")
self.requires("bitprim-blockchain/0.X@%s/%s" % (self.user, self.channel))
self.requires("bitprim-network/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
if self.options.keoken and self.options.currency != "BCH":
self.output.warn("For the moment Keoken is only enabled for BCH. Building without Keoken support...")
del self.options.keoken
else:
self.options["*"].keoken = self.options.keoken
if self.is_keoken:
if self.options.db == "pruned" or self.options.db == "default":
self.output.warn("Keoken mode requires db=full and your configuration is db=%s, it has been changed automatically..." % (self.options.db,))
self.options.db = "full"
self.options["*"].db = self.options.db
self.options["*"].use_domain = self.options.use_domain
self.options["*"].mempool = self.options.mempool
self.options["*"].currency = self.options.currency
self.output.info("Compiling for currency: %s" % (self.options.currency,))
self.output.info("Compiling with mempool: %s" % (self.options.mempool,))
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.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_REMOTE_BLOCKCHAIN"] = option_on_off(self.with_remote_blockchain)
cmake.definitions["WITH_REMOTE_DATABASE"] = option_on_off(self.with_remote_database)
cmake.definitions["WITH_TESTS"] = option_on_off(self.options.with_tests)
# cmake.definitions["WITH_CONSOLE"] = option_on_off(self.with_console)
cmake.definitions["CURRENCY"] = self.options.currency
cmake.definitions["WITH_KEOKEN"] = option_on_off(self.is_keoken)
cmake.definitions["WITH_MEMPOOL"] = option_on_off(self.options.mempool)
cmake.definitions["USE_DOMAIN"] = option_on_off(self.options.use_domain)
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"] = 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.settings.compiler != "Visual Studio":
cmake.definitions["CONAN_CXX_FLAGS"] = cmake.definitions.get("CONAN_CXX_FLAGS", "") + " -Wno-inconsistent-missing-override"
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
#TODO(bitprim): compare with the other project to see if this could be deleted!
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-node"]