You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2019/10/08 13:21:46 UTC

[celix] branch feature/#80_bundle_start_with_exception updated (564aebf -> c44e2c6)

This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a change to branch feature/#80_bundle_start_with_exception
in repository https://gitbox.apache.org/repos/asf/celix.git.


    from 564aebf  #80: Updates variables name of find<PKG>cmake to reflect the name of the find cmake file.
     new 402e9f5  #80: Updates error handling of failed lib loading for bundles.
     new c44e2c6  #118: Reverts some packge name changes and adds the creation of Jansson target.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 bundles/pubsub/examples/CMakeLists.txt             |  2 +-
 bundles/pubsub/keygen/CMakeLists.txt               |  2 +-
 bundles/pubsub/pubsub_discovery/CMakeLists.txt     |  2 +-
 .../pubsub/pubsub_serializer_json/CMakeLists.txt   |  2 +-
 bundles/pubsub/test/CMakeLists.txt                 | 12 +++----
 .../remote_services/discovery_etcd/CMakeLists.txt  |  2 +-
 .../remote_service_admin_dfi/CMakeLists.txt        |  2 +-
 .../topology_manager/tms_tst/CMakeLists.txt        |  2 +-
 cmake/Modules/FindJansson.cmake                    | 39 +++++++++++-----------
 cmake/Modules/FindNanoMsg.cmake                    | 26 +++++++--------
 cmake/Modules/FindOpenSSL.cmake                    | 32 +++++++++---------
 cmake/cmake_celix/UseCelix.cmake                   | 20 ++++++++---
 libs/dfi/CMakeLists.txt                            |  4 +--
 libs/etcdlib/CMakeLists.txt                        |  6 ++--
 libs/framework/src/framework.c                     | 32 +++++++++---------
 libs/framework/tst/CMakeLists.txt                  |  9 +++--
 .../framework/tst/bundle_context_bundles_tests.cpp | 13 ++++++++
 libs/framework/tst/subdir/CMakeLists.txt           |  2 ++
 .../test.h => libs/framework/tst/subdir/src/foo.c  | 11 +++---
 19 files changed, 125 insertions(+), 95 deletions(-)
 copy examples/celix-examples/bundle_with_private_lib/tlib/include/test.h => libs/framework/tst/subdir/src/foo.c (90%)


[celix] 02/02: #118: Reverts some packge name changes and adds the creation of Jansson target.

Posted by pn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/#80_bundle_start_with_exception
in repository https://gitbox.apache.org/repos/asf/celix.git

commit c44e2c6db69074e9e8f7defaf7aa1178b69e293f
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Tue Oct 8 15:21:27 2019 +0200

    #118: Reverts some packge name changes and adds the creation of Jansson target.
    
    Recent version of Jansson build and installed with CMake will create a
    Jansson (imported) CMake target. If this target is not present
    UseCelix.cmake will create this.
---
 bundles/pubsub/examples/CMakeLists.txt             |  2 +-
 bundles/pubsub/keygen/CMakeLists.txt               |  2 +-
 bundles/pubsub/pubsub_discovery/CMakeLists.txt     |  2 +-
 .../pubsub/pubsub_serializer_json/CMakeLists.txt   |  2 +-
 bundles/pubsub/test/CMakeLists.txt                 | 12 +++----
 .../remote_services/discovery_etcd/CMakeLists.txt  |  2 +-
 .../remote_service_admin_dfi/CMakeLists.txt        |  2 +-
 .../topology_manager/tms_tst/CMakeLists.txt        |  2 +-
 cmake/Modules/FindJansson.cmake                    | 39 +++++++++++-----------
 cmake/Modules/FindNanoMsg.cmake                    | 26 +++++++--------
 cmake/Modules/FindOpenSSL.cmake                    | 32 +++++++++---------
 cmake/cmake_celix/UseCelix.cmake                   | 20 ++++++++---
 libs/dfi/CMakeLists.txt                            |  4 +--
 libs/etcdlib/CMakeLists.txt                        |  6 ++--
 14 files changed, 82 insertions(+), 71 deletions(-)

diff --git a/bundles/pubsub/examples/CMakeLists.txt b/bundles/pubsub/examples/CMakeLists.txt
index cab7eef..ec7e5a9 100644
--- a/bundles/pubsub/examples/CMakeLists.txt
+++ b/bundles/pubsub/examples/CMakeLists.txt
@@ -22,7 +22,7 @@ find_program(XTERM_CMD NAMES xterm)
 
 find_package(Jansson REQUIRED)
 
-set(PUBSUB_CONTAINER_LIBS Jansson::lib Celix::dfi)
+set(PUBSUB_CONTAINER_LIBS Jansson Celix::dfi)
 
 # UDP Multicast
 add_celix_container(pubsub_publisher_udp_mc
diff --git a/bundles/pubsub/keygen/CMakeLists.txt b/bundles/pubsub/keygen/CMakeLists.txt
index a4b1a63..65db872 100644
--- a/bundles/pubsub/keygen/CMakeLists.txt
+++ b/bundles/pubsub/keygen/CMakeLists.txt
@@ -25,6 +25,6 @@ if (BUILD_ZMQ_SECURITY)
     target_link_libraries(makecert CZMQ::lib)
     
     add_executable(ed_file ed_file.c)
-    target_link_libraries(ed_file PUBLIC ZMQ::lib CZMQ::lib ${OPENSSL_CRYPTO_LIBRARY})
+    target_link_libraries(ed_file PUBLIC ZMQ::lib CZMQ::lib OpenSSL::lib)
 
 endif()
diff --git a/bundles/pubsub/pubsub_discovery/CMakeLists.txt b/bundles/pubsub/pubsub_discovery/CMakeLists.txt
index 54896e4..5da7041 100644
--- a/bundles/pubsub/pubsub_discovery/CMakeLists.txt
+++ b/bundles/pubsub/pubsub_discovery/CMakeLists.txt
@@ -30,7 +30,7 @@ target_include_directories(celix_pubsub_discovery_etcd PRIVATE src)
 target_link_libraries(celix_pubsub_discovery_etcd PRIVATE
         Celix::pubsub_spi Celix::framework Celix::etcdlib_static
         Celix::shell_api Celix::log_helper
-        CURL::libcurl Jansson::lib)
+        CURL::libcurl Jansson)
 
 install_celix_bundle(celix_pubsub_discovery_etcd EXPORT celix COMPONENT pubsub)
 
diff --git a/bundles/pubsub/pubsub_serializer_json/CMakeLists.txt b/bundles/pubsub/pubsub_serializer_json/CMakeLists.txt
index 84c250f..163d8ff 100644
--- a/bundles/pubsub/pubsub_serializer_json/CMakeLists.txt
+++ b/bundles/pubsub/pubsub_serializer_json/CMakeLists.txt
@@ -30,7 +30,7 @@ target_include_directories(celix_pubsub_serializer_json PRIVATE
     src
 )
 set_target_properties(celix_pubsub_serializer_json PROPERTIES INSTALL_RPATH "$ORIGIN")
-target_link_libraries(celix_pubsub_serializer_json PRIVATE Celix::pubsub_spi Celix::framework Celix::dfi Jansson::lib Celix::log_helper)
+target_link_libraries(celix_pubsub_serializer_json PRIVATE Celix::pubsub_spi Celix::framework Celix::dfi Jansson Celix::log_helper)
 
 install_celix_bundle(celix_pubsub_serializer_json EXPORT celix COMPONENT pubsub)
 
diff --git a/bundles/pubsub/test/CMakeLists.txt b/bundles/pubsub/test/CMakeLists.txt
index 36b4a8f..365f77f 100644
--- a/bundles/pubsub/test/CMakeLists.txt
+++ b/bundles/pubsub/test/CMakeLists.txt
@@ -120,7 +120,7 @@ add_celix_container(pubsub_udpmc_tests
             pubsub_sut
             pubsub_tst
 )
-target_link_libraries(pubsub_udpmc_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson::lib Celix::dfi)
+target_link_libraries(pubsub_udpmc_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson Celix::dfi)
 target_include_directories(pubsub_udpmc_tests PRIVATE ${CPPUTEST_INCLUDE_DIR} test)
 message(WARNING "TODO fix issues with UDPMC and reanble test again")
 #add_test(NAME pubsub_udpmc_tests COMMAND pubsub_udpmc_tests WORKING_DIRECTORY $<TARGET_PROPERTY:pubsub_udpmc_tests,CONTAINER_LOC>)
@@ -141,7 +141,7 @@ add_celix_container(pubsub_tcp_tests
         pubsub_sut
         pubsub_tst
         )
-target_link_libraries(pubsub_tcp_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson::lib Celix::dfi)
+target_link_libraries(pubsub_tcp_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson Celix::dfi)
 target_include_directories(pubsub_tcp_tests PRIVATE ${CPPUTEST_INCLUDE_DIR} test)
 add_test(NAME pubsub_tcp_tests COMMAND pubsub_tcp_tests WORKING_DIRECTORY $<TARGET_PROPERTY:pubsub_tcp_tests,CONTAINER_LOC>)
 SETUP_TARGET_FOR_COVERAGE(pubsub_tcp_tests_cov pubsub_tcp_tests ${CMAKE_BINARY_DIR}/coverage/pubsub_tcp_tests/pubsub_tcp_tests ..)
@@ -163,7 +163,7 @@ add_celix_container(pubsub_tcp_endpoint_tests
         pubsub_endpoint_sut
         pubsub_endpoint_tst
         )
-target_link_libraries(pubsub_tcp_endpoint_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson::lib Celix::dfi)
+target_link_libraries(pubsub_tcp_endpoint_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson Celix::dfi)
 target_include_directories(pubsub_tcp_endpoint_tests PRIVATE ${CPPUTEST_INCLUDE_DIR} test)
 
 #TCP Endpoint test is disabled because the test is not stable when running on Travis
@@ -188,7 +188,7 @@ add_celix_container(pubsub_websocket_tests
             pubsub_sut
             pubsub_tst
 )
-target_link_libraries(pubsub_websocket_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson::lib Celix::dfi)
+target_link_libraries(pubsub_websocket_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson Celix::dfi)
 target_include_directories(pubsub_websocket_tests PRIVATE ${CPPUTEST_INCLUDE_DIR} test)
 add_test(NAME pubsub_websocket_tests COMMAND pubsub_websocket_tests WORKING_DIRECTORY $<TARGET_PROPERTY:pubsub_websocket_tests,CONTAINER_LOC>)
 SETUP_TARGET_FOR_COVERAGE(pubsub_websocket_tests_cov pubsub_websocket_tests ${CMAKE_BINARY_DIR}/coverage/pubsub_websocket_tests/pubsub_websocket_tests ..)
@@ -208,7 +208,7 @@ if (BUILD_PUBSUB_PSA_ZMQ)
                 pubsub_tst
     )
 
-    target_link_libraries(pubsub_zmq_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson::lib Celix::dfi)
+    target_link_libraries(pubsub_zmq_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson Celix::dfi)
     target_include_directories(pubsub_zmq_tests PRIVATE ${CPPUTEST_INCLUDE_DIR} test)
     add_test(NAME pubsub_zmq_tests COMMAND pubsub_zmq_tests WORKING_DIRECTORY $<TARGET_PROPERTY:pubsub_zmq_tests,CONTAINER_LOC>)
     SETUP_TARGET_FOR_COVERAGE(pubsub_zmq_tests_cov pubsub_zmq_tests ${CMAKE_BINARY_DIR}/coverage/pubsub_zmq_tests/pubsub_zmq_tests ..)
@@ -228,7 +228,7 @@ if (BUILD_PUBSUB_PSA_ZMQ)
                 pubsub_sut
                 pubsub_tst
     )
-    target_link_libraries(pubsub_zmq_zerocopy_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson::lib Celix::dfi)
+    target_link_libraries(pubsub_zmq_zerocopy_tests PRIVATE Celix::pubsub_api ${CPPUTEST_LIBRARIES} Jansson Celix::dfi)
     target_include_directories(pubsub_zmq_zerocopy_tests PRIVATE ${CPPUTEST_INCLUDE_DIR} test)
     add_test(NAME pubsub_zmq_zerocopy_tests COMMAND pubsub_zmq_zerocopy_tests WORKING_DIRECTORY $<TARGET_PROPERTY:pubsub_zmq_zerocopy_tests,CONTAINER_LOC>)
     SETUP_TARGET_FOR_COVERAGE(pubsub_zmq_zerocopy_tests_cov pubsub_zmq_zerocopy_tests ${CMAKE_BINARY_DIR}/coverage/pubsub_zmq_tests/pubsub_zmq_zerocopy_tests ..)
diff --git a/bundles/remote_services/discovery_etcd/CMakeLists.txt b/bundles/remote_services/discovery_etcd/CMakeLists.txt
index a6fce5b..41e6f83 100644
--- a/bundles/remote_services/discovery_etcd/CMakeLists.txt
+++ b/bundles/remote_services/discovery_etcd/CMakeLists.txt
@@ -43,7 +43,7 @@ if (RSA_DISCOVERY_ETCD)
 			${CURL_INCLUDE_DIR}
 			${LIBXML2_INCLUDE_DIR}
 	)
-	target_link_libraries(rsa_discovery_etcd PRIVATE CURL::libcurl ${LIBXML2_LIBRARIES} Jansson::lib)
+	target_link_libraries(rsa_discovery_etcd PRIVATE CURL::libcurl ${LIBXML2_LIBRARIES} Jansson)
 
 	install_celix_bundle(rsa_discovery_etcd EXPORT celix COMPONENT rsa)
 	#Setup target aliases to match external usage
diff --git a/bundles/remote_services/remote_service_admin_dfi/CMakeLists.txt b/bundles/remote_services/remote_service_admin_dfi/CMakeLists.txt
index bffb937..eccf62c 100644
--- a/bundles/remote_services/remote_service_admin_dfi/CMakeLists.txt
+++ b/bundles/remote_services/remote_service_admin_dfi/CMakeLists.txt
@@ -45,7 +45,7 @@ if (RSA_REMOTE_SERVICE_ADMIN_DFI)
             Celix::log_helper
             Celix::rsa_common
             CURL::libcurl
-            Jansson::lib
+            Jansson
     )
 
     if (ENABLE_TESTING)
diff --git a/bundles/remote_services/topology_manager/tms_tst/CMakeLists.txt b/bundles/remote_services/topology_manager/tms_tst/CMakeLists.txt
index 22b4377..8339f7c 100644
--- a/bundles/remote_services/topology_manager/tms_tst/CMakeLists.txt
+++ b/bundles/remote_services/topology_manager/tms_tst/CMakeLists.txt
@@ -41,7 +41,7 @@ target_include_directories(test_tm_scoped PRIVATE ../src ../include)
 target_link_libraries(test_tm_scoped PRIVATE
         Celix::framework
         ${CPPUTEST_LIBRARY}
-        Jansson::lib
+        Jansson
         calculator_api
         Celix::rsa_common
 )
diff --git a/cmake/Modules/FindJansson.cmake b/cmake/Modules/FindJansson.cmake
index 1235da9..45ee311 100644
--- a/cmake/Modules/FindJansson.cmake
+++ b/cmake/Modules/FindJansson.cmake
@@ -18,41 +18,40 @@
 
 # - Try to find Jansson
 # Once done this will define
-#  Jansson - System has Jansson
-#  Jansson_INCLUDE_DIRS - The Jansson include directories
-#  Jansson_LIBRARIES - The libraries needed to use Jansson
-#  Jansson_DEFINITIONS - Compiler switches required for using Jansson
-#  Jansson::lib - Imported target for Jansson
+#  JANSSON_FOUND - System has Jansson
+#  JANSSON_INCLUDE_DIRS - The Jansson include directories
+#  JANSSON_LIBRARIES - The libraries needed to use Jansson
+#  Jansson - Imported target for Jansson
 
-find_path(Jansson_INCLUDE_DIR jansson.h
+find_path(JANSSON_INCLUDE_DIR jansson.h
           /usr/include
           /usr/local/include )
 
-find_library(Jansson_LIBRARY NAMES jansson
+find_library(JANSSON_LIBRARY NAMES jansson
              PATHS /usr/lib /usr/local/lib )
 
-set(Jansson_LIBRARIES ${Jansson_LIBRARY} )
-set(Jansson_INCLUDE_DIRS ${Jansson_INCLUDE_DIR} )
+set(JANSSON_LIBRARIES ${JANSSON_LIBRARY} )
+set(JANSSON_INCLUDE_DIRS ${JANSSON_INCLUDE_DIR} )
 
 include(FindPackageHandleStandardArgs)
 # handle the QUIETLY and REQUIRED arguments and set JANSSON_FOUND to TRUE
 # if all listed variables are TRUE
 find_package_handle_standard_args(Jansson  DEFAULT_MSG
-                                  Jansson_LIBRARY Jansson_INCLUDE_DIR)
+                                  JANSSON_LIBRARY JANSSON_INCLUDE_DIR)
 
-mark_as_advanced(Jansson_INCLUDE_DIR Jansson_LIBRARY)
+mark_as_advanced(JANSSON_INCLUDE_DIR JANSSON_LIBRARY)
 
-if (Jansson_FOUND AND NOT TARGET Jansson::lib)
-    add_library(Jansson::lib SHARED IMPORTED)
-    set_target_properties(Jansson::lib PROPERTIES
-            IMPORTED_LOCATION "${Jansson_LIBRARY}"
-            INTERFACE_INCLUDE_DIRECTORIES "${Jansson_INCLUDE_DIR}"
+if (JANSSON_FOUND AND NOT TARGET Jansson)
+    add_library(Jansson SHARED IMPORTED)
+    set_target_properties(Jansson PROPERTIES
+            IMPORTED_LOCATION "${JANSSON_LIBRARY}"
+            INTERFACE_INCLUDE_DIRECTORIES "${JANSSON_INCLUDE_DIR}"
     )
 
 endif ()
 
 #For backward compatability
-set(JANSSON_LIBRARY ${Jansson_LIBRARY})
-set(JANSSON_LIBRARIES ${Jansson_LIBRARY})
-set(JANSSON_INCLUDE_DIR ${Jansson_INCLUDE_DIR})
-set(JANSSON_INCLUDE_DIRS ${Jansson_INCLUDE_DIR})
+set(JANSSON_LIBRARY ${JANSSON_LIBRARY})
+set(JANSSON_LIBRARIES ${JANSSON_LIBRARY})
+set(JANSSON_INCLUDE_DIR ${JANSSON_INCLUDE_DIR})
+set(JANSSON_INCLUDE_DIRS ${JANSSON_INCLUDE_DIR})
diff --git a/cmake/Modules/FindNanoMsg.cmake b/cmake/Modules/FindNanoMsg.cmake
index a7578a7..9fdde2f 100644
--- a/cmake/Modules/FindNanoMsg.cmake
+++ b/cmake/Modules/FindNanoMsg.cmake
@@ -16,35 +16,35 @@
 # under the License.
 
 
-# - Try to find ZMQ
+# - Try to find NanoMsg
 # 	Once done this will define
-#  NanoMsg_FOUND - System has Nanomsg
-#  NanoMsg_INCLUDE_DIRS - The Nanomsg include directories
-#  NanoMsg_LIBRARIES - The libraries needed to use Nanomsg
+#  NANOMSG_FOUND - System has Nanomsg
+#  NANOMSG_INCLUDE_DIRS - The Nanomsg include directories
+#  NANOMSG_LIBRARIES - The libraries needed to use Nanomsg
 #  NanoMsg::lib - Imported target for Nanomsg
 
-find_path(NanoMsg_INCLUDE_DIR nanomsg/nn.h
+find_path(NANOMSG_INCLUDE_DIR nanomsg/nn.h
           /usr/include
           /usr/local/include )
 
-find_library(NanoMsg_LIBRARY NAMES nanomsg
+find_library(NANOMSG_LIBRARY NAMES nanomsg
              PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 )
 
-set(NanoMsg_LIBRARIES ${NanoMsg_LIBRARY} )
-set(NanoMsg_INCLUDE_DIRS ${NanoMsg_INCLUDE_DIR} )
+set(NANOMSG_LIBRARIES ${NANOMSG_LIBRARY} )
+set(NANOMSG_INCLUDE_DIRS ${NANOMSG_INCLUDE_DIR} )
 
 include(FindPackageHandleStandardArgs)
 # handle the QUIETLY and REQUIRED arguments and set ZMQ_FOUND to TRUE
 # if all listed variables are TRUE
 find_package_handle_standard_args(NanoMsg  DEFAULT_MSG
-        NanoMsg_LIBRARY NanoMsg_INCLUDE_DIR)
+        NANOMSG_LIBRARY NANOMSG_INCLUDE_DIR)
 
-mark_as_advanced(NanoMsg_INCLUDE_DIR NanoMsg_LIBRARY )
+mark_as_advanced(NANOMSG_INCLUDE_DIR NANOMSG_LIBRARY )
 
-if (NanoMsg_FOUND AND NOT TARGET NanoMsg::lib)
+if (NANOMSG_FOUND AND NOT TARGET NanoMsg::lib)
     add_library(NanoMsg::lib SHARED IMPORTED)
     set_target_properties(NanoMsg::lib PROPERTIES
-            IMPORTED_LOCATION "${NanoMsg_LIBRARY}"
-            INTERFACE_INCLUDE_DIRECTORIES "${NanoMsg_INCLUDE_DIR}"
+            IMPORTED_LOCATION "${NANOMSG_LIBRARY}"
+            INTERFACE_INCLUDE_DIRECTORIES "${NANOMSG_INCLUDE_DIR}"
     )
 endif ()
\ No newline at end of file
diff --git a/cmake/Modules/FindOpenSSL.cmake b/cmake/Modules/FindOpenSSL.cmake
index 801546d..eefbfaf 100644
--- a/cmake/Modules/FindOpenSSL.cmake
+++ b/cmake/Modules/FindOpenSSL.cmake
@@ -18,38 +18,38 @@
 
 # - Try to find OpenSSL
 # Once done this will define
-#  OpenSSL_FOUND - System has OpenSSL
-#  OpenSSL_INCLUDE_DIRS - The OpenSSL include directories
-#  OpenSSL_LIBRARIES - The libraries needed to use OpenSSL
+#  OPENSSL_FOUND - System has OpenSSL
+#  OPENSSL_INCLUDE_DIRS - The OpenSSL include directories
+#  OPENSSL_LIBRARIES - The libraries needed to use OpenSSL
 #  OpenSSL::lib - Imported target for OpenSSL
 
-find_path(OpenSSL_INCLUDE_DIR ssl.h crypto.h
+find_path(OPENSSL_INCLUDE_DIR ssl.h crypto.h
           /usr/include/openssl
           /usr/local/include/openssl 
           /usr/local/opt/openssl/include/openssl
-          ${OpenSSL_DIR}/include/openssl)
+          ${OPENSSL_DIR}/include/openssl)
 
-find_library(OpenSSL_LIBRARY NAMES ssl
-             PATHS /usr/lib /usr/local/lib  /usr/local/opt/openssl/lib ${OpenSSL_DIR}/lib)
+find_library(OPENSSL_LIBRARY NAMES ssl
+             PATHS /usr/lib /usr/local/lib  /usr/local/opt/openssl/lib ${OPENSSL_DIR}/lib)
 
-find_library(Crypto_LIBRARY NAMES crypto
-             PATHS /usr/lib /usr/local/lib  /usr/local/opt/openssl/lib ${OpenSSL_DIR}/lib)
+find_library(CRYPTO_LIBRARY NAMES crypto
+             PATHS /usr/lib /usr/local/lib  /usr/local/opt/openssl/lib ${OPENSSL_DIR}/lib)
 
-set(OPENSSL_LIBRARIES ${OpenSSL_LIBRARY} ${CRYPTO_LIBRARY})
-set(OPENSSL_INCLUDE_DIRS ${OpenSSL_INCLUDE_DIR})
+set(OPENSSL_LIBRARIES ${OPENSSL_LIBRARY} ${CRYPTO_LIBRARY})
+set(OPENSSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
 
 include(FindPackageHandleStandardArgs)
 # handle the QUIETLY and REQUIRED arguments and set OPENSSL_FOUND to TRUE
 # if all listed variables are TRUE
 find_package_handle_standard_args(OpenSSL  DEFAULT_MSG
-              OpenSSL_LIBRARY Crypto_LIBRARY OpenSSL_INCLUDE_DIR)
+              OPENSSL_LIBRARY CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
 
-mark_as_advanced(OpenSSL_INCLUDE_DIR OpenSSL_LIBRARY Crypto_LIBRARY)
+mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARY CRYPTO_LIBRARY)
 
-if (OpenSSL_FOUND AND NOT TARGET OpenSSL::lib)
+if (OPENSSL_FOUND AND NOT TARGET OpenSSL::lib)
     add_library(OpenSSL::lib SHARED IMPORTED)
     set_target_properties(OpenSSL::lib PROPERTIES
-            IMPORTED_LOCATION "${OpenSSL_LIBRARY};${Crypto_LIBRARY}"
-            INTERFACE_INCLUDE_DIRECTORIES "${OpenSSL_INCLUDE_DIR}"
+            IMPORTED_LOCATION "${OPENSSL_LIBRARY};${CRYPTO_LIBRARY}"
+            INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}"
     )
 endif ()
\ No newline at end of file
diff --git a/cmake/cmake_celix/UseCelix.cmake b/cmake/cmake_celix/UseCelix.cmake
index 84b2a2b..0e98b53 100644
--- a/cmake/cmake_celix/UseCelix.cmake
+++ b/cmake/cmake_celix/UseCelix.cmake
@@ -37,19 +37,31 @@ find_package(Jansson REQUIRED) #etcdlib, dfi
 find_package(FFI REQUIRED) #dfi
 
 if (NOT TARGET ZLIB::ZLIB)
-    message("Note ZLIB::ZLIB target not created by find_package(ZLIB). Creating one")
+    #Note more recent zlib will create ZLIB::ZLIB target
+    message("Note ZLIB::ZLIB target not created by find_package(ZLIB). Creating ZLIB::ZLIB Target.")
     add_library(ZLIB::ZLIB SHARED IMPORTED)
     set_target_properties(ZLIB::ZLIB PROPERTIES
             IMPORTED_LOCATION "${ZLIB_LIBRARIES}"
             INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}"
-            )
+    )
 endif ()
 
 if (NOT TARGET CURL::libcurl)
-    message("Note CURL::libcurl target not created by find_package(CURL). Creating one")
+    #Note more recent curl will create CURL::libcurl target
+    message("Note CURL::libcurl target not created by find_package(CURL). Creating CURL::libcurl Target.")
     add_library(CURL::libcurl SHARED IMPORTED)
     set_target_properties(CURL::libcurl PROPERTIES
             IMPORTED_LOCATION "${CURL_LIBRARIES}"
             INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}"
-            )
+    )
+endif ()
+
+if (NOT TARGET Jansson)
+    #Note if JanssonConfig is present on system this is not needed
+    message("Note Jansson target not created by find_package(Jansson). Creating Jansson Target.")
+    add_library(Jansson SHARED IMPORTED)
+    set_target_properties(Jansson PROPERTIES
+            IMPORTED_LOCATION "${JANSSON_LIBRARY}"
+            INTERFACE_INCLUDE_DIRECTORIES "${JANSSON_INCLUDE_DIR}"
+    )
 endif ()
diff --git a/libs/dfi/CMakeLists.txt b/libs/dfi/CMakeLists.txt
index 4f7aeac..3a18c1b 100644
--- a/libs/dfi/CMakeLists.txt
+++ b/libs/dfi/CMakeLists.txt
@@ -40,7 +40,7 @@ target_include_directories(dfi PUBLIC
 )
 
 target_link_libraries(dfi PRIVATE FFI::lib)
-target_link_libraries(dfi PUBLIC Jansson::lib)
+target_link_libraries(dfi PUBLIC Jansson)
 target_link_libraries(dfi PRIVATE Celix::utils)
 set_target_properties(dfi PROPERTIES "SOVERSION" 1)
 
@@ -68,7 +68,7 @@ if (ENABLE_TESTING)
 		test/run_tests.cpp
 	)
 
-    target_link_libraries(test_dfi PRIVATE Celix::dfi Celix::utils FFI::lib Jansson::lib ${CPPUTEST_LIBRARIES})
+    target_link_libraries(test_dfi PRIVATE Celix::dfi Celix::utils FFI::lib Jansson ${CPPUTEST_LIBRARIES})
 
     file(COPY ${CMAKE_CURRENT_LIST_DIR}/test/schemas DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
     file(COPY ${CMAKE_CURRENT_LIST_DIR}/test/descriptors DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/libs/etcdlib/CMakeLists.txt b/libs/etcdlib/CMakeLists.txt
index 98227f6..42ede14 100644
--- a/libs/etcdlib/CMakeLists.txt
+++ b/libs/etcdlib/CMakeLists.txt
@@ -53,7 +53,7 @@ target_include_directories(etcdlib PRIVATE src)
 
 set_target_properties(etcdlib PROPERTIES SOVERSION 1)
 set_target_properties(etcdlib PROPERTIES VERSION 1.0.0)
-target_link_libraries(etcdlib PUBLIC CURL::libcurl Jansson::lib)
+target_link_libraries(etcdlib PUBLIC CURL::libcurl Jansson)
 
 add_library(etcdlib_static STATIC
     src/etcd.c
@@ -64,10 +64,10 @@ target_include_directories(etcdlib_static PUBLIC
 )
 target_include_directories(etcdlib_static PRIVATE src)
 set_target_properties(etcdlib_static PROPERTIES "SOVERSION" 1)
-target_link_libraries(etcdlib_static PUBLIC CURL::libcurl Jansson::lib)
+target_link_libraries(etcdlib_static PUBLIC CURL::libcurl Jansson)
 
 add_executable(etcdlib_test ${CMAKE_CURRENT_SOURCE_DIR}/test/etcdlib_test.c)
-target_link_libraries(etcdlib_test PRIVATE etcdlib_static CURL::libcurl Jansson::lib)
+target_link_libraries(etcdlib_test PRIVATE etcdlib_static CURL::libcurl Jansson)
 
 #TODO install etcdlib_static. For now left out, because the imported target leaks library paths
 install(DIRECTORY api/ DESTINATION include/etcdlib COMPONENT ${ETCDLIB_CMP})


[celix] 01/02: #80: Updates error handling of failed lib loading for bundles.

Posted by pn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/#80_bundle_start_with_exception
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 402e9f538ce59da6ca05614ddb2deb365360cb8c
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Tue Oct 8 15:18:32 2019 +0200

    #80: Updates error handling of failed lib loading for bundles.
---
 libs/framework/src/framework.c                     | 32 +++++++++++-----------
 libs/framework/tst/CMakeLists.txt                  |  9 ++++--
 .../framework/tst/bundle_context_bundles_tests.cpp | 13 +++++++++
 libs/framework/tst/subdir/CMakeLists.txt           |  2 ++
 libs/framework/tst/subdir/src/foo.c                | 26 ++++++++++++++++++
 5 files changed, 64 insertions(+), 18 deletions(-)

diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index 17d56f3..34363ca 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -912,8 +912,10 @@ celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int opti
                     if (wires == NULL) {
                         return CELIX_BUNDLE_EXCEPTION;
                     }
-                    framework_markResolvedModules(framework, wires);
-
+                    status = framework_markResolvedModules(framework, wires);
+                    if (status != CELIX_SUCCESS) {
+                        break;
+                    }
                 }
                 /* no break */
             case OSGI_FRAMEWORK_BUNDLE_RESOLVED:
@@ -1867,6 +1869,7 @@ long framework_getNextBundleId(framework_pt framework) {
 }
 
 celix_status_t framework_markResolvedModules(framework_pt framework, linked_list_pt resolvedModuleWireMap) {
+    celix_status_t status = CELIX_SUCCESS;
     if (resolvedModuleWireMap != NULL) {
         // hash_map_iterator_pt iterator = hashMapIterator_create(resolvedModuleWireMap);
         linked_list_iterator_pt iterator = linkedListIterator_create(resolvedModuleWireMap, linkedList_size(resolvedModuleWireMap));
@@ -1923,21 +1926,21 @@ celix_status_t framework_markResolvedModules(framework_pt framework, linked_list
 //                printf("Module %s imports library %s:%s from %s\n", importerName, name, versionString, exporterName);
 //			}
 
-            module_setWires(module, wires);
-
-            module_setResolved(module);
-            resolver_moduleResolved(module);
-
-            const char *mname = NULL;
-            module_getSymbolicName(module, &mname);
-            framework_markBundleResolved(framework, module);
+            if (status == CELIX_SUCCESS) {
+                module_setWires(module, wires);
+                module_setResolved(module);
+                resolver_moduleResolved(module);
+                const char *mname = NULL;
+                module_getSymbolicName(module, &mname);
+                status = framework_markBundleResolved(framework, module);
+            }
             linkedListIterator_remove(iterator);
             free(iw);
         }
         linkedListIterator_destroy(iterator);
         linkedList_destroy(resolvedModuleWireMap);
     }
-    return CELIX_SUCCESS;
+    return status;
 }
 
 celix_status_t framework_markBundleResolved(framework_pt framework, module_pt module) {
@@ -1984,7 +1987,7 @@ celix_status_t framework_markBundleResolved(framework_pt framework, module_pt mo
         fw_bundleEntry_decreaseUseCount(framework, bndId);
     }
 
-    return CELIX_SUCCESS;
+    return status;
 }
 
 array_list_pt framework_getBundles(framework_pt framework) {
@@ -2425,8 +2428,7 @@ static celix_status_t framework_loadBundleLibraries(framework_pt framework, bund
 
         if (status == CELIX_SUCCESS) {
             bundle_setHandle(bundle, handle);
-        }
-        else if(handle != NULL){
+        } else if (handle != NULL) {
             celix_libloader_close(handle);
         }
     }
@@ -2480,8 +2482,6 @@ static celix_status_t framework_loadLibraries(framework_pt framework, const char
         token = strtok_r(NULL, ",", &last);
     }
 
-    framework_logIfError(framework->logger, status, NULL, "Could not load all libraries");
-
     free(libraries);
     return status;
 }
diff --git a/libs/framework/tst/CMakeLists.txt b/libs/framework/tst/CMakeLists.txt
index 4466761..33a5efd 100644
--- a/libs/framework/tst/CMakeLists.txt
+++ b/libs/framework/tst/CMakeLists.txt
@@ -19,7 +19,12 @@ add_celix_bundle(simple_test_bundle1 NO_ACTIVATOR VERSION 1.0.0)
 add_celix_bundle(simple_test_bundle2 NO_ACTIVATOR VERSION 1.0.0)
 add_celix_bundle(simple_test_bundle3 NO_ACTIVATOR VERSION 1.0.0)
 add_celix_bundle(bundle_with_exception SOURCES nop_activator.c VERSION 1.0.0)
-add_subdirectory(subdir) #simple_test_bundle4 and simeple_test_bundle5
+add_subdirectory(subdir) #simple_test_bundle4, simple_test_bundle5 and sublib
+
+add_celix_bundle(unresolveable_bundle SOURCES nop_activator.c VERSION 1.0.0)
+target_link_directories(unresolveable_bundle PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/subdir)
+target_link_libraries(unresolveable_bundle PRIVATE "-lsublib")
+add_dependencies(unresolveable_bundle sublib)
 
 add_executable(test_framework
     run_tests.cpp
@@ -31,7 +36,7 @@ add_executable(test_framework
 )
 
 target_link_libraries(test_framework Celix::framework CURL::libcurl ${CPPUTEST_LIBRARY})
-add_dependencies(test_framework simple_test_bundle1_bundle simple_test_bundle2_bundle simple_test_bundle3_bundle simple_test_bundle4_bundle simple_test_bundle5_bundle bundle_with_exception)
+add_dependencies(test_framework simple_test_bundle1_bundle simple_test_bundle2_bundle simple_test_bundle3_bundle simple_test_bundle4_bundle simple_test_bundle5_bundle bundle_with_exception_bundle unresolveable_bundle_bundle)
 target_include_directories(test_framework PRIVATE ../src)
 
 configure_file(config.properties.in config.properties @ONLY)
diff --git a/libs/framework/tst/bundle_context_bundles_tests.cpp b/libs/framework/tst/bundle_context_bundles_tests.cpp
index f193173..f173c96 100644
--- a/libs/framework/tst/bundle_context_bundles_tests.cpp
+++ b/libs/framework/tst/bundle_context_bundles_tests.cpp
@@ -42,6 +42,7 @@ TEST_GROUP(CelixBundleContextBundlesTests) {
     const char * const TEST_BND4_LOC = "simple_test_bundle4.zip";
     const char * const TEST_BND5_LOC = "simple_test_bundle5.zip";
     const char * const TEST_BND_WITH_EXCEPTION_LOC = "bundle_with_exception.zip";
+    const char * const TEST_BND_UNRESOLVEABLE_LOC = "unresolveable_bundle.zip";
 
     void setup() {
         properties = properties_create();
@@ -102,6 +103,18 @@ TEST(CelixBundleContextBundlesTests, startBundleWithException) {
     CHECK_TRUE(called);
 }
 
+
+TEST(CelixBundleContextBundlesTests, startUnresolveableBundle) {
+    long bndId = celix_bundleContext_installBundle(ctx, TEST_BND_UNRESOLVEABLE_LOC, true);
+    CHECK(bndId > 0); //bundle is installed, but not resolved
+
+    bool called = celix_framework_useBundle(fw, false, bndId, nullptr, [](void */*handle*/, const celix_bundle_t *bnd) {
+        auto state = celix_bundle_getState(bnd);
+        CHECK_EQUAL(state, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
+    });
+    CHECK_TRUE(called);
+}
+
 TEST(CelixBundleContextBundlesTests, useBundleTest) {
     int count = 0;
 
diff --git a/libs/framework/tst/subdir/CMakeLists.txt b/libs/framework/tst/subdir/CMakeLists.txt
index 5853a86..4956e3e 100644
--- a/libs/framework/tst/subdir/CMakeLists.txt
+++ b/libs/framework/tst/subdir/CMakeLists.txt
@@ -17,3 +17,5 @@
 
 add_celix_bundle(simple_test_bundle4 NO_ACTIVATOR VERSION 1.0.0)
 add_celix_bundle(simple_test_bundle5 NO_ACTIVATOR VERSION 1.0.0)
+
+add_library(sublib SHARED src/foo.c)
diff --git a/libs/framework/tst/subdir/src/foo.c b/libs/framework/tst/subdir/src/foo.c
new file mode 100644
index 0000000..6f56eb7
--- /dev/null
+++ b/libs/framework/tst/subdir/src/foo.c
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+
+void foo(void);
+
+void foo(void) {
+    printf("nop\n");
+}