-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
191 lines (150 loc) · 7.04 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
# Copyright (c) 2016-2024 Knuth Project developers.
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
import os
from conan.tools.build.cppstd import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, cmake_layout
from conan.tools.files import copy
from kthbuild import KnuthConanFileV2, option_on_off
required_conan_version = ">=2.0"
class KnuthInfrastructureConan(KnuthConanFileV2):
name = "infrastructure"
license = "http://www.boost.org/users/license.html"
url = "https://github.com/knuth/infrastructure"
description = "Multicrypto Cross-Platform C++ Development Toolkit"
settings = "os", "compiler", "build_type", "arch"
package_type = "library"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_icu": [True, False],
"with_png": [True, False],
"with_qrencode": [True, False],
"tests": [True, False],
"examples": [True, False],
"march_id": ["ANY"],
"march_strategy": ["download_if_possible", "optimized", "download_or_fail"],
"verbose": [True, False],
"cxxflags": ["ANY"],
"cflags": ["ANY"],
"cmake_export_compile_commands": [True, False],
"log": ["spdlog", "binlog"],
"asio_standalone": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_icu": False,
"with_png": False,
"with_qrencode": False,
"tests": False,
"examples": False,
"march_strategy": "download_if_possible",
"verbose": False,
"cmake_export_compile_commands": False,
"log": "spdlog",
"asio_standalone": False,
}
exports_sources = "src/*", "CMakeLists.txt", "ci_utils/cmake/*", "cmake/*", "include/*", "test/*", "examples/*", "test_new/*"
def build_requirements(self):
if self.options.tests:
self.test_requires("catch2/3.6.0")
def requirements(self):
self.requires("secp256k1/0.21.0", transitive_headers=True, transitive_libs=True)
self.requires("boost/1.86.0", transitive_headers=True, transitive_libs=True)
self.requires("fmt/11.0.2", transitive_headers=True, transitive_libs=True)
self.requires("expected-lite/0.8.0", transitive_headers=True, transitive_libs=True)
self.requires("ctre/3.9.0", transitive_headers=True, transitive_libs=True)
if self.options.log == "binlog":
self.requires("binlog/2020.02.29@kth/stable", transitive_headers=True, transitive_libs=True)
elif self.options.log == "spdlog":
self.requires("spdlog/1.15.0", transitive_headers=True, transitive_libs=True)
if self.options.with_png:
self.requires("libpng/1.6.40", transitive_headers=True, transitive_libs=True)
if self.options.with_qrencode:
self.requires("libqrencode/4.1.1", transitive_headers=True, transitive_libs=True)
if self.options.asio_standalone:
self.requires("asio/1.28.1", transitive_headers=True, transitive_libs=True)
def validate(self):
KnuthConanFileV2.validate(self)
if self.info.settings.compiler.cppstd:
check_min_cppstd(self, "23")
def config_options(self):
KnuthConanFileV2.config_options(self)
def configure(self):
# self.output.info("libcxx: %s" % (str(self.settings.compiler.libcxx),))
KnuthConanFileV2.configure(self)
self.options["fmt/*"].header_only = True
if self.settings.os == "Emscripten":
self.options["boost/*"].header_only = True
if self.options.log == "spdlog":
self.options["spdlog/*"].header_only = True
# if self.options.log != "boost":
# self.options["boost"].without_filesystem = True
# self.options["boost"].without_log = True
# self.options["*"].log = self.options.log
self.output.info("Compiling with log: %s" % (self.options.log,))
def package_id(self):
KnuthConanFileV2.package_id(self)
def layout(self):
cmake_layout(self)
def generate(self):
tc = self.cmake_toolchain_basis()
# tc.variables["CMAKE_VERBOSE_MAKEFILE"] = True
tc.variables["WITH_ICU"] = option_on_off(self.options.with_icu)
# tc.variables["WITH_QRENCODE"] = option_on_off(self.options.with_qrencode)
# tc.variables["WITH_PNG"] = option_on_off(self.options.with_qrencode)
tc.variables["WITH_QRENCODE"] = option_on_off(self.options.with_qrencode)
tc.variables["WITH_PNG"] = option_on_off(self.options.with_png)
tc.variables["LOG_LIBRARY"] = self.options.log
tc.variables["CONAN_DISABLE_CHECK_COMPILER"] = option_on_off(True)
tc.generate()
tc = CMakeDeps(self)
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
if not self.options.cmake_export_compile_commands:
cmake.build()
#Note: Cmake Tests and Visual Studio doesn't work
if self.options.tests:
cmake.test()
# cmake.test(target="tests")
# def imports(self):
# self.copy("*.h", "", "include")
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.includedirs = ['include']
self.cpp_info.libs = ["infrastructure"]
...
# self.cpp_info.requires = ["boost::program_options",
# "boost::thread",
# "secp256k1::secp256k1",
# "spdlog::spdlog",
# "fmt::fmt",
# "expected-lite::expected-lite",
# "ctre::ctre"
# ]
self.cpp_info.requires = ["secp256k1::secp256k1",
"spdlog::spdlog",
"fmt::fmt",
"expected-lite::expected-lite",
"ctre::ctre"
]
if self.settings.os != "Emscripten":
self.cpp_info.requires.append("boost::program_options")
self.cpp_info.requires.append("boost::thread")
else:
self.cpp_info.requires.append("boost::boost")
#TODO(fernando): add the rest of the conditional dependencies
if self.settings.os == "Linux" or self.settings.os == "FreeBSD" or self.settings.os == "Emscripten":
self.cpp_info.system_libs.append("pthread")
if self.settings.os == "Linux" and self.settings.compiler == "gcc" and float(str(self.settings.compiler.version)) <= 8:
self.cpp_info.system_libs.append("stdc++fs")
if self.settings.os == "Windows" and self.settings.compiler == "gcc": # MinGW
self.cpp_info.system_libs.append("ws2_32")
self.cpp_info.system_libs.append("wsock32")
if not self.is_shared:
self.cpp_info.defines.append("KI_STATIC")