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

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

commit d2240029b26e9f44fd97b33cc5bd08bc12f94e39
Author: Pepijn Noltes <[email protected]>
AuthorDate: Mon Apr 10 22:49:36 2023 +0200

    Add linker script for add_celix_bundle so minimize bundle lib size
---
 cmake/cmake_celix/BundlePackaging.cmake                          | 4 ++++
 .../cmake_celix/templates/make_only_activator_symbols_global.map | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/cmake/cmake_celix/BundlePackaging.cmake 
b/cmake/cmake_celix/BundlePackaging.cmake
index 80255ce8..90f312ce 100644
--- a/cmake/cmake_celix/BundlePackaging.cmake
+++ b/cmake/cmake_celix/BundlePackaging.cmake
@@ -355,6 +355,10 @@ function(add_celix_bundle)
         set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES 
"BUNDLE_ACTIVATOR" "$<TARGET_SONAME_FILE_NAME:${BUNDLE_TARGET_NAME}>")
         set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES 
"BUILD_WITH_INSTALL_RPATH" true)
 
+        #TBD: The linker script ensures that only the activator symbols are 
exported, this can reduce the bundle size.
+        #     If this is done, there should also be an option to disable this 
behaviour.
+        target_link_libraries(${BUNDLE_TARGET_NAME} PRIVATE 
"-Wl,--version-script=${CELIX_CMAKE_DIRECTORY}/templates/make_only_activator_symbols_global.map")
+
         if(APPLE)
             set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES 
INSTALL_RPATH "@loader_path")
         else()
diff --git a/cmake/cmake_celix/templates/make_only_activator_symbols_global.map 
b/cmake/cmake_celix/templates/make_only_activator_symbols_global.map
new file mode 100644
index 00000000..43446eb8
--- /dev/null
+++ b/cmake/cmake_celix/templates/make_only_activator_symbols_global.map
@@ -0,0 +1,9 @@
+{
+    global:
+        celix_bundleActivator_create;
+        celix_bundleActivator_start;
+        celix_bundleActivator_stop;
+        celix_bundleActivator_destroy;
+    local:
+        *;
+};
\ No newline at end of file

Reply via email to