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

pengzheng pushed a commit to branch feature/remove_dfi_dep
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/feature/remove_dfi_dep by this 
push:
     new ff553fc3 Make ffi a private dependency of dfi.
ff553fc3 is described below

commit ff553fc38582862ac235be23982a888311159ea8
Author: PengZheng <[email protected]>
AuthorDate: Mon Feb 6 21:12:14 2023 +0800

    Make ffi a private dependency of dfi.
---
 bundles/http_admin/gtest/CMakeLists.txt          |  1 -
 bundles/pubsub/CMakeLists.txt                    |  2 +-
 bundles/remote_services/CMakeLists.txt           |  2 +-
 conanfile.py                                     |  8 ++-
 libs/dfi/CMakeLists.txt                          | 71 ++++++++++++------------
 libs/dfi/gtest/CMakeLists.txt                    |  1 +
 libs/dfi/src/dyn_function.c                      |  2 +-
 libs/dfi/{include => src}/dyn_function_common.h  |  0
 libs/dfi/{include => src}/dyn_interface_common.h |  0
 libs/dfi/src/dyn_type.c                          |  2 +-
 libs/dfi/{include => src}/dyn_type_common.h      |  0
 libs/dfi/src/json_rpc.c                          |  2 +-
 12 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/bundles/http_admin/gtest/CMakeLists.txt 
b/bundles/http_admin/gtest/CMakeLists.txt
index afc17329..3e9c8f6e 100644
--- a/bundles/http_admin/gtest/CMakeLists.txt
+++ b/bundles/http_admin/gtest/CMakeLists.txt
@@ -15,7 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-find_package(jansson REQUIRED)
 
 add_celix_bundle(http_admin_sut
     #"Vanilla" bundle which is under test
diff --git a/bundles/pubsub/CMakeLists.txt b/bundles/pubsub/CMakeLists.txt
index bf8fe5f6..b4985be6 100644
--- a/bundles/pubsub/CMakeLists.txt
+++ b/bundles/pubsub/CMakeLists.txt
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-celix_subproject(PUBSUB "Option to build the pubsub bundles" ON)
+celix_subproject(PUBSUB "Option to build the pubsub bundles" ON DEPS CELIX_DFI)
 if (PUBSUB)
     add_subdirectory(pubsub_api)
     add_subdirectory(pubsub_utils)
diff --git a/bundles/remote_services/CMakeLists.txt 
b/bundles/remote_services/CMakeLists.txt
index 86a08d63..60d122ad 100644
--- a/bundles/remote_services/CMakeLists.txt
+++ b/bundles/remote_services/CMakeLists.txt
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-celix_subproject(REMOTE_SERVICE_ADMIN "Option to enable building the Remote 
Service Admin Service bundles" ON)
+celix_subproject(REMOTE_SERVICE_ADMIN "Option to enable building the Remote 
Service Admin Service bundles" ON DEPS CELIX_DFI)
 if (REMOTE_SERVICE_ADMIN)
 
     add_subdirectory(thpool)
diff --git a/conanfile.py b/conanfile.py
index 4b9b81bf..7c7aa207 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -77,6 +77,7 @@ class CelixConan(ConanFile):
         "build_promises": [True, False],
         "build_pushstreams": [True, False],
         "build_experimental": [True, False],
+        "build_dfi": [True, False],
         "celix_cxx14": [True, False],
         "celix_cxx17": [True, False],
         "celix_install_deprecated_api": [True, False],
@@ -122,6 +123,7 @@ class CelixConan(ConanFile):
         "build_promises": False,
         "build_pushstreams": False,
         "build_experimental": False,
+        "build_dfi": True,
         "celix_cxx14": True,
         "celix_cxx17": True,
         "celix_install_deprecated_api": False,
@@ -191,8 +193,6 @@ class CelixConan(ConanFile):
             self.options.build_shell_bonjour = False
 
     def requirements(self):
-        self.requires("libffi/[>=3.2.1 <4.0.0]")
-        self.options['libffi'].shared = True
         self.requires("jansson/[>=2.12 <3.0.0]")
         self.options['jansson'].shared = True
         self.requires("libcurl/[>=7.64.1 <8.0.0]")
@@ -223,6 +223,10 @@ class CelixConan(ConanFile):
             self.options['zeromq'].shared = True
             self.requires("czmq/4.2.0")
             self.options['czmq'].shared = True
+        if self.options.build_dfi:
+            self.requires("libffi/[>=3.2.1 <4.0.0]")
+            self.options['libffi'].shared = True
+
 
     def _configure_cmake(self):
         if self._cmake:
diff --git a/libs/dfi/CMakeLists.txt b/libs/dfi/CMakeLists.txt
index 6c035f41..f011f3f3 100644
--- a/libs/dfi/CMakeLists.txt
+++ b/libs/dfi/CMakeLists.txt
@@ -15,43 +15,46 @@
 # specific language governing permissions and limitations
 # under the License.
 
-find_package(libffi REQUIRED)
-find_package(jansson REQUIRED)
+celix_subproject(CELIX_DFI "Option to enable building the dynamic function 
interface library" ON)
+if (CELIX_DFI)
+       find_package(libffi REQUIRED)
+       find_package(jansson REQUIRED)
 
-set(SOURCES
-       src/dyn_common.c
-       src/dyn_type_common.c
-       src/dyn_type.c
-       src/dyn_avpr_type.c
-       src/dyn_function.c
-       src/dyn_avpr_function.c
-       src/dyn_interface.c
-       src/dyn_avpr_interface.c
-       src/dyn_message.c
-       src/json_serializer.c
-       src/json_rpc.c
-       src/avrobin_serializer.c
-)
+       set(SOURCES
+                       src/dyn_common.c
+                       src/dyn_type_common.c
+                       src/dyn_type.c
+                       src/dyn_avpr_type.c
+                       src/dyn_function.c
+                       src/dyn_avpr_function.c
+                       src/dyn_interface.c
+                       src/dyn_avpr_interface.c
+                       src/dyn_message.c
+                       src/json_serializer.c
+                       src/json_rpc.c
+                       src/avrobin_serializer.c
+                       )
 
-add_library(dfi SHARED ${SOURCES})
-set_target_properties(dfi PROPERTIES OUTPUT_NAME "celix_dfi")
-target_include_directories(dfi PUBLIC
-       $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
-       $<INSTALL_INTERFACE:include/celix/dfi>
-)
-target_link_libraries(dfi PRIVATE libffi::libffi)
-target_link_libraries(dfi PUBLIC jansson::jansson)
-target_link_libraries(dfi PRIVATE Celix::utils)
-set_target_properties(dfi PROPERTIES "SOVERSION" 1)
+       add_library(dfi SHARED ${SOURCES})
+       set_target_properties(dfi PROPERTIES OUTPUT_NAME "celix_dfi")
+       target_include_directories(dfi PUBLIC
+                       $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
+                       $<INSTALL_INTERFACE:include/celix/dfi>
+                       )
+       target_link_libraries(dfi PRIVATE libffi::libffi)
+       target_link_libraries(dfi PUBLIC jansson::jansson)
+       target_link_libraries(dfi PRIVATE Celix::utils)
+       set_target_properties(dfi PROPERTIES "SOVERSION" 1)
 
-install(TARGETS dfi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT 
dfi
-               INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/dfi)
-install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix/dfi 
COMPONENT dfi)
+       install(TARGETS dfi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} 
COMPONENT dfi
+                       INCLUDES DESTINATION 
${CMAKE_INSTALL_INCLUDEDIR}/celix/dfi)
+       install(DIRECTORY include/ DESTINATION 
${CMAKE_INSTALL_INCLUDEDIR}/celix/dfi COMPONENT dfi)
 
-#Alias setup to match external usage
-add_library(Celix::dfi ALIAS dfi)
+       #Alias setup to match external usage
+       add_library(Celix::dfi ALIAS dfi)
 
-if (ENABLE_TESTING)
-       add_subdirectory(gtest)
-endif(ENABLE_TESTING)
+       if (ENABLE_TESTING)
+               add_subdirectory(gtest)
+       endif(ENABLE_TESTING)
+endif (CELIX_DFI)
 
diff --git a/libs/dfi/gtest/CMakeLists.txt b/libs/dfi/gtest/CMakeLists.txt
index cce1ac4a..2ae8c232 100644
--- a/libs/dfi/gtest/CMakeLists.txt
+++ b/libs/dfi/gtest/CMakeLists.txt
@@ -39,6 +39,7 @@ See issue #232
 ]]
 target_compile_options(test_dfi PRIVATE -O0) #This is needed because
 
+target_include_directories(test_dfi PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../src)
 target_link_libraries(test_dfi PRIVATE Celix::dfi Celix::utils libffi::libffi 
jansson::jansson GTest::gtest GTest::gtest_main)
 celix_deprecated_utils_headers(test_dfi)
 
diff --git a/libs/dfi/src/dyn_function.c b/libs/dfi/src/dyn_function.c
index 2e7cd98d..89583ce5 100644
--- a/libs/dfi/src/dyn_function.c
+++ b/libs/dfi/src/dyn_function.c
@@ -23,7 +23,7 @@
 #include <strings.h>
 #include <stdlib.h>
 #include <ffi.h>
-#include <dyn_type_common.h>
+#include "dyn_type_common.h"
 
 static const int OK = 0;
 static const int MEM_ERROR = 1;
diff --git a/libs/dfi/include/dyn_function_common.h 
b/libs/dfi/src/dyn_function_common.h
similarity index 100%
rename from libs/dfi/include/dyn_function_common.h
rename to libs/dfi/src/dyn_function_common.h
diff --git a/libs/dfi/include/dyn_interface_common.h 
b/libs/dfi/src/dyn_interface_common.h
similarity index 100%
rename from libs/dfi/include/dyn_interface_common.h
rename to libs/dfi/src/dyn_interface_common.h
diff --git a/libs/dfi/src/dyn_type.c b/libs/dfi/src/dyn_type.c
index 0972cb4a..108f492e 100644
--- a/libs/dfi/src/dyn_type.c
+++ b/libs/dfi/src/dyn_type.c
@@ -24,7 +24,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <ffi.h>
-#include <dyn_type_common.h>
+#include "dyn_type_common.h"
 
 #include "dyn_type_common.h"
 #include "dyn_common.h"
diff --git a/libs/dfi/include/dyn_type_common.h b/libs/dfi/src/dyn_type_common.h
similarity index 100%
rename from libs/dfi/include/dyn_type_common.h
rename to libs/dfi/src/dyn_type_common.h
diff --git a/libs/dfi/src/json_rpc.c b/libs/dfi/src/json_rpc.c
index 7203a43e..79495177 100644
--- a/libs/dfi/src/json_rpc.c
+++ b/libs/dfi/src/json_rpc.c
@@ -26,7 +26,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <ffi.h>
-#include <dyn_type_common.h>
+#include "dyn_type_common.h"
 
 static int OK = 0;
 static int ERROR = 1;

Reply via email to