@@ -141,6 +141,67 @@ def validate(self):
141141 self .validate_config_option_is_positive_number ("celix_properties_optimization_string_buffer_size" )
142142 self .validate_config_option_is_positive_number ("celix_properties_optimization_entries_buffer_size" )
143143
144+ # Helper function to safely get dependency option value
145+ def _get_dependency_option_value (self , dep_name , option_name ):
146+ """Safely get dependency option value, handling get_safe vs direct attribute access"""
147+ if dep_name in self .dependencies :
148+ dep = self .dependencies [dep_name ]
149+ # First try get_safe, if that fails try direct attribute access
150+ value = dep .options .get_safe (option_name )
151+ if value is None :
152+ # Try direct attribute access
153+ try :
154+ value = getattr (dep .options , option_name )
155+ except AttributeError :
156+ # Option does not exist
157+ return None
158+ return value
159+ return None
160+
161+ # Validate dependency shared options based on Celix options
162+ # Split OR conditions into individual checks with detailed error messages
163+ from collections import namedtuple
164+
165+ ValidationRule = namedtuple ('ValidationRule' , ['condition' , 'dep_name' , 'option_name' , 'expected_value' , 'condition_desc' ])
166+
167+ validation_rules = [
168+ ValidationRule (self .options .build_utils , 'libzip' , "shared" , True , 'build_utils=True' ),
169+ ValidationRule (self .options .build_utils , 'libuv' , "shared" , True , 'build_utils=True' ),
170+ ValidationRule (self .options .build_framework , 'util-linux-libuuid' , "shared" , True , 'build_framework=True' ),
171+ ValidationRule (self .options .build_framework and self .options .framework_curlinit , 'libcurl' , "shared" , True , 'build_framework=True and framework_curlinit=True' ),
172+ ValidationRule (self .options .build_framework and self .options .framework_curlinit , 'openssl' , "shared" , True , 'build_framework=True and framework_curlinit=True' ),
173+ ValidationRule (self .options .build_celix_etcdlib , 'libcurl' , "shared" , True , 'build_celix_etcdlib=True' ),
174+ ValidationRule (self .options .build_celix_etcdlib , 'openssl' , "shared" , True , 'build_celix_etcdlib=True' ),
175+ ValidationRule (self .options .build_rsa_discovery_common , 'libcurl' , "shared" , True , 'build_rsa_discovery_common=True' ),
176+ ValidationRule (self .options .build_rsa_discovery_common , 'openssl' , "shared" , True , 'build_rsa_discovery_common=True' ),
177+ ValidationRule (self .options .build_rsa_remote_service_admin_dfi , 'libcurl' , "shared" , True , 'build_rsa_remote_service_admin_dfi=True' ),
178+ ValidationRule (self .options .build_rsa_remote_service_admin_dfi , 'openssl' , "shared" , True , 'build_rsa_remote_service_admin_dfi=True' ),
179+ ValidationRule (self .options .build_launcher , 'libcurl' , "shared" , True , 'build_launcher=True' ),
180+ ValidationRule (self .options .build_launcher , 'openssl' , "shared" , True , 'build_launcher=True' ),
181+ ValidationRule (self .options .enable_testing , 'gtest' , "shared" , True , 'enable_testing=True' ),
182+ ValidationRule (self .options .enable_benchmarking , 'benchmark' , "shared" , True , 'enable_benchmarking=True' ),
183+ ValidationRule (self .options .build_rsa_discovery_common , 'libxml2' , "shared" , True , 'build_rsa_discovery_common=True' ),
184+ ValidationRule (self .options .build_rsa_remote_service_admin_dfi and self .options .enable_testing , 'libxml2' , "shared" , True , 'build_rsa_remote_service_admin_dfi=True and enable_testing=True' ),
185+ ValidationRule (self .options .build_http_admin , 'civetweb' , "shared" , True , 'build_http_admin=True' ),
186+ ValidationRule (self .options .build_http_admin , 'openssl' , "shared" , True , 'build_http_admin=True' ),
187+ ValidationRule (self .options .build_rsa_discovery_common , 'civetweb' , "shared" , True , 'build_rsa_discovery_common=True' ),
188+ ValidationRule (self .options .build_rsa_discovery_common , 'openssl' , "shared" , True , 'build_rsa_discovery_common=True' ),
189+ ValidationRule (self .options .build_rsa_remote_service_admin_dfi , 'civetweb' , "shared" , True , 'build_rsa_remote_service_admin_dfi=True' ),
190+ ValidationRule (self .options .build_rsa_remote_service_admin_dfi , 'openssl' , "shared" , True , 'build_rsa_remote_service_admin_dfi=True' ),
191+ ValidationRule (self .options .build_celix_dfi , 'libffi' , "shared" , True , 'build_celix_dfi=True' ),
192+ ValidationRule (self .options .build_utils , 'jansson' , "shared" , True , 'build_utils=True' ),
193+ ValidationRule (self .options .build_celix_dfi , 'jansson' , "shared" , True , 'build_celix_dfi=True' ),
194+ ValidationRule (self .options .build_celix_etcdlib , 'jansson' , "shared" , True , 'build_celix_etcdlib=True' ),
195+ ValidationRule (self .options .build_event_admin_remote_provider_mqtt , 'jansson' , "shared" , True , 'build_event_admin_remote_provider_mqtt=True' ),
196+ ValidationRule (self .options .build_event_admin_remote_provider_mqtt and self .options .enable_testing , "mosquitto" , "broker" , True , "build_event_admin_remote_provider_mqtt=True and enable_testing=True" ),
197+ ]
198+
199+ for rule in validation_rules :
200+ if rule .condition and rule .dep_name in self .dependencies :
201+ actual_value = _get_dependency_option_value (self , rule .dep_name , rule .option_name )
202+ if actual_value is not None and actual_value != rule .expected_value :
203+ raise ConanInvalidConfiguration (f"Celix configuration `{ rule .condition_desc } ` requires { rule .dep_name } /*:{ rule .option_name } ={ rule .expected_value } " )
204+
144205 def package_id (self ):
145206 del self .info .options .build_all
146207 # the followings are not installed
@@ -304,39 +365,6 @@ def configure(self):
304365 setattr (self .options , opt , options [opt ])
305366 del options
306367
307- # Conan 2 does not support set dependency option in requirements()
308- # https://github.com/conan-io/conan/issues/14528#issuecomment-1685344080
309- if self .options .build_utils :
310- self .options ['libzip' ].shared = True
311- self .options ['libuv' ].shared = True
312- if self .options .build_framework :
313- self .options ['util-linux-libuuid' ].shared = True
314- if ((self .options .build_framework and self .options .framework_curlinit )
315- or self .options .build_celix_etcdlib
316- or self .options .build_rsa_discovery_common or self .options .build_rsa_remote_service_admin_dfi
317- or self .options .build_launcher ):
318- self .options ['libcurl' ].shared = True
319- self .options ['openssl' ].shared = True
320- if self .options .enable_testing :
321- self .options ['gtest' ].shared = True
322- if self .options .enable_benchmarking :
323- self .options ['benchmark' ].shared = True
324- if (self .options .build_rsa_discovery_common
325- or (self .options .build_rsa_remote_service_admin_dfi and self .options .enable_testing )):
326- self .options ['libxml2' ].shared = True
327- if self .options .build_http_admin or self .options .build_rsa_discovery_common \
328- or self .options .build_rsa_remote_service_admin_dfi :
329- self .options ['civetweb' ].shared = True
330- self .options ['openssl' ].shared = True
331- if self .options .build_celix_dfi :
332- self .options ['libffi' ].shared = True
333- if self .options .build_utils or self .options .build_celix_dfi or self .options .build_celix_etcdlib or self .options .build_event_admin_remote_provider_mqtt :
334- self .options ['jansson' ].shared = True
335- if self .options .build_event_admin_remote_provider_mqtt :
336- self .options ['mosquitto' ].shared = True
337- if self .options .enable_testing :
338- self .options ['mosquitto' ].broker = True
339-
340368 def requirements (self ):
341369 if self .options .build_utils :
342370 self .requires ("libzip/[>=1.7.3 <2.0.0]" )
@@ -371,7 +399,7 @@ def requirements(self):
371399 self .requires ("zlib/1.3.1" , override = True )
372400 if self .options .build_event_admin_remote_provider_mqtt :
373401 self .requires ("mosquitto/[>=2.0.3 <3.0.0]" )
374- self . validate ()
402+
375403
376404 def layout (self ):
377405 cmake_layout (self )
@@ -425,7 +453,5 @@ def package_info(self):
425453 # enable imports() of conanfile.py to collect bundles from the local cache using @bindirs
426454 # check https://docs.conan.io/en/latest/reference/conanfile/methods.html#imports
427455 self .cpp_info .bindirs = ["bin" , os .path .join ("share" , self .name , "bundles" )]
428- self .cpp_info .build_modules ["cmake" ].append (os .path .join ("lib" , "cmake" , "Celix" , "CelixConfig.cmake" ))
429- self .cpp_info .build_modules ["cmake_find_package" ].append (os .path .join ("lib" , "cmake" ,
430- "Celix" , "CelixConfig.cmake" ))
431- self .cpp_info .set_property ("cmake_build_modules" , [os .path .join ("lib" , "cmake" , "Celix" , "CelixConfig.cmake" )])
456+ self .cpp_info .builddirs .append (os .path .join ("lib" , "cmake" , "Celix" ))
457+ self .cpp_info .set_property ("cmake_find_mode" , "none" )
0 commit comments