forked from apache/celix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
266 lines (251 loc) · 12.2 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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os
required_conan_version = ">=1.32.0"
class CelixConan(ConanFile):
name = "celix"
version = "2.3.0"
homepage = "https://celix.apache.org"
url = "https://github.com/apache/celix.git"
topics = ("conan", "celix", "osgi", "embedded", "linux", "C/C++")
exports_sources = "CMakeLists.txt", "bundles*", "cmake*", "!cmake-build*", "examples*", "libs*", "misc*", "LICENSE"
generators = "cmake_paths", "cmake_find_package", "virtualrunenv"
settings = "os", "arch", "compiler", "build_type"
license = " Apache-2.0"
description = "Apache Celix is an implementation of the OSGi specification adapted to C and C++ (C++17). " \
"It is a framework to develop (dynamic) modular software applications " \
"using component and/or service-oriented programming."
options = {
"enable_testing": [True, False],
"enable_code_coverage": [True, False],
"enable_address_sanitizer": [True, False],
"enable_undefined_sanitizer": [True, False],
"enable_thread_sanitizer": [True, False],
"enable_testing_dependency_manager_for_cxx11": [True, False],
"enable_testing_for_cxx14": [True, False],
"build_all": [True, False],
"build_deployment_admin": [True, False],
"build_http_admin": [True, False],
"build_log_service": [True, False],
"build_syslog_writer": [True, False],
"build_pubsub": [True, False],
"build_pubsub_psa_zmq": [True, False],
"build_pubsub_examples": [True, False],
"build_pubsub_integration": [True, False],
"build_pubsub_psa_tcp": [True, False],
"build_pubsub_psa_udp_mc": [True, False],
"build_pubsub_psa_ws": [True, False],
"build_pubsub_discovery_etcd": [True, False],
"build_cxx_remote_service_admin": [True, False],
"build_cxx_rsa_integration": [True, False],
"build_remote_service_admin": [True, False],
"build_rsa_remote_service_admin_dfi": [True, False],
"build_rsa_discovery_configured": [True, False],
"build_rsa_discovery_etcd": [True, False],
"build_rsa_remote_service_admin_shm_v2": [True, False],
"build_rsa_json_rpc": [True, False],
"build_shell": [True, False],
"build_remote_shell": [True, False],
"build_shell_bonjour": [True, False],
"build_shell_tui": [True, False],
"build_shell_wui": [True, False],
"build_examples": [True, False],
"build_celix_etcdlib": [True, False],
"build_launcher": [True, False],
"build_promises": [True, False],
"build_pushstreams": [True, False],
"build_experimental": [True, False],
"build_celix_dfi": [True, False],
"celix_cxx14": [True, False],
"celix_cxx17": [True, False],
"celix_install_deprecated_api": [True, False],
"celix_use_compression_for_bundle_zips": [True, False],
}
default_options = {
"enable_testing": False,
"enable_code_coverage": False,
"enable_address_sanitizer": False,
"enable_undefined_sanitizer": False,
"enable_thread_sanitizer": False,
"enable_testing_dependency_manager_for_cxx11": False,
"enable_testing_for_cxx14": False,
"build_all": False,
"build_deployment_admin": False,
"build_http_admin": True,
"build_log_service": True,
"build_syslog_writer": True,
"build_pubsub": True,
"build_pubsub_psa_zmq": False,
"build_pubsub_examples": False,
"build_pubsub_integration": False,
"build_pubsub_psa_tcp": False,
"build_pubsub_psa_udp_mc": False,
"build_pubsub_psa_ws": True,
"build_pubsub_discovery_etcd": False,
"build_cxx_remote_service_admin": True,
"build_cxx_rsa_integration": False,
"build_remote_service_admin": True,
"build_rsa_remote_service_admin_dfi": True,
"build_rsa_discovery_configured": True,
"build_rsa_discovery_etcd": False,
"build_rsa_remote_service_admin_shm_v2": False,
"build_rsa_json_rpc": False,
"build_shell": True,
"build_remote_shell": False,
"build_shell_bonjour": False,
"build_shell_tui": False,
"build_shell_wui": False,
"build_examples": False,
"build_celix_etcdlib": False,
"build_launcher": False,
"build_promises": False,
"build_pushstreams": False,
"build_experimental": False,
"build_celix_dfi": True,
"celix_cxx14": True,
"celix_cxx17": True,
"celix_install_deprecated_api": False,
"celix_use_compression_for_bundle_zips": True,
}
_cmake = None
def validate(self):
if self.settings.os != "Linux" and self.settings.os != "Macos":
raise ConanInvalidConfiguration("Celix is only supported for Linux/Macos")
def package_id(self):
del self.info.options.build_all
# the followings are not installed
del self.info.options.build_pubsub_integration
del self.info.options.build_pubsub_examples
del self.info.options.build_cxx_rsa_integration
del self.info.options.build_examples
del self.info.options.build_shell_bonjour
del self.info.options.enable_testing_dependency_manager_for_cxx11
del self.info.options.enable_testing_for_cxx14
def build_requirements(self):
if self.options.enable_testing:
self.test_requires("gtest/1.10.0")
self.test_requires("cpputest/4.0")
def configure(self):
if self.options.build_all:
for opt, val in self.options.values.items():
if opt.startswith('build_'):
setattr(self.options, opt, True)
if not self.options.celix_cxx14:
self.options.celix_cxx17 = False
if not self.options.celix_cxx17:
self.options.build_cxx_remote_service_admin = False
self.options.build_promises = False
self.options.build_pushstreams = False
if not self.options.build_cxx_remote_service_admin:
self.options.build_cxx_rsa_integration = False
if not self.options.enable_testing:
self.options.build_pubsub_integration = False
self.options.enable_code_coverage = False
if not self.options.build_log_service:
self.options.build_syslog_writer = False
if not self.options.build_pubsub:
self.options.build_pubsub_psa_zmq = False
self.options.build_pubsub_examples = False
self.options.build_pubsub_integration = False
self.options.build_pubsub_psa_tcp = False
self.options.build_pubsub_psa_udp_mc = False
self.options.build_pubsub_psa_ws = False
self.options.build_pubsub_discovery_etcd = False
if not self.options.build_remote_service_admin:
self.options.build_rsa_remote_service_admin_dfi = False
self.options.build_rsa_discovery_configured = False
self.options.build_rsa_discovery_etcd = False
self.options.build_rsa_json_rpc = False
if (not self.options.build_remote_service_admin) or (self.settings.os != "Linux"):
self.options.build_rsa_remote_service_admin_shm_v2 = False
if not self.options.build_shell:
self.options.build_remote_shell = False
self.options.build_shell_bonjour = False
self.options.build_shell_tui = False
self.options.build_shell_wui = False
if not self.options.celix_install_deprecated_api:
self.options.build_shell_bonjour = False
def requirements(self):
self.requires("libcurl/[>=7.64.1 <8.0.0]")
self.options['libcurl'].shared = True
self.requires("zlib/[>=1.2.8 <2.0.0]")
self.options['zlib'].shared = True
self.requires("libuuid/1.0.3")
self.options['libuuid'].shared = True
self.requires("libzip/[>=1.7.3 <2.0.0]")
self.options['libzip'].shared = True
self.options['openssl'].shared = True
self.options['libxml2'].shared = True
if self.options.enable_testing:
self.options['gtest'].shared = True
if self.options.enable_address_sanitizer:
self.options["cpputest"].with_leak_detection = False
if self.options.build_remote_service_admin or self.options.build_shell_bonjour:
self.requires("libxml2/[>=2.9.9 <3.0.0]")
if self.options.build_cxx_remote_service_admin:
self.requires("rapidjson/[>=1.1.0 <2.0.0]")
if self.options.build_shell_bonjour:
# TODO: CC=cc is fixed in the official mdnsresponder Makefile, patching is needed to make cross-compile work
# https://github.com/conan-io/conan-center-index/issues/9711
# Another issue is in conan infrastructure: https://github.com/conan-io/conan-center-index/issues/9709
self.requires("mdnsresponder/1310.140.1")
if self.options.build_pubsub_psa_zmq:
self.requires("zeromq/4.3.4")
self.options['zeromq'].shared = True
self.requires("czmq/4.2.0")
self.options['czmq'].shared = True
if self.options.build_http_admin or self.options.build_remote_service_admin:
self.requires("civetweb/1.15")
self.options['civetweb'].shared = True
if self.options.build_celix_dfi:
self.requires("libffi/[>=3.2.1 <4.0.0]")
self.options['libffi'].shared = True
if self.options.build_celix_dfi or self.options.build_celix_etcdlib:
self.requires("jansson/[>=2.12 <3.0.0]")
self.options['jansson'].shared = True
def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
for opt, val in self.options.values.items():
self._cmake.definitions[opt.upper()] = self.options.get_safe(opt, False)
self._cmake.definitions["CMAKE_PROJECT_Celix_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake")
# the following is workaround for https://github.com/conan-io/conan/issues/7192
if self.settings.os == "Linux":
self._cmake.definitions["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs"
elif self.settings.os == "Macos":
self._cmake.definitions["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,-undefined -Wl,dynamic_lookup"
self.output.info(self._cmake.definitions)
v = tools.Version(self.version)
self._cmake.configure(defs={'CELIX_MAJOR': v.major, 'CELIX_MINOR': v.minor, 'CELIX_MICRO': v.patch})
return self._cmake
def build(self):
# self._patch_sources()
cmake = self._configure_cmake()
cmake.build()
def package(self):
self.copy("LICENSE", dst="licenses", src=self.source_folder)
cmake = self._configure_cmake()
cmake.install()
def package_info(self):
# enable imports() of conanfile.py to collect bundles from the local cache using @bindirs
# check https://docs.conan.io/en/latest/reference/conanfile/methods.html#imports
self.cpp_info.bindirs = ["bin", os.path.join("share", self.name, "bundles")]
self.cpp_info.build_modules["cmake"].append(os.path.join("lib", "cmake", "Celix", "CelixConfig.cmake"))
self.cpp_info.build_modules["cmake_find_package"].append(os.path.join("lib", "cmake", "Celix", "CelixConfig.cmake"))