forked from libbitcoin/libbitcoin-network
-
Notifications
You must be signed in to change notification settings - Fork 3
/
conanfile.py
179 lines (146 loc) · 7.6 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
#
# 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 BitprimNetworkConan(BitprimConanFile):
name = "bitprim-network"
# version = get_version()
license = "http://www.boost.org/users/license.html"
url = "https://github.com/bitprim/bitprim-network"
description = "Bitcoin P2P Network Library"
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],
"use_domain": [True, False],
"cxxflags": "ANY",
"cflags": "ANY",
"glibcxx_supports_cxx11_abi": "ANY",
}
default_options = "shared=False", \
"fPIC=True", \
"with_tests=False", \
"currency=BCH", \
"microarchitecture=_DUMMY_", \
"fix_march=False", \
"verbose=False", \
"use_domain=True", \
"cxxflags=_DUMMY_", \
"cflags=_DUMMY_", \
"glibcxx_supports_cxx11_abi=_DUMMY_"
generators = "cmake"
exports = "conan_*", "ci_utils/*"
exports_sources = "src/*", "CMakeLists.txt", "cmake/*", "bitprim-networkConfig.cmake.in", "bitprimbuildinfo.cmake", "include/*", "test/*"
package_files = "build/lbitprim-network.a"
build_policy = "missing"
def requirements(self):
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["*"].use_domain = self.options.use_domain
self.options["*"].currency = self.options.currency
self.output.info("Compiling for currency: %s" % (self.options.currency,))
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_TESTS"] = option_on_off(self.options.with_tests)
cmake.definitions["CURRENCY"] = self.options.currency
cmake.definitions["USE_DOMAIN"] = option_on_off(self.options.use_domain)
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-network"]