From 60b59416568f5143666cd6b9fc910586b8ad9649 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Sun, 20 Aug 2023 13:47:07 +0800 Subject: [PATCH 01/22] Drop generators unsupported by Conan 2.0 Drop generators unsupported by Conan 2.0 --- .../discovery_configured/CMakeLists.txt | 2 +- .../pubsub/pubsub_admin_zmq/CMakeLists.txt | 2 +- cmake/Modules/FindCppUTest.cmake | 12 ++-- cmake/Modules/FindRapidJSON.cmake | 6 +- cmake/Modules/FindZeroMQ.cmake | 6 +- cmake/Modules/Findczmq.cmake | 8 +-- cmake/Modules/Findlibzip.cmake | 6 +- conanfile.py | 55 +++++++++++-------- libs/utils/CMakeLists.txt | 16 +++--- libs/utils/error_injector/zip/CMakeLists.txt | 2 +- libs/utils/gtest/CMakeLists.txt | 2 +- 11 files changed, 62 insertions(+), 55 deletions(-) diff --git a/bundles/cxx_remote_services/discovery_configured/CMakeLists.txt b/bundles/cxx_remote_services/discovery_configured/CMakeLists.txt index 7be039705..aa894eb30 100644 --- a/bundles/cxx_remote_services/discovery_configured/CMakeLists.txt +++ b/bundles/cxx_remote_services/discovery_configured/CMakeLists.txt @@ -38,7 +38,7 @@ target_link_libraries(RsaConfiguredDiscovery PRIVATE Celix::framework Celix::rsa_spi Celix::log_helper - RapidJSON::RapidJSON + rapidjson ) target_include_directories(RsaConfiguredDiscovery PRIVATE src) diff --git a/bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt b/bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt index 1d6119512..9428a8bec 100644 --- a/bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt +++ b/bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt @@ -47,7 +47,7 @@ if (PUBSUB_PSA_ZMQ) ) target_link_libraries(celix_pubsub_admin_zmq PRIVATE - Celix::log_helper ZeroMQ::ZeroMQ czmq::czmq libuuid::libuuid ${OPTIONAL_OPENSSL_LIB}) + Celix::log_helper libzmq czmq libuuid::libuuid ${OPTIONAL_OPENSSL_LIB}) target_link_libraries(celix_pubsub_admin_zmq PRIVATE Celix::shell_api) target_link_libraries(celix_pubsub_admin_zmq PRIVATE Celix::pubsub_spi Celix::pubsub_utils) target_include_directories(celix_pubsub_admin_zmq PRIVATE src) diff --git a/cmake/Modules/FindCppUTest.cmake b/cmake/Modules/FindCppUTest.cmake index 26d14514a..8b4c54e02 100644 --- a/cmake/Modules/FindCppUTest.cmake +++ b/cmake/Modules/FindCppUTest.cmake @@ -44,18 +44,18 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(CppUTest DEFAULT_MSG CppUTest_LIBRARY CppUTest IF(CppUTest_FOUND) SET(CppUTest_LIBRARIES ${CppUTest_LIBRARY}) SET(CppUTest_INCLUDE_DIRS ${CppUTest_INCLUDE_DIR}) - if(NOT TARGET CppUTest::CppUTest) - add_library(CppUTest::CppUTest STATIC IMPORTED) - set_target_properties(CppUTest::CppUTest PROPERTIES + if(NOT TARGET CppUTest) + add_library(CppUTest STATIC IMPORTED) + set_target_properties(CppUTest PROPERTIES IMPORTED_LOCATION "${CppUTest_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${CppUTest_INCLUDE_DIR}" ) endif() SET(CppUTest_EXT_LIBRARIES ${CppUTest_EXT_LIBRARY}) SET(CppUTest_EXT_INCLUDE_DIRS ${CppUTest_EXT_INCLUDE_DIR}) - if(NOT TARGET CppUTest::CppUTestExt) - add_library(CppUTest::CppUTestExt STATIC IMPORTED) - set_target_properties(CppUTest::CppUTestExt PROPERTIES + if(NOT TARGET CppUTestExt) + add_library(CppUTestExt STATIC IMPORTED) + set_target_properties(CppUTestExt PROPERTIES IMPORTED_LOCATION "${CppUTest_EXT_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${CppUTest_EXT_INCLUDE_DIR}" ) diff --git a/cmake/Modules/FindRapidJSON.cmake b/cmake/Modules/FindRapidJSON.cmake index b31f0b2d7..083d9c41b 100644 --- a/cmake/Modules/FindRapidJSON.cmake +++ b/cmake/Modules/FindRapidJSON.cmake @@ -28,8 +28,8 @@ find_package_handle_standard_args(RapidJSON DEFAULT_MSG mark_as_advanced(RapidJSON_INCLUDE_DIR) -if(RapidJSON_FOUND AND NOT TARGET RapidJSON::RapidJSON) - add_library(RapidJSON::RapidJSON INTERFACE IMPORTED) - set_target_properties(RapidJSON::RapidJSON PROPERTIES INTERFACE_INCLUDE_DIRECTORIES +if(RapidJSON_FOUND AND NOT TARGET rapidjson) + add_library(rapidjson INTERFACE IMPORTED) + set_target_properties(rapidjson PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${RapidJSON_INCLUDE_DIRS}") endif() diff --git a/cmake/Modules/FindZeroMQ.cmake b/cmake/Modules/FindZeroMQ.cmake index ca0f5d524..e6f5d0215 100644 --- a/cmake/Modules/FindZeroMQ.cmake +++ b/cmake/Modules/FindZeroMQ.cmake @@ -42,9 +42,9 @@ find_package_handle_standard_args(ZeroMQ DEFAULT_MSG mark_as_advanced(ZEROMQ_INCLUDE_DIR ZEROMQ_LIBRARY ) -if (ZeroMQ_FOUND AND NOT TARGET ZeroMQ::ZeroMQ) - add_library(ZeroMQ::ZeroMQ SHARED IMPORTED) - set_target_properties(ZeroMQ::ZeroMQ PROPERTIES +if (ZeroMQ_FOUND AND NOT TARGET libzmq) + add_library(libzmq SHARED IMPORTED) + set_target_properties(libzmq PROPERTIES IMPORTED_LOCATION "${ZEROMQ_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${ZEROMQ_INCLUDE_DIR}" ) diff --git a/cmake/Modules/Findczmq.cmake b/cmake/Modules/Findczmq.cmake index 2cc5a05a0..8a3edf5b8 100644 --- a/cmake/Modules/Findczmq.cmake +++ b/cmake/Modules/Findczmq.cmake @@ -22,7 +22,7 @@ # CZMQ_INCLUDE_DIRS - The czmq include directories # CZMQ_LIBRARIES - The libraries needed to use czmq # CZMQ_DEFINITIONS - Compiler switches required for using czmq -# czmq::czmq - Imported CMake target for the library (include path + library) +# czmq - Imported CMake target for the library (include path + library) find_path(CZMQ_INCLUDE_DIR czmq.h /usr/include @@ -42,9 +42,9 @@ find_package_handle_standard_args(czmq DEFAULT_MSG mark_as_advanced(CZMQ_INCLUDE_DIR CZMQ_LIBRARY) -if (czmq_FOUND AND NOT TARGET czmq::czmq) - add_library(czmq::czmq SHARED IMPORTED) - set_target_properties(czmq::czmq PROPERTIES +if (czmq_FOUND AND NOT TARGET czmq) + add_library(czmq SHARED IMPORTED) + set_target_properties(czmq PROPERTIES IMPORTED_LOCATION "${CZMQ_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${CZMQ_INCLUDE_DIR}" ) diff --git a/cmake/Modules/Findlibzip.cmake b/cmake/Modules/Findlibzip.cmake index 0d67aee47..5cf2725c3 100644 --- a/cmake/Modules/Findlibzip.cmake +++ b/cmake/Modules/Findlibzip.cmake @@ -37,9 +37,9 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(libzip DEFAULT_MSG LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR) -if(libzip_FOUND AND NOT TARGET libzip::libzip) - add_library(libzip::libzip IMPORTED STATIC GLOBAL) - set_target_properties(libzip::libzip PROPERTIES +if(libzip_FOUND AND NOT TARGET libzip::zip) + add_library(libzip::zip IMPORTED STATIC GLOBAL) + set_target_properties(libzip::zip PROPERTIES IMPORTED_LOCATION "${LIBZIP_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${LIBZIP_INCLUDE_DIR}" ) diff --git a/conanfile.py b/conanfile.py index 622a34a0d..a98a42943 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,8 +15,10 @@ # specific language governing permissions and limitations # under the License. -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile, tools +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain +from conan.tools.scm import Version import os @@ -30,14 +32,14 @@ class CelixConan(ConanFile): 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" + generators = "CMakeDeps", "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 = { + _celix_options = { "enable_testing": [True, False], "enable_code_coverage": [True, False], "enable_address_sanitizer": [True, False], @@ -97,11 +99,13 @@ class CelixConan(ConanFile): "celix_cxx17": [True, False], "celix_install_deprecated_api": [True, False], "celix_use_compression_for_bundle_zips": [True, False], - "celix_err_buffer_size": "ANY", + "celix_err_buffer_size": ["ANY"], "enable_cmake_warning_tests": [True, False], "enable_testing_on_ci": [True, False], "framework_curlinit": [True, False], } + + options = _celix_options default_options = { "enable_testing": False, "enable_code_coverage": False, @@ -209,7 +213,7 @@ def build_requirements(self): def configure(self): if self.options.build_all: - for opt, val in self.options.values.items(): + for opt in self._celix_options.keys(): if opt.startswith('build_'): setattr(self.options, opt, True) @@ -427,29 +431,32 @@ def requirements(self): self.requires("mdnsresponder/1310.140.1") self.validate() - def _enable_error_injectors(self): - for k in self.deps_cpp_info.deps: - if k == "mdnsresponder": - self._cmake.definitions["BUILD_ERROR_INJECTOR_MDNSRESPONDER"] = "ON" + def generate(self): + tc = CMakeToolchain(self) + for opt in self._celix_options.keys(): + tc.cache_variables[opt.upper()] = self.options.get_safe(opt, False) + if self.options.enable_testing: + for k in self.deps_cpp_info.deps: + if k == "mdnsresponder": + tc.cache_variables["BUILD_ERROR_INJECTOR_MDNSRESPONDER"] = "ON" + tc.cache_variables["CELIX_ERR_BUFFER_SIZE"] = self.options.celix_err_buffer_size + # tc.cache_variables["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": + tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs" + elif self.settings.os == "Macos": + tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,-undefined -Wl,dynamic_lookup" + v = Version(self.version) + tc.cache_variables["CELIX_MAJOR"] = v.major.value + tc.cache_variables["CELIX_MINOR"] = v.minor.value + tc.cache_variables["CELIX_MICRO"] = v.patch.value + tc.generate() 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) - if self.options.enable_testing: - self._enable_error_injectors() - self._cmake.definitions["CELIX_ERR_BUFFER_SIZE"] = self.options.celix_err_buffer_size - 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}) + self._cmake.configure() return self._cmake def build(self): diff --git a/libs/utils/CMakeLists.txt b/libs/utils/CMakeLists.txt index d22ebae7f..9ee10c323 100644 --- a/libs/utils/CMakeLists.txt +++ b/libs/utils/CMakeLists.txt @@ -52,7 +52,7 @@ if (UTILS) src/celix_cleanup.c ${MEMSTREAM_SOURCES} ) - set(UTILS_PRIVATE_DEPS libzip::libzip) + set(UTILS_PRIVATE_DEPS libzip::zip) set(UTILS_PUBLIC_DEPS) add_library(utils SHARED ${UTILS_SRC}) @@ -140,33 +140,33 @@ if (UTILS) add_executable(hash_map_test private/test/hash_map_test.cpp) target_include_directories(hash_map_test PRIVATE include_deprecated) - target_link_libraries(hash_map_test utils_cut CppUTest::CppUTest pthread) + target_link_libraries(hash_map_test utils_cut CppUTest pthread) add_executable(array_list_test private/test/array_list_test.cpp) target_include_directories(array_list_test PRIVATE include_deprecated) - target_link_libraries(array_list_test utils_cut CppUTest::CppUTest pthread) + target_link_libraries(array_list_test utils_cut CppUTest pthread) add_executable(linked_list_test private/test/linked_list_test.cpp) target_include_directories(linked_list_test PRIVATE include_deprecated) - target_link_libraries(linked_list_test utils_cut CppUTest::CppUTest pthread) + target_link_libraries(linked_list_test utils_cut CppUTest pthread) add_executable(properties_test private/test/properties_test.cpp) target_include_directories(properties_test PRIVATE include_deprecated) - target_link_libraries(properties_test CppUTest::CppUTest CppUTest::CppUTestExt utils_cut pthread) + target_link_libraries(properties_test CppUTest CppUTestExt utils_cut pthread) add_executable(ip_utils_test private/test/ip_utils_test.cpp) target_include_directories(ip_utils_test PRIVATE include_deprecated) - target_link_libraries(ip_utils_test CppUTest::CppUTest utils_cut pthread) + target_link_libraries(ip_utils_test CppUTest utils_cut pthread) add_executable(version_test private/test/version_test.cpp) target_include_directories(version_test PRIVATE include_deprecated) - target_link_libraries(version_test CppUTest::CppUTest utils_cut pthread) + target_link_libraries(version_test CppUTest utils_cut pthread) if (LINKER_WRAP_SUPPORTED) add_executable(version_ei_test private/test/version_ei_test.cc) target_include_directories(version_ei_test PRIVATE include_deprecated) - target_link_libraries(version_ei_test CppUTest::CppUTest utils_cut Celix::malloc_ei Celix::utils_ei pthread) + target_link_libraries(version_ei_test CppUTest utils_cut Celix::malloc_ei Celix::utils_ei pthread) add_test(NAME version_ei_test COMMAND version_ei_test) endif () diff --git a/libs/utils/error_injector/zip/CMakeLists.txt b/libs/utils/error_injector/zip/CMakeLists.txt index 858737564..f07c24362 100644 --- a/libs/utils/error_injector/zip/CMakeLists.txt +++ b/libs/utils/error_injector/zip/CMakeLists.txt @@ -19,7 +19,7 @@ find_package(libzip REQUIRED) add_library(zip_ei STATIC src/zip_ei.cc) target_include_directories(zip_ei PUBLIC include) -target_link_libraries(zip_ei PUBLIC Celix::error_injector libzip::libzip) +target_link_libraries(zip_ei PUBLIC Celix::error_injector libzip::zip) # It plays nicely with address sanitizer this way. target_link_options(zip_ei INTERFACE diff --git a/libs/utils/gtest/CMakeLists.txt b/libs/utils/gtest/CMakeLists.txt index f4c776cc4..3ff391bdb 100644 --- a/libs/utils/gtest/CMakeLists.txt +++ b/libs/utils/gtest/CMakeLists.txt @@ -41,7 +41,7 @@ add_executable(test_utils ${CELIX_UTIL_TEST_SOURCES_FOR_CXX_HEADERS} ) -target_link_libraries(test_utils PRIVATE utils_cut Celix::utils GTest::gtest GTest::gtest_main libzip::libzip) +target_link_libraries(test_utils PRIVATE utils_cut Celix::utils GTest::gtest GTest::gtest_main libzip::zip) target_include_directories(test_utils PRIVATE ../src) #for version_private (needs refactoring of test) celix_deprecated_utils_headers(test_utils) From 2e42f25ad95a0f45f053934fed48e2ea04fdf95e Mon Sep 17 00:00:00 2001 From: PengZheng Date: Sun, 20 Aug 2023 20:35:10 +0800 Subject: [PATCH 02/22] Use conan2's conanrun.sh --- .github/workflows/coverage.yml | 4 ++-- .github/workflows/macos.yml | 4 ++-- .github/workflows/ubuntu.yml | 4 ++-- documents/building/dev_celix_with_clion.md | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5e1c0d27b..045c3dff3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -38,9 +38,9 @@ jobs: - name: Test with coverage run: | cd build - source activate_run.sh + source conanrun.sh make coverage - source deactivate_run.sh + source deactivate_conanrun.sh lcx="lcov --output-file=coverage.info " && for i in `find . -name "*.info.cleaned"`; do lcx+=" --add-tracefile=$i"; done && $lcx - name: Codecov uses: codecov/codecov-action@e156083f13aff6830c92fc5faa23505779fbf649 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b2feb2764..189433512 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -44,9 +44,9 @@ jobs: - name: Test run: | cd build - source activate_run.sh + source conanrun.sh ctest --output-on-failure - source deactivate_run.sh + source deactivate_conanrun.sh macos-build-brew: runs-on: macOS-latest diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 3f2dc9da7..85869deb5 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -67,9 +67,9 @@ jobs: - name: Test run: | cd build - source activate_run.sh + source conanrun.sh ctest --output-on-failure - source deactivate_run.sh + source deactivate_conanrun.sh linux-build-apt: runs-on: ubuntu-22.04 diff --git a/documents/building/dev_celix_with_clion.md b/documents/building/dev_celix_with_clion.md index d6c1b926f..8de4c6d35 100644 --- a/documents/building/dev_celix_with_clion.md +++ b/documents/building/dev_celix_with_clion.md @@ -23,7 +23,7 @@ limitations under the License. Apache Celix can be build for development in CLion with use of the Conan package manager. Conan will arrange the building of the Apache Celix dependencies and generate Find files for these dependencies. -Conan will also generate a `active_run.sh` and `deactivate_run.sh` script that does the environment (de)setup for the +Conan will also generate a `conanrun.sh` and `deactivate_conanrun.sh` script that does the environment (de)setup for the binary locations of the build dependencies (i.e. configures `PATH` and `LD_LIBRARY_PATH`/`DYLD_LIBRARY_PATH`). ## Configuring CLion for C++17 @@ -54,9 +54,9 @@ cd cmake-build-debug make -j #optional setup run env and run tests -source activate_run.sh +source conanrun.sh ctest --verbose -source deactivate_run.sh +source deactivate_conanrun.sh ``` ## Configuring CLion From 93d93ec2c29913dfaf08032eb25984664b310a53 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Sun, 20 Aug 2023 21:17:43 +0800 Subject: [PATCH 03/22] Stop gap for #618 --- bundles/remote_services/discovery_zeroconf/gtest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/remote_services/discovery_zeroconf/gtest/CMakeLists.txt b/bundles/remote_services/discovery_zeroconf/gtest/CMakeLists.txt index 9a7ba819b..44b23a05b 100644 --- a/bundles/remote_services/discovery_zeroconf/gtest/CMakeLists.txt +++ b/bundles/remote_services/discovery_zeroconf/gtest/CMakeLists.txt @@ -64,7 +64,7 @@ if (LINKER_WRAP_SUPPORTED) GTest::gtest_main ) - target_compile_definitions(unit_test_discovery_zeroconf PRIVATE -DMDNSD="${DNSSD_LIB_DIRS}/../bin/mdnsd") + target_compile_definitions(unit_test_discovery_zeroconf PRIVATE -DMDNSD="${DNSSD_INCLUDE_DIR}/../bin/mdnsd") add_test(NAME run_unit_test_discovery_zeroconf COMMAND sudo $) From 949ec5dc6fb68a0efc265e14ce1806916ddb1b6f Mon Sep 17 00:00:00 2001 From: PengZheng Date: Mon, 21 Aug 2023 14:18:47 +0800 Subject: [PATCH 04/22] Specify dependency options in a way compatible with both Conan1 and Conan2. --- conanfile.py | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/conanfile.py b/conanfile.py index a98a42943..1c59a7efb 100644 --- a/conanfile.py +++ b/conanfile.py @@ -385,46 +385,62 @@ def configure(self): if self.options.celix_cxx17: self.options.celix_cxx14 = True - def requirements(self): + # Once we drop Conan1 support, the following could be merged into requirements() + # https://github.com/conan-io/conan/issues/14528#issuecomment-1685344080 if self.options.build_utils: - self.requires("libzip/[>=1.7.3 <2.0.0]") self.options['libzip'].shared = True if self.options.build_framework or self.options.build_pubsub: - self.requires("util-linux-libuuid/2.39") self.options['util-linux-libuuid'].shared = True if ((self.options.build_framework and self.options.framework_curlinit) or self.options.build_celix_etcdlib or self.options.build_deployment_admin or self.options.build_rsa_discovery_common or self.options.build_rsa_remote_service_admin_dfi or self.options.build_launcher): - self.requires("libcurl/[>=7.64.1 <8.0.0]") self.options['libcurl'].shared = True if self.options.build_deployment_admin: - self.requires("zlib/[>=1.2.8 <2.0.0]") self.options['zlib'].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_rsa_discovery_common or self.options.build_shell_bonjour: - self.requires("libxml2/[>=2.9.9 <3.0.0]") self.options['libxml2'].shared = True + if self.options.build_pubsub_psa_zmq: + self.options['zeromq'].shared = True + self.options['czmq'].shared = True + if self.options.build_http_admin or self.options.build_rsa_discovery_common \ + or self.options.build_rsa_remote_service_admin_dfi: + self.options['civetweb'].shared = True + if self.options.build_celix_dfi: + self.options['libffi'].shared = True + if self.options.build_celix_dfi or self.options.build_celix_etcdlib: + self.options['jansson'].shared = True + + def requirements(self): + if self.options.build_utils: + self.requires("libzip/[>=1.7.3 <2.0.0]") + if self.options.build_framework or self.options.build_pubsub: + self.requires("util-linux-libuuid/2.39") + if ((self.options.build_framework and self.options.framework_curlinit) + or self.options.build_celix_etcdlib or self.options.build_deployment_admin + or self.options.build_rsa_discovery_common or self.options.build_rsa_remote_service_admin_dfi + or self.options.build_launcher): + self.requires("libcurl/[>=7.64.1 <8.0.0]") + if self.options.build_deployment_admin: + self.requires("zlib/[>=1.2.8 <2.0.0]") + if self.options.build_rsa_discovery_common 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_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_rsa_discovery_common \ or self.options.build_rsa_remote_service_admin_dfi: 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 if self.options.build_rsa_discovery_zeroconf or self.options.build_shell_bonjour: # TODO: To be replaced with mdnsresponder/1790.80.10, resolve some problems of mdnsresponder # https://github.com/conan-io/conan-center-index/pull/16254 From 6d25aa626335d7ccaa4a83520289b0760f8aa8e3 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Mon, 21 Aug 2023 19:07:28 +0800 Subject: [PATCH 05/22] Implement dynamic defaults. Dynamic defaults is unsupported by Conan2 according to https://github.com/conan-io/conan/issues/14528 --- conanfile.py | 332 ++++++++++++++++++++++++++------------------------- 1 file changed, 171 insertions(+), 161 deletions(-) diff --git a/conanfile.py b/conanfile.py index 1c59a7efb..718a45803 100644 --- a/conanfile.py +++ b/conanfile.py @@ -104,9 +104,7 @@ class CelixConan(ConanFile): "enable_testing_on_ci": [True, False], "framework_curlinit": [True, False], } - - options = _celix_options - default_options = { + _celix_defaults = { "enable_testing": False, "enable_code_coverage": False, "enable_address_sanitizer": False, @@ -171,6 +169,8 @@ class CelixConan(ConanFile): "enable_testing_on_ci": False, "framework_curlinit": True, } + + options = _celix_options _cmake = None def validate(self): @@ -212,178 +212,188 @@ def build_requirements(self): self.test_requires("cpputest/4.0") def configure(self): - if self.options.build_all: - for opt in self._celix_options.keys(): + # copy options to _celix_options, fill in defaults if not set + options = {} + for opt in self._celix_options.keys(): + options[opt] = self.options.get_safe(opt).value + if options[opt] is None: + options[opt] = self._celix_defaults[opt] + + if options["build_all"]: + for opt in options.keys(): if opt.startswith('build_'): - setattr(self.options, opt, True) + options[opt] = True if self.settings.os != "Linux": - self.options.build_rsa_remote_service_admin_shm_v2 = False - self.options.build_rsa_discovery_zeroconf = False - self.options.build_shell_bonjour = False - - if not self.options.enable_testing: - self.options.build_pubsub_integration = False - self.options.enable_code_coverage = False - - if self.options.build_examples: - self.options.build_shell_tui = True - self.options.build_shell_wui = True - self.options.build_log_service = True - self.options.build_syslog_writer = True - - if self.options.build_shell_bonjour: - self.options.build_shell = True - - if self.options.build_deployment_admin: - self.options.build_framework = True - - if self.options.build_cxx_rsa_integration: - self.options.build_cxx_remote_service_admin = True - self.options.build_pushstreams = True - self.options.build_promises = True - self.options.build_log_helper = True - self.options.build_shell = True - self.options.build_shell_tui = True - self.options.build_shell_api = True - self.options.build_pubsub = True - self.options.build_pubsub_wire_protocol_v2 = True - self.options.build_pubsub_json_serializer = True - self.options.build_pubsub_psa_zmq = True - self.options.build_pubsub_discovery_etcd = True - - if self.options.build_pubsub_integration: - self.options.build_pubsub = True - self.options.build_shell_tui = True - self.options.build_pubsub_json_serializer = True - self.options.build_pubsub_wire_protocol_v2 = True - self.options.build_pubsub_wire_protocol_v1 = True - - if self.options.build_pubsub_examples: - self.options.build_log_service = True - self.options.build_shell_tui = True - self.options.build_pubsub_json_serializer = True - self.options.build_pubsub_discovery_etcd = True - self.options.build_pubsub_wire_protocol_v2 = True - self.options.build_pubsub_wire_protocol_v1 = True - - if self.options.build_pubsub_discovery_etcd: - self.options.build_pubsub = True - self.options.build_celix_etcdlib = True - - if self.options.build_pubsub_psa_ws: - self.options.build_http_admin = True - self.options.build_pubsub = True - - if self.options.build_pubsub_psa_zmq or self.options.build_pubsub_psa_tcp \ - or self.options.build_pubsub_psa_udp_mc: - self.options.build_pubsub = True - - if self.options.build_pubsub_wire_protocol_v1: - self.options.build_pubsub = True - - if self.options.build_pubsub_wire_protocol_v2: - self.options.build_pubsub = True - - if self.options.build_pubsub_json_serializer or self.options.build_pubsub_avrobin_serializer: - self.options.build_pubsub = True - - if self.options.build_pubsub: - self.options.build_framework = True - self.options.build_celix_dfi = True - self.options.build_shell_api = True - self.options.build_log_helper = True - self.options.celix_install_deprecated_api = True - - if self.options.build_cxx_remote_service_admin: - self.options.build_framework = True - self.options.build_log_helper = True - self.options.celix_cxx17 = True + options["build_rsa_remote_service_admin_shm_v2"] = False + options["build_rsa_discovery_zeroconf"] = False + options["build_shell_bonjour"] = False + + if not options["enable_testing"]: + options["build_pubsub_integration"] = False + options["enable_code_coverage"] = False + + if options["build_examples"]: + options["build_shell_tui"] = True + options["build_shell_wui"] = True + options["build_log_service"] = True + options["build_syslog_writer"] = True + + if options["build_shell_bonjour"]: + options["build_shell"] = True + + if options["build_deployment_admin"]: + options["build_framework"] = True + + if options["build_cxx_rsa_integration"]: + options["build_cxx_remote_service_admin"] = True + options["build_pushstreams"] = True + options["build_promises"] = True + options["build_log_helper"] = True + options["build_shell"] = True + options["build_shell_tui"] = True + options["build_shell_api"] = True + options["build_pubsub"] = True + options["build_pubsub_wire_protocol_v2"] = True + options["build_pubsub_json_serializer"] = True + options["build_pubsub_psa_zmq"] = True + options["build_pubsub_discovery_etcd"] = True + + if options["build_pubsub_integration"]: + options["build_pubsub"] = True + options["build_shell_tui"] = True + options["build_pubsub_json_serializer"] = True + options["build_pubsub_wire_protocol_v2"] = True + options["build_pubsub_wire_protocol_v1"] = True + + if options["build_pubsub_examples"]: + options["build_log_service"] = True + options["build_shell_tui"] = True + options["build_pubsub_json_serializer"] = True + options["build_pubsub_discovery_etcd"] = True + options["build_pubsub_wire_protocol_v2"] = True + options["build_pubsub_wire_protocol_v1"] = True + + if options["build_pubsub_discovery_etcd"]: + options["build_pubsub"] = True + options["build_celix_etcdlib"] = True + + if options["build_pubsub_psa_ws"]: + options["build_http_admin"] = True + options["build_pubsub"] = True + + if options["build_pubsub_psa_zmq"] or options["build_pubsub_psa_tcp"] \ + or options["build_pubsub_psa_udp_mc"]: + options["build_pubsub"] = True + + if options["build_pubsub_wire_protocol_v1"]: + options["build_pubsub"] = True + + if options["build_pubsub_wire_protocol_v2"]: + options["build_pubsub"] = True + + if options["build_pubsub_json_serializer"] or options["build_pubsub_avrobin_serializer"]: + options["build_pubsub"] = True + + if options["build_pubsub"]: + options["build_framework"] = True + options["build_celix_dfi"] = True + options["build_shell_api"] = True + options["build_log_helper"] = True + options["celix_install_deprecated_api"] = True + + if options["build_cxx_remote_service_admin"]: + options["build_framework"] = True + options["build_log_helper"] = True + options["celix_cxx17"] = True + + if options["build_rsa_discovery_etcd"]: + options["build_celix_etcdlib"] = True + options["build_rsa_discovery_common"] = True + + if options["build_rsa_discovery_configured"]: + options["build_rsa_discovery_common"] = True + + if options["build_rsa_discovery_common"] or options["build_rsa_discovery_zeroconf"] \ + or options["build_rsa_remote_service_admin_dfi"] or options["build_rsa_json_rpc"] \ + or options["build_rsa_remote_service_admin_shm_v2"]: + options["build_remote_service_admin"] = True + + if options["build_remote_service_admin"]: + options["build_framework"] = True + options["build_log_helper"] = True + options["build_celix_dfi"] = True + options["celix_install_deprecated_api"] = True + + if options["build_remote_shell"]: + options["build_shell"] = True + + if options["build_shell_wui"]: + options["build_shell"] = True + options["build_http_admin"] = True + + if options["build_shell_tui"]: + options["build_shell"] = True + + if options["build_shell"]: + options["build_shell_api"] = True + options["build_log_helper"] = True + options["build_framework"] = True + + if options["build_http_admin"]: + options["build_framework"] = True + + if options["build_syslog_writer"]: + options["build_log_service"] = True + + if options["build_log_service"]: + options["build_log_service_api"] = True + options["build_shell_api"] = True + options["build_framework"] = True + options["build_log_helper"] = True + + if options["build_shell_api"]: + options["build_utils"] = True - if self.options.build_rsa_discovery_etcd: - self.options.build_celix_etcdlib = True - self.options.build_rsa_discovery_common = True + if options["build_log_helper"]: + options["build_log_service_api"] = True + options["build_framework"] = True - if self.options.build_rsa_discovery_configured: - self.options.build_rsa_discovery_common = True + if options["build_log_service_api"]: + options["build_utils"] = True + if options["celix_install_deprecated_api"]: + options["build_framework"] = True - if self.options.build_rsa_discovery_common or self.options.build_rsa_discovery_zeroconf \ - or self.options.build_rsa_remote_service_admin_dfi or self.options.build_rsa_json_rpc \ - or self.options.build_rsa_remote_service_admin_shm_v2: - self.options.build_remote_service_admin = True + if options["build_components_ready_check"]: + options["build_framework"] = True - if self.options.build_remote_service_admin: - self.options.build_framework = True - self.options.build_log_helper = True - self.options.build_celix_dfi = True - self.options.celix_install_deprecated_api = True + if options["build_rcm"]: + options["build_utils"] = True - if self.options.build_remote_shell: - self.options.build_shell = True + if options["build_launcher"] or options["build_dependency_manager"]: + options["build_framework"] = True - if self.options.build_shell_wui: - self.options.build_shell = True - self.options.build_http_admin = True + if options["build_dependency_manager_cxx"]: + options["build_framework"] = True + options["celix_cxx14"] = True - if self.options.build_shell_tui: - self.options.build_shell = True + if options["build_celix_dfi"]: + options["build_utils"] = True - if self.options.build_shell: - self.options.build_shell_api = True - self.options.build_log_helper = True - self.options.build_framework = True + if options["build_framework"]: + options["build_utils"] = True - if self.options.build_http_admin: - self.options.build_framework = True + if options["build_pushstreams"]: + options["build_promises"] = True - if self.options.build_syslog_writer: - self.options.build_log_service = True + if options["build_promises"]: + options["celix_cxx17"] = True - if self.options.build_log_service: - self.options.build_log_service_api = True - self.options.build_shell_api = True - self.options.build_framework = True - self.options.build_log_helper = True + if options["celix_cxx17"]: + options["celix_cxx14"] = True - if self.options.build_shell_api: - self.options.build_utils = True - - if self.options.build_log_helper: - self.options.build_log_service_api = True - self.options.build_framework = True - - if self.options.build_log_service_api: - self.options.build_utils = True - if self.options.celix_install_deprecated_api: - self.options.build_framework = True - - if self.options.build_components_ready_check: - self.options.build_framework = True - - if self.options.build_rcm: - self.options.build_utils = True - - if self.options.build_launcher or self.options.build_dependency_manager: - self.options.build_framework = True - - if self.options.build_dependency_manager_cxx: - self.options.build_framework = True - self.options.celix_cxx14 = True - - if self.options.build_celix_dfi: - self.options.build_utils = True - - if self.options.build_framework: - self.options.build_utils = True - - if self.options.build_pushstreams: - self.options.build_promises = True - - if self.options.build_promises: - self.options.celix_cxx17 = True - - if self.options.celix_cxx17: - self.options.celix_cxx14 = True + for opt in self._celix_options.keys(): + setattr(self.options, opt, options[opt]) # Once we drop Conan1 support, the following could be merged into requirements() # https://github.com/conan-io/conan/issues/14528#issuecomment-1685344080 @@ -450,7 +460,7 @@ def requirements(self): def generate(self): tc = CMakeToolchain(self) for opt in self._celix_options.keys(): - tc.cache_variables[opt.upper()] = self.options.get_safe(opt, False) + tc.cache_variables[opt.upper()] = self.options.get_safe(opt, self._celix_defaults[opt]) if self.options.enable_testing: for k in self.deps_cpp_info.deps: if k == "mdnsresponder": From c181c050ebc9f4b1834e27999184d092f0a83df5 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Tue, 22 Aug 2023 15:12:30 +0800 Subject: [PATCH 06/22] Simplify options settings. --- conanfile.py | 97 +++++++++++++--------------------------------------- 1 file changed, 23 insertions(+), 74 deletions(-) diff --git a/conanfile.py b/conanfile.py index 718a45803..c13259485 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from conan import ConanFile, tools +from conan import ConanFile, conan_version from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain from conan.tools.scm import Version @@ -39,71 +39,6 @@ class CelixConan(ConanFile): "It is a framework to develop (dynamic) modular software applications " \ "using component and/or service-oriented programming." - _celix_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_log_helper": [True, False], - "build_log_service_api": [True, False], - "build_syslog_writer": [True, False], - "build_pubsub": [True, False], - "build_pubsub_wire_protocol_v1": [True, False], - "build_pubsub_wire_protocol_v2": [True, False], - "build_pubsub_json_serializer": [True, False], - "build_pubsub_avrobin_serializer": [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_common": [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_rsa_discovery_zeroconf": [True, False], - "build_shell": [True, False], - "build_shell_api": [True, False], - "build_remote_shell": [True, False], - "build_shell_bonjour": [True, False], - "build_shell_tui": [True, False], - "build_shell_wui": [True, False], - "build_components_ready_check": [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], - "build_dependency_manager": [True, False], - "build_dependency_manager_cxx": [True, False], - "build_framework": [True, False], - "build_rcm": [True, False], - "build_utils": [True, False], - "celix_cxx14": [True, False], - "celix_cxx17": [True, False], - "celix_install_deprecated_api": [True, False], - "celix_use_compression_for_bundle_zips": [True, False], - "celix_err_buffer_size": ["ANY"], - "enable_cmake_warning_tests": [True, False], - "enable_testing_on_ci": [True, False], - "framework_curlinit": [True, False], - } _celix_defaults = { "enable_testing": False, "enable_code_coverage": False, @@ -164,13 +99,21 @@ class CelixConan(ConanFile): "celix_cxx17": True, "celix_install_deprecated_api": False, "celix_use_compression_for_bundle_zips": True, - "celix_err_buffer_size": 512, "enable_cmake_warning_tests": False, "enable_testing_on_ci": False, "framework_curlinit": True, } + options = { + "celix_err_buffer_size": ["ANY"], + } + default_options = { + "celix_err_buffer_size": 512, + } + + for comp in _celix_defaults.keys(): + options[comp] = [True, False] + del comp - options = _celix_options _cmake = None def validate(self): @@ -212,9 +155,9 @@ def build_requirements(self): self.test_requires("cpputest/4.0") def configure(self): - # copy options to _celix_options, fill in defaults if not set + # copy options to options, fill in defaults if not set options = {} - for opt in self._celix_options.keys(): + for opt in self._celix_defaults.keys(): options[opt] = self.options.get_safe(opt).value if options[opt] is None: options[opt] = self._celix_defaults[opt] @@ -392,10 +335,10 @@ def configure(self): if options["celix_cxx17"]: options["celix_cxx14"] = True - for opt in self._celix_options.keys(): + for opt in self._celix_defaults.keys(): setattr(self.options, opt, options[opt]) - # Once we drop Conan1 support, the following could be merged into requirements() + # Conan 2 does not support set dependency option in requirements() # https://github.com/conan-io/conan/issues/14528#issuecomment-1685344080 if self.options.build_utils: self.options['libzip'].shared = True @@ -406,6 +349,7 @@ def configure(self): or self.options.build_rsa_discovery_common or self.options.build_rsa_remote_service_admin_dfi or self.options.build_launcher): self.options['libcurl'].shared = True + self.options['openssl'].shared = True if self.options.build_deployment_admin: self.options['zlib'].shared = True if self.options.enable_testing: @@ -420,6 +364,7 @@ def configure(self): if self.options.build_http_admin or self.options.build_rsa_discovery_common \ or self.options.build_rsa_remote_service_admin_dfi: self.options['civetweb'].shared = True + self.options['openssl'].shared = True if self.options.build_celix_dfi: self.options['libffi'].shared = True if self.options.build_celix_dfi or self.options.build_celix_etcdlib: @@ -455,12 +400,16 @@ def requirements(self): # TODO: To be replaced with mdnsresponder/1790.80.10, resolve some problems of mdnsresponder # https://github.com/conan-io/conan-center-index/pull/16254 self.requires("mdnsresponder/1310.140.1") + # A stop gap for https://github.com/conan-io/conan/issues/14535 + lst = [x.ref.name for x in self.requires.values()] + if "libcurl" in lst or "civetweb" in lst: + self.requires("openssl/1.1.1t") self.validate() def generate(self): tc = CMakeToolchain(self) - for opt in self._celix_options.keys(): - tc.cache_variables[opt.upper()] = self.options.get_safe(opt, self._celix_defaults[opt]) + for opt in self._celix_defaults.keys(): + tc.cache_variables[opt.upper()] = self.options.get_safe(opt) if self.options.enable_testing: for k in self.deps_cpp_info.deps: if k == "mdnsresponder": From 73f44eafda02a03e75e85754ba750ef1eb64c500 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Tue, 22 Aug 2023 17:56:13 +0800 Subject: [PATCH 07/22] Fix version conflict of openssl caused by civetweb. --- conanfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/conanfile.py b/conanfile.py index c13259485..d010c56af 100644 --- a/conanfile.py +++ b/conanfile.py @@ -337,6 +337,7 @@ def configure(self): for opt in self._celix_defaults.keys(): setattr(self.options, opt, options[opt]) + del options # Conan 2 does not support set dependency option in requirements() # https://github.com/conan-io/conan/issues/14528#issuecomment-1685344080 @@ -391,7 +392,7 @@ def requirements(self): self.requires("czmq/4.2.0") if self.options.build_http_admin or self.options.build_rsa_discovery_common \ or self.options.build_rsa_remote_service_admin_dfi: - self.requires("civetweb/1.15") + self.requires("civetweb/1.16") if self.options.build_celix_dfi: self.requires("libffi/[>=3.2.1 <4.0.0]") if self.options.build_celix_dfi or self.options.build_celix_etcdlib: @@ -400,10 +401,8 @@ def requirements(self): # TODO: To be replaced with mdnsresponder/1790.80.10, resolve some problems of mdnsresponder # https://github.com/conan-io/conan-center-index/pull/16254 self.requires("mdnsresponder/1310.140.1") - # A stop gap for https://github.com/conan-io/conan/issues/14535 - lst = [x.ref.name for x in self.requires.values()] - if "libcurl" in lst or "civetweb" in lst: - self.requires("openssl/1.1.1t") + # the latest civetweb (1.16) is not ready for openssl3 + self.requires("openssl/1.1.1t", override=True) self.validate() def generate(self): @@ -425,6 +424,7 @@ def generate(self): tc.cache_variables["CELIX_MAJOR"] = v.major.value tc.cache_variables["CELIX_MINOR"] = v.minor.value tc.cache_variables["CELIX_MICRO"] = v.patch.value + tc.user_presets_path = False tc.generate() def _configure_cmake(self): From 00336571046022d1d932db56befe0005cfeb45a4 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 23 Aug 2023 12:39:41 +0800 Subject: [PATCH 08/22] Add test_package for Conan2. --- conanfile.py | 4 +- examples/conan_test_package_v2/CMakeLists.txt | 19 ++ examples/conan_test_package_v2/conanfile.py | 178 ++++++++++++++++++ 3 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 examples/conan_test_package_v2/CMakeLists.txt create mode 100644 examples/conan_test_package_v2/conanfile.py diff --git a/conanfile.py b/conanfile.py index d010c56af..9c1e2c60d 100644 --- a/conanfile.py +++ b/conanfile.py @@ -19,6 +19,7 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain from conan.tools.scm import Version +from conan.tools.files import copy import os @@ -440,7 +441,7 @@ def build(self): cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self.source_folder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) cmake = self._configure_cmake() cmake.install() @@ -451,3 +452,4 @@ def package_info(self): 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")) + self.cpp_info.set_property("cmake_build_modules", [os.path.join("lib", "cmake", "Celix", "CelixConfig.cmake")]) diff --git a/examples/conan_test_package_v2/CMakeLists.txt b/examples/conan_test_package_v2/CMakeLists.txt new file mode 100644 index 000000000..6ab3a2010 --- /dev/null +++ b/examples/conan_test_package_v2/CMakeLists.txt @@ -0,0 +1,19 @@ +# 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. + +cmake_minimum_required (VERSION 3.14) +project(test_package_v2) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../conan_test_package ${CMAKE_CURRENT_BINARY_DIR}/conan_test_package) \ No newline at end of file diff --git a/examples/conan_test_package_v2/conanfile.py b/examples/conan_test_package_v2/conanfile.py new file mode 100644 index 000000000..587a6acb8 --- /dev/null +++ b/examples/conan_test_package_v2/conanfile.py @@ -0,0 +1,178 @@ +# 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 conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.build import can_run +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + celix_options = self.dependencies["celix"].options + tc.cache_variables["TEST_FRAMEWORK"] = celix_options.build_framework + tc.cache_variables["TEST_HTTP_ADMIN"] = celix_options.build_http_admin + tc.cache_variables["TEST_LOG_SERVICE"] = celix_options.build_log_service + tc.cache_variables["TEST_SYSLOG_WRITER"] = celix_options.build_syslog_writer + tc.cache_variables["TEST_PUBSUB"] = celix_options.build_pubsub + tc.cache_variables["TEST_PSA_ZMQ"] = celix_options.build_pubsub_psa_zmq + tc.cache_variables["TEST_PSA_TCP"] = celix_options.build_pubsub_psa_tcp + tc.cache_variables["TEST_PSA_UDP_MC"] = celix_options.build_pubsub_psa_udp_mc + tc.cache_variables["TEST_PSA_WS"] = celix_options.build_pubsub_psa_ws + tc.cache_variables["TEST_PSA_DISCOVERY_ETCD"] = celix_options.build_pubsub_discovery_etcd + tc.cache_variables["TEST_RSA"] = celix_options.build_remote_service_admin + tc.cache_variables["TEST_RSA_DFI"] = celix_options.build_rsa_remote_service_admin_dfi + tc.cache_variables["TEST_RSA_SHM_V2"] = celix_options.build_rsa_remote_service_admin_shm_v2 + tc.cache_variables["TEST_RSA_RPC_JSON"] = celix_options.build_rsa_json_rpc + tc.cache_variables["TEST_RSA_DISCOVERY_CONFIGURED"] = celix_options.build_rsa_discovery_configured + tc.cache_variables["TEST_RSA_DISCOVERY_ETCD"] = celix_options.build_rsa_discovery_etcd + tc.cache_variables["TEST_RSA_DISCOVERY_ZEROCONF"] = celix_options.build_rsa_discovery_zeroconf + tc.cache_variables["TEST_SHELL"] = celix_options.build_shell + if celix_options.build_shell: + tc.cache_variables["TEST_CXX_SHELL"] = celix_options.celix_cxx17 or celix_options.celix_cxx14 + tc.cache_variables["TEST_REMOTE_SHELL"] = celix_options.build_remote_shell + tc.cache_variables["TEST_SHELL_TUI"] = celix_options.build_shell_tui + tc.cache_variables["TEST_SHELL_WUI"] = celix_options.build_shell_wui + tc.cache_variables["TEST_ETCD_LIB"] = celix_options.build_celix_etcdlib + tc.cache_variables["TEST_LAUNCHER"] = celix_options.build_launcher + tc.cache_variables["TEST_PROMISES"] = celix_options.build_promises + tc.cache_variables["TEST_PUSHSTREAMS"] = celix_options.build_pushstreams + tc.cache_variables["TEST_DEPLOYMENT_ADMIN"] = celix_options.build_deployment_admin + tc.cache_variables["TEST_LOG_HELPER"] = celix_options.build_log_helper + tc.cache_variables["TEST_LOG_SERVICE_API"] = celix_options.build_log_service_api + tc.cache_variables["TEST_PUBSUB_WIRE_PROTOCOL_V1"] = celix_options.build_pubsub_wire_protocol_v1 + tc.cache_variables["TEST_PUBSUB_WIRE_PROTOCOL_V2"] = celix_options.build_pubsub_wire_protocol_v2 + tc.cache_variables["TEST_PUBSUB_JSON_SERIALIZER"] = celix_options.build_pubsub_json_serializer + tc.cache_variables["TEST_PUBSUB_AVROBIN_SERIALIZER"] = celix_options.build_pubsub_avrobin_serializer + tc.cache_variables["TEST_CXX_REMOTE_SERVICE_ADMIN"] = celix_options.build_cxx_remote_service_admin + tc.cache_variables["TEST_SHELL_API"] = celix_options.build_shell_api + tc.cache_variables["TEST_SHELL_BONJOUR"] = celix_options.build_shell_bonjour + tc.cache_variables["TEST_CELIX_DFI"] = celix_options.build_celix_dfi + tc.cache_variables["TEST_UTILS"] = celix_options.build_utils + tc.cache_variables["TEST_COMPONENTS_READY_CHECK"] = celix_options.build_components_ready_check + tc.user_presets_path = False + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + celix_options = self.dependencies["celix"].options + if celix_options.build_framework: + self.run("./use_framework", run_environment=True) + if celix_options.build_http_admin: + self.run("./use_http_admin", cwd=os.path.join("deploy", "use_http_admin"), run_environment=True) + if celix_options.build_log_service: + self.run("./use_log_writer", cwd=os.path.join("deploy", "use_log_writer"), run_environment=True) + if celix_options.build_syslog_writer: + self.run("./use_syslog_writer", cwd=os.path.join("deploy", "use_syslog_writer"), run_environment=True) + if celix_options.build_pubsub: + self.run("./use_my_psa", cwd=os.path.join("deploy", "use_my_psa"), run_environment=True) + if celix_options.build_pubsub_psa_zmq: + self.run("./use_psa_zmq", cwd=os.path.join("deploy", "use_psa_zmq"), run_environment=True) + if celix_options.build_pubsub_psa_tcp: + self.run("./use_psa_tcp", cwd=os.path.join("deploy", "use_psa_tcp"), run_environment=True) + if celix_options.build_pubsub_psa_udp_mc: + self.run("./use_psa_udp_mc", cwd=os.path.join("deploy", "use_psa_udp_mc"), run_environment=True) + if celix_options.build_pubsub_psa_ws: + self.run("./use_psa_ws", cwd=os.path.join("deploy", "use_psa_ws"), run_environment=True) + if celix_options.build_pubsub_discovery_etcd and celix_options.build_launcher: + self.run("./use_psa_discovery_etcd", + cwd=os.path.join("deploy", "use_psa_discovery_etcd"), run_environment=True) + if celix_options.build_remote_service_admin: + self.run("./use_my_rsa", cwd=os.path.join("deploy", "use_my_rsa"), run_environment=True) + self.run("./use_c_rsa_spi", run_environment=True) + if celix_options.build_rsa_remote_service_admin_dfi and celix_options.build_launcher: + self.run("./use_rsa_dfi", cwd=os.path.join("deploy", "use_rsa_dfi"), run_environment=True) + if celix_options.build_rsa_remote_service_admin_shm_v2: + self.run("./use_rsa_shm_v2", cwd=os.path.join("deploy", "use_rsa_shm_v2"), run_environment=True) + if celix_options.build_rsa_json_rpc: + self.run("./use_rsa_rpc_json", cwd=os.path.join("deploy", "use_rsa_rpc_json"), run_environment=True) + if celix_options.build_rsa_discovery_configured and celix_options.build_launcher: + self.run("./use_rsa_configured", cwd=os.path.join("deploy", "use_rsa_configured"), run_environment=True) + if celix_options.build_rsa_discovery_etcd and celix_options.build_launcher: + self.run("./use_rsa_etcd", cwd=os.path.join("deploy", "use_rsa_etcd"), run_environment=True) + if celix_options.build_rsa_discovery_zeroconf: + self.run("./use_rsa_discovery_zeroconf", + cwd=os.path.join("deploy", "use_rsa_discovery_zeroconf"), run_environment=True) + if celix_options.build_shell: + self.run("./use_shell", run_environment=True) + if celix_options.celix_cxx17 or celix_options.celix_cxx14: + self.run("./use_cxx_shell", run_environment=True) + if celix_options.build_remote_shell: + self.run("./use_remote_shell", cwd=os.path.join("deploy", "use_remote_shell"), run_environment=True) + if celix_options.build_shell_tui: + self.run("./use_shell_tui", cwd=os.path.join("deploy", "use_shell_tui"), run_environment=True) + if celix_options.build_shell_wui: + self.run("./use_shell_wui", cwd=os.path.join("deploy", "use_shell_wui"), run_environment=True) + if celix_options.build_celix_etcdlib: + self.run("./use_etcd_lib", run_environment=True) + if celix_options.build_launcher: + self.run("./use_launcher", cwd=os.path.join("deploy", "use_launcher"), run_environment=True) + if celix_options.build_promises: + self.run("./use_promises", run_environment=True) + if celix_options.build_pushstreams: + self.run("./use_pushstreams", run_environment=True) + if celix_options.build_deployment_admin: + self.run("./use_deployment_admin", + cwd=os.path.join("deploy", "use_deployment_admin"), run_environment=True) + if celix_options.build_log_helper: + self.run("./use_log_helper", run_environment=True) + if celix_options.build_log_service_api: + self.run("./use_log_service_api", run_environment=True) + if celix_options.build_pubsub_wire_protocol_v1: + self.run("./use_pubsub_wire_protocol_v1", + cwd=os.path.join("deploy", "use_pubsub_wire_protocol_v1"), run_environment=True) + if celix_options.build_pubsub_wire_protocol_v2: + self.run("./use_pubsub_wire_protocol_v2", + cwd=os.path.join("deploy", "use_pubsub_wire_protocol_v2"), run_environment=True) + if celix_options.build_pubsub_json_serializer: + self.run("./use_pubsub_json_serializer", + cwd=os.path.join("deploy", "use_pubsub_json_serializer"), run_environment=True) + if celix_options.build_pubsub_avrobin_serializer: + self.run("./use_pubsub_avrobin_serializer", + cwd=os.path.join("deploy", "use_pubsub_avrobin_serializer"), run_environment=True) + if celix_options.build_cxx_remote_service_admin: + self.run("./use_cxx_remote_service_admin", + cwd=os.path.join("deploy", "use_cxx_remote_service_admin"), run_environment=True) + self.run("./use_rsa_spi", run_environment=True) + if celix_options.build_shell_api: + self.run("./use_shell_api", run_environment=True) + if celix_options.build_shell_bonjour: + self.run("./use_shell_bonjour", + cwd=os.path.join("deploy", "use_shell_bonjour"), run_environment=True) + if celix_options.build_celix_dfi: + self.run("./use_celix_dfi", run_environment=True) + if celix_options.build_utils: + self.run("./use_utils", run_environment=True) + if celix_options.build_components_ready_check: + self.run("./use_components_ready_check", + cwd=os.path.join("deploy", "use_components_ready_check"), run_environment=True) From ff7ad59d20072e3ea6e86df3c4edfc315c077c9b Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 23 Aug 2023 14:37:48 +0800 Subject: [PATCH 09/22] Fix linking error caused by private linking of transitive dependencies and wrong cwd. --- examples/conan_test_package_v2/conanfile.py | 189 ++++++++++---------- 1 file changed, 98 insertions(+), 91 deletions(-) diff --git a/examples/conan_test_package_v2/conanfile.py b/examples/conan_test_package_v2/conanfile.py index 587a6acb8..cf2aca10a 100644 --- a/examples/conan_test_package_v2/conanfile.py +++ b/examples/conan_test_package_v2/conanfile.py @@ -18,6 +18,7 @@ from conan import ConanFile from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.build import can_run +from conan.tools.files import chdir import os @@ -75,6 +76,11 @@ def generate(self): tc.cache_variables["TEST_CELIX_DFI"] = celix_options.build_celix_dfi tc.cache_variables["TEST_UTILS"] = celix_options.build_utils tc.cache_variables["TEST_COMPONENTS_READY_CHECK"] = celix_options.build_components_ready_check + # the following is workaround https://github.com/conan-io/conan/issues/7192 + if self.settings.os == "Linux": + tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs" + elif self.settings.os == "Macos": + tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,-undefined -Wl,dynamic_lookup" tc.user_presets_path = False tc.generate() @@ -85,94 +91,95 @@ def build(self): def test(self): if can_run(self): - celix_options = self.dependencies["celix"].options - if celix_options.build_framework: - self.run("./use_framework", run_environment=True) - if celix_options.build_http_admin: - self.run("./use_http_admin", cwd=os.path.join("deploy", "use_http_admin"), run_environment=True) - if celix_options.build_log_service: - self.run("./use_log_writer", cwd=os.path.join("deploy", "use_log_writer"), run_environment=True) - if celix_options.build_syslog_writer: - self.run("./use_syslog_writer", cwd=os.path.join("deploy", "use_syslog_writer"), run_environment=True) - if celix_options.build_pubsub: - self.run("./use_my_psa", cwd=os.path.join("deploy", "use_my_psa"), run_environment=True) - if celix_options.build_pubsub_psa_zmq: - self.run("./use_psa_zmq", cwd=os.path.join("deploy", "use_psa_zmq"), run_environment=True) - if celix_options.build_pubsub_psa_tcp: - self.run("./use_psa_tcp", cwd=os.path.join("deploy", "use_psa_tcp"), run_environment=True) - if celix_options.build_pubsub_psa_udp_mc: - self.run("./use_psa_udp_mc", cwd=os.path.join("deploy", "use_psa_udp_mc"), run_environment=True) - if celix_options.build_pubsub_psa_ws: - self.run("./use_psa_ws", cwd=os.path.join("deploy", "use_psa_ws"), run_environment=True) - if celix_options.build_pubsub_discovery_etcd and celix_options.build_launcher: - self.run("./use_psa_discovery_etcd", - cwd=os.path.join("deploy", "use_psa_discovery_etcd"), run_environment=True) - if celix_options.build_remote_service_admin: - self.run("./use_my_rsa", cwd=os.path.join("deploy", "use_my_rsa"), run_environment=True) - self.run("./use_c_rsa_spi", run_environment=True) - if celix_options.build_rsa_remote_service_admin_dfi and celix_options.build_launcher: - self.run("./use_rsa_dfi", cwd=os.path.join("deploy", "use_rsa_dfi"), run_environment=True) - if celix_options.build_rsa_remote_service_admin_shm_v2: - self.run("./use_rsa_shm_v2", cwd=os.path.join("deploy", "use_rsa_shm_v2"), run_environment=True) - if celix_options.build_rsa_json_rpc: - self.run("./use_rsa_rpc_json", cwd=os.path.join("deploy", "use_rsa_rpc_json"), run_environment=True) - if celix_options.build_rsa_discovery_configured and celix_options.build_launcher: - self.run("./use_rsa_configured", cwd=os.path.join("deploy", "use_rsa_configured"), run_environment=True) - if celix_options.build_rsa_discovery_etcd and celix_options.build_launcher: - self.run("./use_rsa_etcd", cwd=os.path.join("deploy", "use_rsa_etcd"), run_environment=True) - if celix_options.build_rsa_discovery_zeroconf: - self.run("./use_rsa_discovery_zeroconf", - cwd=os.path.join("deploy", "use_rsa_discovery_zeroconf"), run_environment=True) - if celix_options.build_shell: - self.run("./use_shell", run_environment=True) - if celix_options.celix_cxx17 or celix_options.celix_cxx14: - self.run("./use_cxx_shell", run_environment=True) - if celix_options.build_remote_shell: - self.run("./use_remote_shell", cwd=os.path.join("deploy", "use_remote_shell"), run_environment=True) - if celix_options.build_shell_tui: - self.run("./use_shell_tui", cwd=os.path.join("deploy", "use_shell_tui"), run_environment=True) - if celix_options.build_shell_wui: - self.run("./use_shell_wui", cwd=os.path.join("deploy", "use_shell_wui"), run_environment=True) - if celix_options.build_celix_etcdlib: - self.run("./use_etcd_lib", run_environment=True) - if celix_options.build_launcher: - self.run("./use_launcher", cwd=os.path.join("deploy", "use_launcher"), run_environment=True) - if celix_options.build_promises: - self.run("./use_promises", run_environment=True) - if celix_options.build_pushstreams: - self.run("./use_pushstreams", run_environment=True) - if celix_options.build_deployment_admin: - self.run("./use_deployment_admin", - cwd=os.path.join("deploy", "use_deployment_admin"), run_environment=True) - if celix_options.build_log_helper: - self.run("./use_log_helper", run_environment=True) - if celix_options.build_log_service_api: - self.run("./use_log_service_api", run_environment=True) - if celix_options.build_pubsub_wire_protocol_v1: - self.run("./use_pubsub_wire_protocol_v1", - cwd=os.path.join("deploy", "use_pubsub_wire_protocol_v1"), run_environment=True) - if celix_options.build_pubsub_wire_protocol_v2: - self.run("./use_pubsub_wire_protocol_v2", - cwd=os.path.join("deploy", "use_pubsub_wire_protocol_v2"), run_environment=True) - if celix_options.build_pubsub_json_serializer: - self.run("./use_pubsub_json_serializer", - cwd=os.path.join("deploy", "use_pubsub_json_serializer"), run_environment=True) - if celix_options.build_pubsub_avrobin_serializer: - self.run("./use_pubsub_avrobin_serializer", - cwd=os.path.join("deploy", "use_pubsub_avrobin_serializer"), run_environment=True) - if celix_options.build_cxx_remote_service_admin: - self.run("./use_cxx_remote_service_admin", - cwd=os.path.join("deploy", "use_cxx_remote_service_admin"), run_environment=True) - self.run("./use_rsa_spi", run_environment=True) - if celix_options.build_shell_api: - self.run("./use_shell_api", run_environment=True) - if celix_options.build_shell_bonjour: - self.run("./use_shell_bonjour", - cwd=os.path.join("deploy", "use_shell_bonjour"), run_environment=True) - if celix_options.build_celix_dfi: - self.run("./use_celix_dfi", run_environment=True) - if celix_options.build_utils: - self.run("./use_utils", run_environment=True) - if celix_options.build_components_ready_check: - self.run("./use_components_ready_check", - cwd=os.path.join("deploy", "use_components_ready_check"), run_environment=True) + with chdir(self, self.build_folder): + celix_options = self.dependencies["celix"].options + if celix_options.build_framework: + self.run("./conan_test_package/use_framework", env="conanrun") + if celix_options.build_http_admin: + self.run("./use_http_admin", cwd=os.path.join("deploy", "use_http_admin"), env="conanrun") + if celix_options.build_log_service: + self.run("./use_log_writer", cwd=os.path.join("deploy", "use_log_writer"), env="conanrun") + if celix_options.build_syslog_writer: + self.run("./use_syslog_writer", cwd=os.path.join("deploy", "use_syslog_writer"), env="conanrun") + if celix_options.build_pubsub: + self.run("./use_my_psa", cwd=os.path.join("deploy", "use_my_psa"), env="conanrun") + if celix_options.build_pubsub_psa_zmq: + self.run("./use_psa_zmq", cwd=os.path.join("deploy", "use_psa_zmq"), env="conanrun") + if celix_options.build_pubsub_psa_tcp: + self.run("./use_psa_tcp", cwd=os.path.join("deploy", "use_psa_tcp"), env="conanrun") + if celix_options.build_pubsub_psa_udp_mc: + self.run("./use_psa_udp_mc", cwd=os.path.join("deploy", "use_psa_udp_mc"), env="conanrun") + if celix_options.build_pubsub_psa_ws: + self.run("./use_psa_ws", cwd=os.path.join("deploy", "use_psa_ws"), env="conanrun") + if celix_options.build_pubsub_discovery_etcd and celix_options.build_launcher: + self.run("./use_psa_discovery_etcd", + cwd=os.path.join("deploy", "use_psa_discovery_etcd"), env="conanrun") + if celix_options.build_remote_service_admin: + self.run("./use_my_rsa", cwd=os.path.join("deploy", "use_my_rsa"), env="conanrun") + self.run("./conan_test_package/use_c_rsa_spi", env="conanrun") + if celix_options.build_rsa_remote_service_admin_dfi and celix_options.build_launcher: + self.run("./use_rsa_dfi", cwd=os.path.join("deploy", "use_rsa_dfi"), env="conanrun") + if celix_options.build_rsa_remote_service_admin_shm_v2: + self.run("./use_rsa_shm_v2", cwd=os.path.join("deploy", "use_rsa_shm_v2"), env="conanrun") + if celix_options.build_rsa_json_rpc: + self.run("./use_rsa_rpc_json", cwd=os.path.join("deploy", "use_rsa_rpc_json"), env="conanrun") + if celix_options.build_rsa_discovery_configured and celix_options.build_launcher: + self.run("./use_rsa_configured", cwd=os.path.join("deploy", "use_rsa_configured"), env="conanrun") + if celix_options.build_rsa_discovery_etcd and celix_options.build_launcher: + self.run("./use_rsa_etcd", cwd=os.path.join("deploy", "use_rsa_etcd"), env="conanrun") + if celix_options.build_rsa_discovery_zeroconf: + self.run("./use_rsa_discovery_zeroconf", + cwd=os.path.join("deploy", "use_rsa_discovery_zeroconf"), env="conanrun") + if celix_options.build_shell: + self.run("./conan_test_package/use_shell", env="conanrun") + if celix_options.celix_cxx17 or celix_options.celix_cxx14: + self.run("./conan_test_package/use_cxx_shell", env="conanrun") + if celix_options.build_remote_shell: + self.run("./use_remote_shell", cwd=os.path.join("deploy", "use_remote_shell"), env="conanrun") + if celix_options.build_shell_tui: + self.run("./use_shell_tui", cwd=os.path.join("deploy", "use_shell_tui"), env="conanrun") + if celix_options.build_shell_wui: + self.run("./use_shell_wui", cwd=os.path.join("deploy", "use_shell_wui"), env="conanrun") + if celix_options.build_celix_etcdlib: + self.run("./conan_test_package/use_etcd_lib", env="conanrun") + if celix_options.build_launcher: + self.run("./use_launcher", cwd=os.path.join("deploy", "use_launcher"), env="conanrun") + if celix_options.build_promises: + self.run("./conan_test_package/use_promises", env="conanrun") + if celix_options.build_pushstreams: + self.run("./conan_test_package/use_pushstreams", env="conanrun") + if celix_options.build_deployment_admin: + self.run("./use_deployment_admin", + cwd=os.path.join("deploy", "use_deployment_admin"), env="conanrun") + if celix_options.build_log_helper: + self.run("./conan_test_package/use_log_helper", env="conanrun") + if celix_options.build_log_service_api: + self.run("./conan_test_package/use_log_service_api", env="conanrun") + if celix_options.build_pubsub_wire_protocol_v1: + self.run("./use_pubsub_wire_protocol_v1", + cwd=os.path.join("deploy", "use_pubsub_wire_protocol_v1"), env="conanrun") + if celix_options.build_pubsub_wire_protocol_v2: + self.run("./use_pubsub_wire_protocol_v2", + cwd=os.path.join("deploy", "use_pubsub_wire_protocol_v2"), env="conanrun") + if celix_options.build_pubsub_json_serializer: + self.run("./use_pubsub_json_serializer", + cwd=os.path.join("deploy", "use_pubsub_json_serializer"), env="conanrun") + if celix_options.build_pubsub_avrobin_serializer: + self.run("./use_pubsub_avrobin_serializer", + cwd=os.path.join("deploy", "use_pubsub_avrobin_serializer"), env="conanrun") + if celix_options.build_cxx_remote_service_admin: + self.run("./use_cxx_remote_service_admin", + cwd=os.path.join("deploy", "use_cxx_remote_service_admin"), env="conanrun") + self.run("./conan_test_package/use_rsa_spi", env="conanrun") + if celix_options.build_shell_api: + self.run("./conan_test_package/use_shell_api", env="conanrun") + if celix_options.build_shell_bonjour: + self.run("./use_shell_bonjour", + cwd=os.path.join("deploy", "use_shell_bonjour"), env="conanrun") + if celix_options.build_celix_dfi: + self.run("./conan_test_package/use_celix_dfi", env="conanrun") + if celix_options.build_utils: + self.run("./conan_test_package/use_utils", env="conanrun") + if celix_options.build_components_ready_check: + self.run("./use_components_ready_check", + cwd=os.path.join("deploy", "use_components_ready_check"), env="conanrun") From af027163eaf4040e364210183e35168ebe40849c Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 23 Aug 2023 15:28:51 +0800 Subject: [PATCH 10/22] Use Conan2 for conan_create/ubuntu-build --- .github/workflows/conan_create.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/conan_create.yml b/.github/workflows/conan_create.yml index 655a5fc85..748d145a6 100644 --- a/.github/workflows/conan_create.yml +++ b/.github/workflows/conan_create.yml @@ -14,14 +14,14 @@ jobs: fail-fast: false matrix: compiler: [ [gcc,g++], [clang,clang++] ] - type: [ Debug ] + type: [ Release ] timeout-minutes: 120 steps: - name: Checkout source code uses: actions/checkout@v3.3.0 - name: Install build dependencies run: | - sudo pip install -U conan==1.59.0 + sudo pip install -U conan sudo apt-get install -yq --no-install-recommends ninja-build - name: Setup Conan Profile env: @@ -29,24 +29,14 @@ jobs: CXX: ${{ matrix.compiler[1] }} run: | # build profile - conan profile new release --detect - conan profile update settings.build_type=Release release - #Note no backwards compatiblity for gcc5 needed, setting libcxx to c++11. - conan profile update settings.compiler.libcxx=libstdc++11 release - conan profile show release - # host profile conan profile new default --detect - conan profile update settings.build_type=${{ matrix.type }} default - #Note no backwards compatiblity for gcc5 needed, setting libcxx to c++11. - conan profile update settings.compiler.libcxx=libstdc++11 default - conan profile show default + echo tools.cmake.cmaketoolchain:generator=Ninja >> ~\.conan2\global.conf - name: Create Celix env: CC: ${{ matrix.compiler[0] }} CXX: ${{ matrix.compiler[1] }} - CONAN_CMAKE_GENERATOR: Ninja run: | - conan inspect . -a options | awk 'BEGIN { FS="[\t:]+" } /build/ && !/build_all/ { print $1}' | while read option; do conan create . -b missing -o celix:${option}=True -pr:b release -pr:h default -tf examples/conan_test_package -tbf test-build -o celix:celix_cxx17=True -o celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s --require-override=zlib/1.2.13 || exit 1; done + conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ && !/build_all/ { if(output) print $1} /^options/ {output=1} /^options_definitions/ {output=0}' | while read option; do conan create . -b missing -o celix/*:${option}=True -pr:b default -pr:h default -s:h build_type=${{ matrix.type }} -tf examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True || exit 1; done mac-build: runs-on: macOS-11 From f292a838d7b1fb7fb11c96225547f3d30e59637c Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 23 Aug 2023 15:31:34 +0800 Subject: [PATCH 11/22] Fix profile setup for conan_create/ubuntu-build --- .github/workflows/conan_create.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conan_create.yml b/.github/workflows/conan_create.yml index 748d145a6..5f29d9815 100644 --- a/.github/workflows/conan_create.yml +++ b/.github/workflows/conan_create.yml @@ -29,7 +29,7 @@ jobs: CXX: ${{ matrix.compiler[1] }} run: | # build profile - conan profile new default --detect + conan profile detect -f echo tools.cmake.cmaketoolchain:generator=Ninja >> ~\.conan2\global.conf - name: Create Celix env: From dfae92ea37b8524a1fdb4cb10b7a53d6e849dcf6 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 23 Aug 2023 16:00:37 +0800 Subject: [PATCH 12/22] Fix option setting error for conan_create/ubuntu-build --- .github/workflows/conan_create.yml | 1 - conanfile.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conan_create.yml b/.github/workflows/conan_create.yml index 5f29d9815..3b791fc7a 100644 --- a/.github/workflows/conan_create.yml +++ b/.github/workflows/conan_create.yml @@ -30,7 +30,6 @@ jobs: run: | # build profile conan profile detect -f - echo tools.cmake.cmaketoolchain:generator=Ninja >> ~\.conan2\global.conf - name: Create Celix env: CC: ${{ matrix.compiler[0] }} diff --git a/conanfile.py b/conanfile.py index 9c1e2c60d..dd29d5839 100644 --- a/conanfile.py +++ b/conanfile.py @@ -173,9 +173,8 @@ def configure(self): options["build_rsa_discovery_zeroconf"] = False options["build_shell_bonjour"] = False - if not options["enable_testing"]: - options["build_pubsub_integration"] = False - options["enable_code_coverage"] = False + if options["enable_code_coverage"]: + options["enable_testing"] = True if options["build_examples"]: options["build_shell_tui"] = True @@ -209,6 +208,7 @@ def configure(self): options["build_pubsub_json_serializer"] = True options["build_pubsub_wire_protocol_v2"] = True options["build_pubsub_wire_protocol_v1"] = True + options["enable_testing"] = True if options["build_pubsub_examples"]: options["build_log_service"] = True From e7d277ade05fe165a50e65d2cbe51ac59ecda297 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 23 Aug 2023 16:32:46 +0800 Subject: [PATCH 13/22] Remove irrelevant dependency of unit_test_rsa_common. --- bundles/remote_services/rsa_common/gtest/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/bundles/remote_services/rsa_common/gtest/CMakeLists.txt b/bundles/remote_services/rsa_common/gtest/CMakeLists.txt index 4c6c2410f..0cd82925b 100644 --- a/bundles/remote_services/rsa_common/gtest/CMakeLists.txt +++ b/bundles/remote_services/rsa_common/gtest/CMakeLists.txt @@ -22,7 +22,6 @@ if (LINKER_WRAP_SUPPORTED) target_link_libraries(unit_test_rsa_common PRIVATE rsa_common_cut - Celix::rsa_spi Celix::framework Celix::utils Celix::malloc_ei From 1c5605af19b4ad502dd726a85e7db8bf26cfc0ba Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 23 Aug 2023 16:34:18 +0800 Subject: [PATCH 14/22] Fix missing `deps_cpp_info` for Conan 2 --- conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index dd29d5839..55f42b1f0 100644 --- a/conanfile.py +++ b/conanfile.py @@ -411,9 +411,9 @@ def generate(self): for opt in self._celix_defaults.keys(): tc.cache_variables[opt.upper()] = self.options.get_safe(opt) if self.options.enable_testing: - for k in self.deps_cpp_info.deps: - if k == "mdnsresponder": - tc.cache_variables["BUILD_ERROR_INJECTOR_MDNSRESPONDER"] = "ON" + lst = [x.ref.name for x in self.requires.values()] + if "mdnsresponder" in lst: + tc.cache_variables["BUILD_ERROR_INJECTOR_MDNSRESPONDER"] = "ON" tc.cache_variables["CELIX_ERR_BUFFER_SIZE"] = self.options.celix_err_buffer_size # tc.cache_variables["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 From a2d547a14284c91fde1e18ba2bf3752c306d8256 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 23 Aug 2023 20:00:32 +0800 Subject: [PATCH 15/22] Update documentation to reflect the new conan based workflow. --- documents/building/dev_celix_with_clion.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/documents/building/dev_celix_with_clion.md b/documents/building/dev_celix_with_clion.md index 8de4c6d35..6f0c6f103 100644 --- a/documents/building/dev_celix_with_clion.md +++ b/documents/building/dev_celix_with_clion.md @@ -47,12 +47,19 @@ conan profile update settings.build_type=Debug debug #generate and configure cmake-build-debug directory conan install . celix/2.3.0 -pr:b default -pr:h debug -if cmake-build-debug/ -o celix:enable_testing=True -o celix:enable_address_sanitizer=True -o celix:build_all=True -b missing -conan build . -bf cmake-build-debug/ --configure -#optional build +#invoke the exact cmake command `conan install` shows to configure the build directory cd cmake-build-debug +cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/peng/Downloads/git/mycelix/cmake-build-debug/conan_toolchain.cmake -DENABLE_TESTING=ON -DENABLE_CODE_COVERAGE=OFF -DENABLE_ADDRESS_SANITIZER=ON -DENABLE_UNDEFINED_SANITIZER=OFF -DENABLE_THREAD_SANITIZER=OFF -DENABLE_TESTING_DEPENDENCY_MANAGER_FOR_CXX11=OFF -DENABLE_TESTING_FOR_CXX14=OFF -DBUILD_ALL=ON -DBUILD_DEPLOYMENT_ADMIN=ON -DBUILD_HTTP_ADMIN=ON -DBUILD_LOG_SERVICE=ON -DBUILD_LOG_HELPER=ON -DBUILD_LOG_SERVICE_API=ON -DBUILD_SYSLOG_WRITER=ON -DBUILD_PUBSUB=ON -DBUILD_PUBSUB_WIRE_PROTOCOL_V1=ON -DBUILD_PUBSUB_WIRE_PROTOCOL_V2=ON -DBUILD_PUBSUB_JSON_SERIALIZER=ON -DBUILD_PUBSUB_AVROBIN_SERIALIZER=ON -DBUILD_PUBSUB_PSA_ZMQ=ON -DBUILD_PUBSUB_EXAMPLES=ON -DBUILD_PUBSUB_INTEGRATION=ON -DBUILD_PUBSUB_PSA_TCP=ON -DBUILD_PUBSUB_PSA_UDP_MC=ON -DBUILD_PUBSUB_PSA_WS=ON -DBUILD_PUBSUB_DISCOVERY_ETCD=ON -DBUILD_CXX_REMOTE_SERVICE_ADMIN=ON -DBUILD_CXX_RSA_INTEGRATION=ON -DBUILD_REMOTE_SERVICE_ADMIN=ON -DBUILD_RSA_REMOTE_SERVICE_ADMIN_DFI=ON -DBUILD_RSA_DISCOVERY_COMMON=ON -DBUILD_RSA_DISCOVERY_CONFIGURED=ON -DBUILD_RSA_DISCOVERY_ETCD=ON -DBUILD_RSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON -DBUILD_RSA_JSON_RPC=ON -DBUILD_RSA_DISCOVERY_ZEROCONF=ON -DBUILD_SHELL=ON -DBUILD_SHELL_API=ON -DBUILD_REMOTE_SHELL=ON -DBUILD_SHELL_BONJOUR=ON -DBUILD_SHELL_TUI=ON -DBUILD_SHELL_WUI=ON -DBUILD_COMPONENTS_READY_CHECK=ON -DBUILD_EXAMPLES=ON -DBUILD_CELIX_ETCDLIB=ON -DBUILD_LAUNCHER=ON -DBUILD_PROMISES=ON -DBUILD_PUSHSTREAMS=ON -DBUILD_EXPERIMENTAL=ON -DBUILD_CELIX_DFI=ON -DBUILD_DEPENDENCY_MANAGER=ON -DBUILD_DEPENDENCY_MANAGER_CXX=ON -DBUILD_FRAMEWORK=ON -DBUILD_RCM=ON -DBUILD_UTILS=ON -DCELIX_CXX14=ON -DCELIX_CXX17=ON -DCELIX_INSTALL_DEPRECATED_API=ON -DCELIX_USE_COMPRESSION_FOR_BUNDLE_ZIPS=ON -DENABLE_CMAKE_WARNING_TESTS=OFF -DENABLE_TESTING_ON_CI=OFF -DFRAMEWORK_CURLINIT=ON -DBUILD_ERROR_INJECTOR_MDNSRESPONDER=ON -DCELIX_ERR_BUFFER_SIZE=512 -DCMAKE_EXE_LINKER_FLAGS=-Wl,--unresolved-symbols=ignore-in-shared-libs -DCELIX_MAJOR=2 -DCELIX_MINOR=3 -DCELIX_MICRO=0 -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Debug + +#optional build, you may want to skip it and use CLion to build make -j +# if you don't like the above very long cmake command, you may use the following command instead +# Note that it does a full building, which may take a long time +# conan build . -bf cmake-build-debug/ + + #optional setup run env and run tests source conanrun.sh ctest --verbose @@ -63,10 +70,10 @@ source deactivate_conanrun.sh To ensure that all Conan build dependencies can be found the Run/Debug configurations of CLion needs te be updated. This can be done under the menu "Run->Edit Configurations...", then select "Edit configuration templates..." and -then update the "Google Test" template so that the `active_run.sh` Conan generated script is sourced in the +then update the "Google Test" template so that the `conanrun.sh` Conan generated script is sourced in the "Environment variables" entry. If the Apache Celix CMake build directory is `home/joe/workspace/celix/cmake-build-debug` then the value for -"Environment variables" should be: `source /home/joe/workspace/celix/cmake-build-debug/environment_run.sh.env` +"Environment variables" should be: `source /home/joe/workspace/celix/cmake-build-debug/conanrun.sh` ![Configure CLion](media/clion_run_configuration_template.png) From 2e48484ea8b19ae59055caaf395129ea5762841d Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 23 Aug 2023 21:56:03 +0800 Subject: [PATCH 16/22] Remove unsupported `conan build --configure`. --- .github/workflows/coverage.yml | 3 +-- .github/workflows/macos.yml | 3 +-- .github/workflows/ubuntu.yml | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 045c3dff3..6d4e85d8b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -33,8 +33,7 @@ jobs: conan install . celix/ci -pr:b default -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing -b cpputest --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s - name: Build run: | - conan build . -bf build --configure - conan build . -bf build --build + conan build . -bf build - name: Test with coverage run: | cd build diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 189433512..2e95ab671 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -38,8 +38,7 @@ jobs: conan install . celix/ci -pr:b default -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing -b cpputest --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s - name: Build run: | - conan build . -bf build --configure - conan build . -bf build --build + conan build . -bf build - name: Test run: | diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 85869deb5..8f37382ea 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -62,8 +62,7 @@ jobs: CXX: ${{ matrix.compiler[1] }} CONAN_CMAKE_GENERATOR: Ninja run: | - conan build . -bf build --configure - conan build . -bf build --build + conan build . -bf build - name: Test run: | cd build From ff265039c271be74fa93b4409c00553a5492d8bc Mon Sep 17 00:00:00 2001 From: PengZheng Date: Thu, 24 Aug 2023 12:19:34 +0800 Subject: [PATCH 17/22] Enable ninja for all conan build. --- .github/workflows/conan_create.yml | 3 +-- .github/workflows/coverage.yml | 2 +- .github/workflows/macos.yml | 2 +- conanfile.py | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/conan_create.yml b/.github/workflows/conan_create.yml index 3b791fc7a..31cca7c8e 100644 --- a/.github/workflows/conan_create.yml +++ b/.github/workflows/conan_create.yml @@ -9,7 +9,7 @@ on: jobs: ubuntu-build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: @@ -55,6 +55,5 @@ jobs: env: CC: ${{ matrix.compiler[0] }} CXX: ${{ matrix.compiler[1] }} - CONAN_CMAKE_GENERATOR: Ninja run: | conan inspect . -a options | awk 'BEGIN { FS="[\t:]+" } /build/ && !/build_all/ { print $1}' | while read option; do conan create . -b missing -o celix:${option}=True -pr:b default -pr:h default -tf examples/conan_test_package -tbf test-build -o celix:celix_cxx17=True -o celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s --require-override=zlib/1.2.13 || exit 1; done diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 6d4e85d8b..fa6301217 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -11,7 +11,7 @@ jobs: uses: actions/checkout@v3.3.0 - name: Install conan and lcov run: | - sudo apt-get install -yq --no-install-recommends lcov + sudo apt-get install -yq --no-install-recommends lcov ninja-build sudo pip install conan==1.59.0 - name: Setup Conan Profile run: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 2e95ab671..9fd3239bb 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v3.3.0 - name: Install conan run: | - brew install python + brew install python ninja pip3 install -U conan==1.59.0 - name: Setup Conan Profile run: | diff --git a/conanfile.py b/conanfile.py index 55f42b1f0..7a3ea4248 100644 --- a/conanfile.py +++ b/conanfile.py @@ -407,7 +407,7 @@ def requirements(self): self.validate() def generate(self): - tc = CMakeToolchain(self) + tc = CMakeToolchain(self, generator="Ninja") for opt in self._celix_defaults.keys(): tc.cache_variables[opt.upper()] = self.options.get_safe(opt) if self.options.enable_testing: From ad184301276b3167a7a01cbe22fe906d2a8db56e Mon Sep 17 00:00:00 2001 From: PengZheng Date: Thu, 24 Aug 2023 12:46:27 +0800 Subject: [PATCH 18/22] Run gcov by ninja. --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index fa6301217..d8c6a148c 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -38,7 +38,7 @@ jobs: run: | cd build source conanrun.sh - make coverage + ninja coverage source deactivate_conanrun.sh lcx="lcov --output-file=coverage.info " && for i in `find . -name "*.info.cleaned"`; do lcx+=" --add-tracefile=$i"; done && $lcx - name: Codecov From 697e7ede4b30406ff3851d54e5f4c1c31384f24f Mon Sep 17 00:00:00 2001 From: PengZheng Date: Thu, 24 Aug 2023 13:32:29 +0800 Subject: [PATCH 19/22] Run gcov by GNU make. --- .github/workflows/conan_create.yml | 4 ++-- .github/workflows/coverage.yml | 4 ++-- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- conanfile.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/conan_create.yml b/.github/workflows/conan_create.yml index 31cca7c8e..47adadf2f 100644 --- a/.github/workflows/conan_create.yml +++ b/.github/workflows/conan_create.yml @@ -35,7 +35,7 @@ jobs: CC: ${{ matrix.compiler[0] }} CXX: ${{ matrix.compiler[1] }} run: | - conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ && !/build_all/ { if(output) print $1} /^options/ {output=1} /^options_definitions/ {output=0}' | while read option; do conan create . -b missing -o celix/*:${option}=True -pr:b default -pr:h default -s:h build_type=${{ matrix.type }} -tf examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True || exit 1; done + conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ && !/build_all/ { if(output) print $1} /^options/ {output=1} /^options_definitions/ {output=0}' | while read option; do conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:${option}=True -pr:b default -pr:h default -s:h build_type=${{ matrix.type }} -tf examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True || exit 1; done mac-build: runs-on: macOS-11 @@ -56,4 +56,4 @@ jobs: CC: ${{ matrix.compiler[0] }} CXX: ${{ matrix.compiler[1] }} run: | - conan inspect . -a options | awk 'BEGIN { FS="[\t:]+" } /build/ && !/build_all/ { print $1}' | while read option; do conan create . -b missing -o celix:${option}=True -pr:b default -pr:h default -tf examples/conan_test_package -tbf test-build -o celix:celix_cxx17=True -o celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s --require-override=zlib/1.2.13 || exit 1; done + conan inspect . -a options | awk 'BEGIN { FS="[\t:]+" } /build/ && !/build_all/ { print $1}' | while read option; do conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix:${option}=True -pr:b default -pr:h default -tf examples/conan_test_package -tbf test-build -o celix:celix_cxx17=True -o celix:celix_install_deprecated_api=True --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s --require-override=zlib/1.2.13 || exit 1; done diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d8c6a148c..6d4e85d8b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -11,7 +11,7 @@ jobs: uses: actions/checkout@v3.3.0 - name: Install conan and lcov run: | - sudo apt-get install -yq --no-install-recommends lcov ninja-build + sudo apt-get install -yq --no-install-recommends lcov sudo pip install conan==1.59.0 - name: Setup Conan Profile run: | @@ -38,7 +38,7 @@ jobs: run: | cd build source conanrun.sh - ninja coverage + make coverage source deactivate_conanrun.sh lcx="lcov --output-file=coverage.info " && for i in `find . -name "*.info.cleaned"`; do lcx+=" --add-tracefile=$i"; done && $lcx - name: Codecov diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 9fd3239bb..d20ac4903 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -35,7 +35,7 @@ jobs: -o celix:framework_curlinit=False run: | #force require libcurl 7.64.1, due to a sha256 verify issue in libcurl/7.87.0 - conan install . celix/ci -pr:b default -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing -b cpputest --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s + conan install . celix/ci -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b default -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing -b cpputest --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s - name: Build run: | conan build . -bf build diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 8f37382ea..6839c0325 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -55,7 +55,7 @@ jobs: -o celix:framework_curlinit=False run: | #force require libcurl 7.64.1, due to a sha256 verify issue in libcurl/7.87.0 - conan install . celix/ci -pr:b release -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing -b cpputest --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s + conan install . celix/ci -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b release -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing -b cpputest --require-override=libcurl/7.64.1 --require-override=openssl/1.1.1s - name: Build env: CC: ${{ matrix.compiler[0] }} diff --git a/conanfile.py b/conanfile.py index 7a3ea4248..55f42b1f0 100644 --- a/conanfile.py +++ b/conanfile.py @@ -407,7 +407,7 @@ def requirements(self): self.validate() def generate(self): - tc = CMakeToolchain(self, generator="Ninja") + tc = CMakeToolchain(self) for opt in self._celix_defaults.keys(): tc.cache_variables[opt.upper()] = self.options.get_safe(opt) if self.options.enable_testing: From a76ad793e7d5629204fe72a37923e3c7795351ae Mon Sep 17 00:00:00 2001 From: PengZheng Date: Thu, 24 Aug 2023 18:01:43 +0800 Subject: [PATCH 20/22] Fix asan error and re-enable pubsub_udpmc_tests. --- bundles/pubsub/integration/CMakeLists.txt | 2 ++ .../pubsub_admin_udp_mc/src/pubsub_udpmc_topic_receiver.c | 2 +- libs/dfi/src/json_serializer.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bundles/pubsub/integration/CMakeLists.txt b/bundles/pubsub/integration/CMakeLists.txt index c57c1dfb3..8408009bf 100644 --- a/bundles/pubsub/integration/CMakeLists.txt +++ b/bundles/pubsub/integration/CMakeLists.txt @@ -160,6 +160,8 @@ if (PUBSUB_INTEGRATION) ) target_link_libraries(pubsub_udpmc_tests PRIVATE Celix::pubsub_api GTest::gtest GTest::gtest_main) target_include_directories(pubsub_udpmc_tests SYSTEM PRIVATE gtest) + add_test(NAME pubsub_udpmc_tests COMMAND pubsub_udpmc_tests WORKING_DIRECTORY $) + setup_target_for_coverage(pubsub_udpmc_tests SCAN_DIR ..) add_celix_container(pstm_deadlock_udpmc_test USE_CONFIG #ensures that a config.properties will be created with the launch bundles. diff --git a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_receiver.c b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_receiver.c index 5f8201953..a468b3eef 100644 --- a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_receiver.c +++ b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_receiver.c @@ -485,7 +485,7 @@ static void psa_udpmc_processMsg(pubsub_udpmc_topic_receiver_t *receiver, pubsub if (validVersion) { struct iovec deSerializeBuffer; deSerializeBuffer.iov_base = msg->payload; - deSerializeBuffer.iov_len = 0; + deSerializeBuffer.iov_len = msg->payloadSize; celix_status_t status = msgSer->deserialize(msgSer->handle, &deSerializeBuffer, 0, &msgInst); if (status == CELIX_SUCCESS) { diff --git a/libs/dfi/src/json_serializer.c b/libs/dfi/src/json_serializer.c index 711eed05e..c4668866f 100644 --- a/libs/dfi/src/json_serializer.c +++ b/libs/dfi/src/json_serializer.c @@ -57,7 +57,7 @@ int jsonSerializer_deserialize(dyn_type *type, const char *input, size_t length, json_decref(root); } else { status = ERROR; - LOG_ERROR("Error parsing json input '%s'. Error is: %s\n", input, error.text); + LOG_ERROR("Error parsing json input '%.*s'. Error is: %s\n", (int)length, input, error.text); } if (status != OK) { From 9ea3246c91fcbf17e76d771a79146df2d911c583 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Thu, 24 Aug 2023 18:31:00 +0800 Subject: [PATCH 21/22] Still recommend using `conan build` in our Conan-based CLion workflow but mention a quicker way to skip full building. --- documents/building/dev_celix_with_clion.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/documents/building/dev_celix_with_clion.md b/documents/building/dev_celix_with_clion.md index 6f0c6f103..8c0917319 100644 --- a/documents/building/dev_celix_with_clion.md +++ b/documents/building/dev_celix_with_clion.md @@ -48,19 +48,13 @@ conan profile update settings.build_type=Debug debug #generate and configure cmake-build-debug directory conan install . celix/2.3.0 -pr:b default -pr:h debug -if cmake-build-debug/ -o celix:enable_testing=True -o celix:enable_address_sanitizer=True -o celix:build_all=True -b missing -#invoke the exact cmake command `conan install` shows to configure the build directory -cd cmake-build-debug -cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/peng/Downloads/git/mycelix/cmake-build-debug/conan_toolchain.cmake -DENABLE_TESTING=ON -DENABLE_CODE_COVERAGE=OFF -DENABLE_ADDRESS_SANITIZER=ON -DENABLE_UNDEFINED_SANITIZER=OFF -DENABLE_THREAD_SANITIZER=OFF -DENABLE_TESTING_DEPENDENCY_MANAGER_FOR_CXX11=OFF -DENABLE_TESTING_FOR_CXX14=OFF -DBUILD_ALL=ON -DBUILD_DEPLOYMENT_ADMIN=ON -DBUILD_HTTP_ADMIN=ON -DBUILD_LOG_SERVICE=ON -DBUILD_LOG_HELPER=ON -DBUILD_LOG_SERVICE_API=ON -DBUILD_SYSLOG_WRITER=ON -DBUILD_PUBSUB=ON -DBUILD_PUBSUB_WIRE_PROTOCOL_V1=ON -DBUILD_PUBSUB_WIRE_PROTOCOL_V2=ON -DBUILD_PUBSUB_JSON_SERIALIZER=ON -DBUILD_PUBSUB_AVROBIN_SERIALIZER=ON -DBUILD_PUBSUB_PSA_ZMQ=ON -DBUILD_PUBSUB_EXAMPLES=ON -DBUILD_PUBSUB_INTEGRATION=ON -DBUILD_PUBSUB_PSA_TCP=ON -DBUILD_PUBSUB_PSA_UDP_MC=ON -DBUILD_PUBSUB_PSA_WS=ON -DBUILD_PUBSUB_DISCOVERY_ETCD=ON -DBUILD_CXX_REMOTE_SERVICE_ADMIN=ON -DBUILD_CXX_RSA_INTEGRATION=ON -DBUILD_REMOTE_SERVICE_ADMIN=ON -DBUILD_RSA_REMOTE_SERVICE_ADMIN_DFI=ON -DBUILD_RSA_DISCOVERY_COMMON=ON -DBUILD_RSA_DISCOVERY_CONFIGURED=ON -DBUILD_RSA_DISCOVERY_ETCD=ON -DBUILD_RSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON -DBUILD_RSA_JSON_RPC=ON -DBUILD_RSA_DISCOVERY_ZEROCONF=ON -DBUILD_SHELL=ON -DBUILD_SHELL_API=ON -DBUILD_REMOTE_SHELL=ON -DBUILD_SHELL_BONJOUR=ON -DBUILD_SHELL_TUI=ON -DBUILD_SHELL_WUI=ON -DBUILD_COMPONENTS_READY_CHECK=ON -DBUILD_EXAMPLES=ON -DBUILD_CELIX_ETCDLIB=ON -DBUILD_LAUNCHER=ON -DBUILD_PROMISES=ON -DBUILD_PUSHSTREAMS=ON -DBUILD_EXPERIMENTAL=ON -DBUILD_CELIX_DFI=ON -DBUILD_DEPENDENCY_MANAGER=ON -DBUILD_DEPENDENCY_MANAGER_CXX=ON -DBUILD_FRAMEWORK=ON -DBUILD_RCM=ON -DBUILD_UTILS=ON -DCELIX_CXX14=ON -DCELIX_CXX17=ON -DCELIX_INSTALL_DEPRECATED_API=ON -DCELIX_USE_COMPRESSION_FOR_BUNDLE_ZIPS=ON -DENABLE_CMAKE_WARNING_TESTS=OFF -DENABLE_TESTING_ON_CI=OFF -DFRAMEWORK_CURLINIT=ON -DBUILD_ERROR_INJECTOR_MDNSRESPONDER=ON -DCELIX_ERR_BUFFER_SIZE=512 -DCMAKE_EXE_LINKER_FLAGS=-Wl,--unresolved-symbols=ignore-in-shared-libs -DCELIX_MAJOR=2 -DCELIX_MINOR=3 -DCELIX_MICRO=0 -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Debug - -#optional build, you may want to skip it and use CLion to build -make -j - -# if you don't like the above very long cmake command, you may use the following command instead -# Note that it does a full building, which may take a long time -# conan build . -bf cmake-build-debug/ - +# optional build +# If you want to skip building, which may take long, you can copy the the exact CMAKE command `conan install` shows into CLion +# and let CLion perform build directory configuration and build. +conan build . -bf cmake-build-debug/ #optional setup run env and run tests +cd cmake-build-debug source conanrun.sh ctest --verbose source deactivate_conanrun.sh From 4e7c7a4890cdecaa3445b803c55d9fa9b5a8a5e4 Mon Sep 17 00:00:00 2001 From: PengZheng Date: Thu, 24 Aug 2023 19:26:01 +0800 Subject: [PATCH 22/22] Avoid breaking downstream user who link to these targets. --- cmake/Modules/FindCppUTest.cmake | 6 ++++++ cmake/Modules/FindRapidJSON.cmake | 3 +++ cmake/Modules/FindZeroMQ.cmake | 3 +++ cmake/Modules/Findczmq.cmake | 3 +++ cmake/Modules/Findlibzip.cmake | 3 +++ 5 files changed, 18 insertions(+) diff --git a/cmake/Modules/FindCppUTest.cmake b/cmake/Modules/FindCppUTest.cmake index 8b4c54e02..b747b7d12 100644 --- a/cmake/Modules/FindCppUTest.cmake +++ b/cmake/Modules/FindCppUTest.cmake @@ -50,6 +50,9 @@ IF(CppUTest_FOUND) IMPORTED_LOCATION "${CppUTest_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${CppUTest_INCLUDE_DIR}" ) + if (NOT TARGET CppUTest::CppUTest) + add_library(CppUTest::CppUTest ALIAS CppUTest) + endif () endif() SET(CppUTest_EXT_LIBRARIES ${CppUTest_EXT_LIBRARY}) SET(CppUTest_EXT_INCLUDE_DIRS ${CppUTest_EXT_INCLUDE_DIR}) @@ -59,5 +62,8 @@ IF(CppUTest_FOUND) IMPORTED_LOCATION "${CppUTest_EXT_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${CppUTest_EXT_INCLUDE_DIR}" ) + if (NOT TARGET CppUTest::CppUTestExt) + add_library(CppUTest::CppUTestExt ALIAS CppUTestExt) + endif () endif() ENDIF(CppUTest_FOUND) diff --git a/cmake/Modules/FindRapidJSON.cmake b/cmake/Modules/FindRapidJSON.cmake index 083d9c41b..61bda6958 100644 --- a/cmake/Modules/FindRapidJSON.cmake +++ b/cmake/Modules/FindRapidJSON.cmake @@ -32,4 +32,7 @@ if(RapidJSON_FOUND AND NOT TARGET rapidjson) add_library(rapidjson INTERFACE IMPORTED) set_target_properties(rapidjson PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${RapidJSON_INCLUDE_DIRS}") + if (NOT TARGET RapidJSON::RapidJSON) + add_library(RapidJSON::RapidJSON ALIAS rapidjson) + endif () endif() diff --git a/cmake/Modules/FindZeroMQ.cmake b/cmake/Modules/FindZeroMQ.cmake index e6f5d0215..0d097c0f6 100644 --- a/cmake/Modules/FindZeroMQ.cmake +++ b/cmake/Modules/FindZeroMQ.cmake @@ -48,4 +48,7 @@ if (ZeroMQ_FOUND AND NOT TARGET libzmq) IMPORTED_LOCATION "${ZEROMQ_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${ZEROMQ_INCLUDE_DIR}" ) + if (NOT TARGET ZeroMQ::ZeroMQ) + add_library(ZeroMQ::ZeroMQ ALIAS libzmq) + endif () endif () diff --git a/cmake/Modules/Findczmq.cmake b/cmake/Modules/Findczmq.cmake index 8a3edf5b8..330850a54 100644 --- a/cmake/Modules/Findczmq.cmake +++ b/cmake/Modules/Findczmq.cmake @@ -48,4 +48,7 @@ if (czmq_FOUND AND NOT TARGET czmq) IMPORTED_LOCATION "${CZMQ_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${CZMQ_INCLUDE_DIR}" ) + if (NOT TARGET czmq::czmq) + add_library(czmq::czmq ALIAS czmq) + endif () endif () diff --git a/cmake/Modules/Findlibzip.cmake b/cmake/Modules/Findlibzip.cmake index 5cf2725c3..d93b40419 100644 --- a/cmake/Modules/Findlibzip.cmake +++ b/cmake/Modules/Findlibzip.cmake @@ -43,6 +43,9 @@ if(libzip_FOUND AND NOT TARGET libzip::zip) IMPORTED_LOCATION "${LIBZIP_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${LIBZIP_INCLUDE_DIR}" ) + if (NOT TARGET libzip::libzip) + add_library(libzip::libzip ALIAS libzip::zip) + endif () endif() unset(LIBZIP_LIBRARY)