-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconanfile.py
More file actions
176 lines (165 loc) · 6.44 KB
/
Copy pathconanfile.py
File metadata and controls
176 lines (165 loc) · 6.44 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
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.files import copy
from pathlib import Path
import os
def _read_version():
try:
return (
Path(__file__)
.parent.joinpath("VERSION")
.read_text(encoding="utf-8")
.strip()
)
except Exception:
return "0.0.0"
class AeronetConan(ConanFile):
name = "aeronet"
version = _read_version()
license = "MIT"
url = "https://github.com/sjanel/aeronet"
description = "C++23 HTTP/1.1, WebSocket and HTTP/2 server library with optional TLS (OpenSSL)"
topics = ("http", "server", "epoll", "tls", "networking")
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_openssl": [True, False],
"with_spdlog": [True, False],
"with_br": [True, False],
"with_zlib": [True, False],
"with_zlibng": [True, False],
"with_zstd": [True, False],
"with_opentelemetry": [True, False],
"with_glaze": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_openssl": False,
"with_spdlog": False,
"with_br": False,
"with_zlib": False,
"with_zlibng": True,
"with_zstd": False,
"with_opentelemetry": False,
"with_glaze": False,
}
exports_sources = (
"CMakeLists.txt",
"cmake/*",
"aeronet/*",
"examples/*",
"LICENSE",
"README.md",
"VERSION",
)
package_type = "library"
required_conan_version = ">=2.0"
def layout(self):
cmake_layout(self)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["AERONET_ENABLE_ASAN"] = "OFF"
tc.variables["AERONET_ENABLE_OPENSSL"] = (
"ON" if self.options.with_openssl else "OFF"
)
tc.variables["AERONET_ENABLE_SPDLOG"] = (
"ON" if self.options.with_spdlog else "OFF"
)
tc.variables["AERONET_ENABLE_BROTLI"] = "ON" if self.options.with_br else "OFF"
tc.variables["AERONET_ENABLE_ZLIB"] = "ON" if self.options.with_zlib else "OFF"
tc.variables["AERONET_ENABLE_ZLIBNG"] = (
"ON" if self.options.with_zlib and self.options.with_zlibng else "OFF"
)
tc.variables["AERONET_ENABLE_ZSTD"] = "ON" if self.options.with_zstd else "OFF"
tc.variables["AERONET_ENABLE_OPENTELEMETRY"] = (
"ON" if self.options.with_opentelemetry else "OFF"
)
tc.variables["AERONET_ENABLE_GLAZE"] = (
"ON" if self.options.with_glaze else "OFF"
)
# Force OFF for tests/examples in package context
tc.variables["AERONET_BUILD_TESTS"] = "OFF"
tc.variables["AERONET_BUILD_BENCHMARKS"] = "OFF"
tc.variables["AERONET_BUILD_EXAMPLES"] = "OFF"
tc.variables["AERONET_BUILD_SHARED"] = "ON" if self.options.shared else "OFF"
tc.variables["AERONET_INSTALL"] = "ON"
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cm = CMake(self)
cm.configure()
cm.build()
# Tests intentionally not part of package build (run in project CI instead)
def requirements(self):
# Prefer consuming dependency packages (portable builds) when features enabled.
# If you intend to rely purely on system packages, you can remove these.
if self.options.with_openssl:
self.requires("openssl/[~3.6]")
if self.options.with_spdlog:
self.requires("spdlog/[~1.17]")
if self.options.with_br:
self.requires("brotli/[~1.2]")
if self.options.with_zlib:
if self.options.with_zlibng:
self.requires("zlib-ng/[~2.3]")
else:
self.requires("zlib/[~1.3]")
if self.options.with_zstd:
self.requires("zstd/[~1.5]")
if self.options.with_opentelemetry:
self.requires("opentelemetry-cpp/[~1.24]")
# We prefer OTLP HTTP exporter in the codebase (otel-tracer.cpp)
# and do not currently use the gRPC exporter path. Avoid pulling
# the heavy gRPC dependency transitively. Keep protobuf since
# some opentelemetry pieces and generated protos may need it.
self.requires("protobuf/[~5.27]")
if self.options.with_glaze:
self.requires("glaze/7.0.2")
def package(self):
cm = CMake(self)
cm.install()
# Conan 2 removed self.copy(); use tools.files.copy instead.
copy(
self,
"LICENSE",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder,
)
def package_info(self):
# Core libs always present
self.cpp_info.libs = [
"aeronet",
"aeronet_http",
"aeronet_tech",
"aeronet_objects",
"aeronet_sys",
]
if self.options.with_openssl:
# TLS module built separately
self.cpp_info.libs.append("aeronet_tls")
# Provide a convenient CMake target namespace expectation
self.cpp_info.set_property("cmake_file_name", "aeronet")
self.cpp_info.set_property("cmake_target_name", "aeronet::aeronet")
if self.options.with_openssl:
self.cpp_info.requires.append("openssl::openssl")
if self.options.with_spdlog:
self.cpp_info.requires.append("spdlog::spdlog")
if self.options.with_zlib:
if self.options.with_zlibng:
self.cpp_info.requires.append("zlib-ng::zlib-ng")
else:
self.cpp_info.requires.append("zlib::zlib")
if self.options.with_zstd:
self.cpp_info.requires.append("zstd::zstd")
if self.options.with_opentelemetry:
self.cpp_info.requires.append("opentelemetry-cpp::opentelemetry-cpp")
# Protobuf is a direct requirement when OpenTelemetry support is enabled
# and some exported CMake targets / generated protos may need it. Ensure
# the Conan package_info references the protobuf requirement so Conan
# doesn't treat it as unused when creating the package.
self.cpp_info.requires.append("protobuf::protobuf")
if self.options.with_glaze:
self.cpp_info.requires.append("glaze::glaze")