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 2024/05/30 17:24:10 UTC
(celix) 02/05: gh-685: Refactor config prop cmake gen and test config props
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/685-update-container-config-properties-usage
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 74f425794cadb0b7ce71056da9727b178eaca4f2
Author: Pepijn Noltes <pn...@apache.org>
AuthorDate: Thu May 30 15:42:43 2024 +0200
gh-685: Refactor config prop cmake gen and test config props
---
CHANGES.md | 2 +-
.../gtest/client.properties.in | 21 ++--
.../gtest/config.properties.in | 25 +----
.../gtest/server.properties.in | 37 ++-----
.../topology_manager/tms_tst/CMakeLists.txt | 20 ++--
cmake/cmake_celix/BundlePackaging.cmake | 26 ++---
cmake/cmake_celix/ContainerPackaging.cmake | 123 ++++++++++++---------
.../bundle_with_private_lib/CMakeLists.txt | 2 +-
.../celix-examples/hello_world_c/CMakeLists.txt | 3 +-
libs/framework/gtest/config.properties.in | 23 +---
libs/framework/gtest/framework1.properties.in | 25 +----
libs/framework/gtest/framework2.properties.in | 25 +----
.../gtest/install_and_start_bundles.properties.in | 33 +-----
libs/framework/src/celix_launcher.c | 59 ++++++----
libs/utils/gtest/CMakeLists.txt | 4 +-
.../config_admin_tst/config.properties.in | 25 +----
16 files changed, 188 insertions(+), 265 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 2720590a4..593decd40 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -33,7 +33,7 @@ limitations under the License.
- pubsub_serializer.h is removed and no longer supported. Use pubsub_message_serialization_service.h instead.
- C++11 support for dm is removed. C++14 is now the minimum required version.
- C++17 string_view support is removed from the utils and framework lib.
-- Apache Celix CMake bundle functions without a celix_ prefix or infix are removed.
+- Apache Celix CMake container & bundle functions without a celix_ prefix or infix are removed.
- Apache Celix CMake support for creating docker images and creating runtimes dirs is removed.
- Support and usage of "service.lang" service property is removed.
- Rename of `CELIX_FRAMEWORK_FRAMEWORK_CACHE_DIR` config property to `CELIX_FRAMEWORK_CACHE_DIR`.
diff --git a/bundles/remote_services/remote_service_admin_dfi/gtest/client.properties.in b/bundles/remote_services/remote_service_admin_dfi/gtest/client.properties.in
index 506ed25ea..00ef4e8cd 100644
--- a/bundles/remote_services/remote_service_admin_dfi/gtest/client.properties.in
+++ b/bundles/remote_services/remote_service_admin_dfi/gtest/client.properties.in
@@ -1,10 +1,11 @@
-CELIX_AUTO_START_1=@rsa_bundle_file@ @discovery_bundle_file@ @topology_manager_bundle_file@ @tst_bundle_file@
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
-CELIX_FRAMEWORK_CACHE_DIR=.cacheClient
-
-DISCOVERY_CFG_POLL_INTERVAL=1
-DISCOVERY_CFG_POLL_TIMEOUT=5
-RSA_PORT=50881
-DISCOVERY_CFG_SERVER_PORT=50991
-DISCOVERY_CFG_POLL_ENDPOINTS=http://localhost:50992/org.apache.celix.discovery.configured
\ No newline at end of file
+{
+ "CELIX_AUTO_START_1":"@rsa_bundle_file@ @discovery_bundle_file@ @topology_manager_bundle_file@ @tst_bundle_file@",
+ "LOGHELPER_ENABLE_STDOUT_FALLBACK":true,
+ "CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true,
+ "CELIX_FRAMEWORK_CACHE_DIR":".cacheClient",
+ "DISCOVERY_CFG_POLL_INTERVAL":1,
+ "DISCOVERY_CFG_POLL_TIMEOUT":5,
+ "RSA_PORT":50881,
+ "DISCOVERY_CFG_SERVER_PORT":50991,
+ "DISCOVERY_CFG_POLL_ENDPOINTS":"http://localhost:50992/org.apache.celix.discovery.configured"
+}
\ No newline at end of file
diff --git a/bundles/remote_services/remote_service_admin_dfi/gtest/config.properties.in b/bundles/remote_services/remote_service_admin_dfi/gtest/config.properties.in
index 52730b288..cac7390d2 100644
--- a/bundles/remote_services/remote_service_admin_dfi/gtest/config.properties.in
+++ b/bundles/remote_services/remote_service_admin_dfi/gtest/config.properties.in
@@ -1,20 +1,5 @@
-# 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.
-
-CELIX_AUTO_START_1=@rsa_bundle_file@ @calc_bundle_file@
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
+{
+ "CELIX_AUTO_START_1":"@rsa_bundle_file@ @calc_bundle_file@",
+ "LOGHELPER_ENABLE_STDOUT_FALLBACK":true,
+ "CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true
+}
diff --git a/bundles/remote_services/remote_service_admin_dfi/gtest/server.properties.in b/bundles/remote_services/remote_service_admin_dfi/gtest/server.properties.in
index 7812c7fe0..8d74011aa 100644
--- a/bundles/remote_services/remote_service_admin_dfi/gtest/server.properties.in
+++ b/bundles/remote_services/remote_service_admin_dfi/gtest/server.properties.in
@@ -1,26 +1,11 @@
-# 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.
-CELIX_AUTO_START_1=@rsa_bundle_file@ @calc_bundle_file@ @remote_example_bundle_file@ @discovery_bundle_file@ @topology_manager_bundle_file@
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
-CELIX_FRAMEWORK_CACHE_DIR=.cacheServer
-
-DISCOVERY_CFG_POLL_INTERVAL=1
-DISCOVERY_CFG_POLL_TIMEOUT=5
-RSA_PORT=50882
-DISCOVERY_CFG_SERVER_PORT=50992
-DISCOVERY_CFG_POLL_ENDPOINTS=http://localhost:50991/org.apache.celix.discovery.configured
+{
+ "CELIX_AUTO_START_1":"@rsa_bundle_file@ @calc_bundle_file@ @remote_example_bundle_file@ @discovery_bundle_file@ @topology_manager_bundle_file@",
+ "LOGHELPER_ENABLE_STDOUT_FALLBACK":true,
+ "CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true,
+ "CELIX_FRAMEWORK_CACHE_DIR":".cacheServer",
+ "DISCOVERY_CFG_POLL_INTERVAL":1,
+ "DISCOVERY_CFG_POLL_TIMEOUT":5,
+ "RSA_PORT":50882,
+ "DISCOVERY_CFG_SERVER_PORT":50992,
+ "DISCOVERY_CFG_POLL_ENDPOINTS":"http://localhost:50991/org.apache.celix.discovery.configured"
+}
diff --git a/bundles/remote_services/topology_manager/tms_tst/CMakeLists.txt b/bundles/remote_services/topology_manager/tms_tst/CMakeLists.txt
index dfb913135..332677cc1 100644
--- a/bundles/remote_services/topology_manager/tms_tst/CMakeLists.txt
+++ b/bundles/remote_services/topology_manager/tms_tst/CMakeLists.txt
@@ -54,19 +54,19 @@ add_celix_bundle_dependencies(test_tm_scoped Celix::rsa_dfi Celix::rsa_topology_
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/config.properties"
- CONTENT "
-CELIX_AUTO_START_1=$<TARGET_PROPERTY:Celix::rsa_dfi,BUNDLE_FILE> $<TARGET_PROPERTY:calculator,BUNDLE_FILE> $<TARGET_PROPERTY:Celix::rsa_topology_manager,BUNDLE_FILE> $<TARGET_PROPERTY:topology_manager_disc_mock_bundle,BUNDLE_FILE>
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
-")
+ CONTENT "{
+ \"CELIX_AUTO_START_1\":\"$<TARGET_PROPERTY:Celix::rsa_dfi,BUNDLE_FILE> $<TARGET_PROPERTY:calculator,BUNDLE_FILE> $<TARGET_PROPERTY:Celix::rsa_topology_manager,BUNDLE_FILE> $<TARGET_PROPERTY:topology_manager_disc_mock_bundle,BUNDLE_FILE>\",
+ \"LOGHELPER_ENABLE_STDOUT_FALLBACK\":true,
+ \"CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE\":true
+}")
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/config_import.properties"
- CONTENT "
-CELIX_AUTO_START_1=$<TARGET_PROPERTY:Celix::rsa_dfi,BUNDLE_FILE> $<TARGET_PROPERTY:calculator,BUNDLE_FILE> $<TARGET_PROPERTY:Celix::rsa_topology_manager,BUNDLE_FILE> $<TARGET_PROPERTY:topology_manager_test_bundle,BUNDLE_FILE>
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
-")
+ CONTENT "{
+ \"CELIX_AUTO_START_1\":\"$<TARGET_PROPERTY:Celix::rsa_dfi,BUNDLE_FILE> $<TARGET_PROPERTY:calculator,BUNDLE_FILE> $<TARGET_PROPERTY:Celix::rsa_topology_manager,BUNDLE_FILE> $<TARGET_PROPERTY:topology_manager_test_bundle,BUNDLE_FILE>\",
+ \"LOGHELPER_ENABLE_STDOUT_FALLBACK\":true,
+ \"CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE\":true
+}")
configure_file("scope.json" "scope.json")
configure_file("scope2.json" "scope2.json")
diff --git a/cmake/cmake_celix/BundlePackaging.cmake b/cmake/cmake_celix/BundlePackaging.cmake
index 112d942f4..0bdf0f654 100644
--- a/cmake/cmake_celix/BundlePackaging.cmake
+++ b/cmake/cmake_celix/BundlePackaging.cmake
@@ -31,13 +31,13 @@ endif ()
find_program(JAR_COMMAND jar NO_CMAKE_FIND_ROOT_PATH)
if (JAR_COMMAND AND NOT CELIX_USE_ZIP_INSTEAD_OF_JAR)
- message(STATUS "Using jar to create bundles")
+ message(DEBUG "Using jar to create bundles")
else ()
find_program(ZIP_COMMAND zip NO_CMAKE_FIND_ROOT_PATH)
if (ZIP_COMMAND)
- message(STATUS "Using zip to create bundles")
+ message(DEBUG "Using zip to create bundles")
else ()
- message(FATAL_ERROR "A jar or zip command is needed to jar/zip bundles")
+ message(FATAL_ERROR "A jar or zip command is needed to created bundles")
endif ()
endif ()
@@ -48,7 +48,7 @@ if (NOT TARGET celix-bundles)
endif ()
#####
-macro(extract_version_parts VERSION MAJOR MINOR PATCH)
+macro(_extract_version_parts VERSION MAJOR MINOR PATCH)
set(MAJOR "0")
set(MINOR "0")
set(PATCH "0")
@@ -67,20 +67,20 @@ macro(extract_version_parts VERSION MAJOR MINOR PATCH)
endif ()
endmacro()
-function(set_library_version TARGET VERSION)
+function(celix_set_library_version TARGET VERSION)
if (VERSION AND TARGET)
- extract_version_parts("${VERSION}" MAJOR MINOR PATCH)
+ _extract_version_parts("${VERSION}" MAJOR MINOR PATCH)
#NOTE setting aligning ABI version with major part of the interface version.
#This is simpeler than using the <current>:<revision>:<age> approach of libtool
set_property(TARGET ${TARGET} PROPERTY VERSION "${VERSION}")
set_property(TARGET ${TARGET} PROPERTY SOVERSION ${MAJOR})
else ()
- message(WARNING "set_library_version: Cannot set version info TARGET and/or VERSION not provided")
+ message(WARNING "celix_set_library_version: Cannot set version info TARGET and/or VERSION not provided")
endif ()
endfunction()
-function(check_lib LIB)
+function(_check_lib LIB)
if (TARGET ${LIB})
#ok
elseif (IS_ABSOLUTE ${LIB} AND EXISTS ${LIB})
@@ -90,7 +90,7 @@ function(check_lib LIB)
endif ()
endfunction()
-function(check_bundle BUNDLE)
+function(_check_bundle BUNDLE)
if (TARGET ${BUNDLE})
get_target_property(BUNDLE_FILE ${BUNDLE} "BUNDLE_FILE")
if (NOT BUNDLE_FILE)
@@ -191,7 +191,7 @@ function(add_celix_bundle)
message(FATAL_ERROR "add_bundle function requires a value for SOURCES or ACTIVATOR not both")
endif ()
if (BUNDLE_ACTIVATOR)
- check_lib(${BUNDLE_ACTIVATOR})
+ _check_lib(${BUNDLE_ACTIVATOR})
endif ()
if (NOT DEFINED BUNDLE_GROUP)
set(BUNDLE_GROUP "")
@@ -246,7 +246,7 @@ function(add_celix_bundle)
if (BUNDLE_SOURCES)
#create lib from sources
add_library(${BUNDLE_TARGET_NAME} SHARED ${BUNDLE_SOURCES})
- set_library_version(${BUNDLE_TARGET_NAME} ${BUNDLE_VERSION})
+ celix_set_library_version(${BUNDLE_TARGET_NAME} ${BUNDLE_VERSION})
set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES
"BUNDLE_TARGET_IS_LIB" TRUE
"BUNDLE_TARGET" "${BUNDLE_TARGET_NAME}_bundle"
@@ -451,7 +451,7 @@ function(celix_bundle_libs)
list(REMOVE_AT ARGN 0)
#check if arg 0 is corrent
- check_bundle(${BUNDLE})
+ _check_bundle(${BUNDLE})
get_target_property(BUNDLE_DIR ${BUNDLE} "BUNDLE_CONTENT_DIR")
get_target_property(BUNDLE_GEN_DIR ${BUNDLE} "BUNDLE_GEN_DIR")
@@ -536,7 +536,7 @@ function(celix_bundle_import_libs)
list(REMOVE_AT ARGN 0)
#check if arg 0 is correct
- check_bundle(${BUNDLE})
+ _check_bundle(${BUNDLE})
get_target_property(LIBS ${BUNDLE} "BUNDLE_IMPORT_LIBS")
diff --git a/cmake/cmake_celix/ContainerPackaging.cmake b/cmake/cmake_celix/ContainerPackaging.cmake
index 382a2bd16..6523b3d44 100644
--- a/cmake/cmake_celix/ContainerPackaging.cmake
+++ b/cmake/cmake_celix/ContainerPackaging.cmake
@@ -18,7 +18,7 @@
set(CELIX_DEFAULT_CONTAINER_CXX_OPTION ON CACHE BOOL "Whether the default container options is CXX. If OFF this will be C")
-##### setup bundles/container target
+# Setup bundles/container target
if (NOT TARGET celix-containers)
add_custom_target(celix-containers ALL
DEPENDS $<TARGET_PROPERTY:celix-containers,CONTAINER_DEPLOYMENTS>
@@ -30,12 +30,8 @@ if (NOT TARGET celix-containers)
list(APPEND CLEANFILES "${CMAKE_BINARY_DIR}/celix")
set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES "${CLEANFILES}")
endif ()
-#####
-function(add_deploy)
- message(DEPRECATION "deploy_bundles_dir is depecrated, use celix_container_bundles_dir instead.")
- add_celix_container(${ARGN})
-endfunction()
+
#[[
Add a Celix container, consisting out of a selection of bundles and a Celix launcher.
@@ -223,20 +219,24 @@ function(add_celix_container)
CONTENT "#include <celix_launcher.h>
#include <celix_err.h>
+#define CELIX_MULTI_LINE_STRING(...) #__VA_ARGS__
+
int main(int argc, char *argv[]) {
- const char * config = \"\\
-CELIX_CONTAINER_NAME=$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_NAME>\\n\\
-CELIX_BUNDLES_PATH=bundles\\n\\
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>>:CELIX_AUTO_START_0=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>, >\\n>\\
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>>:CELIX_AUTO_START_1=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>, >\\n>\\
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>>:CELIX_AUTO_START_2=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>, >\\n>\\
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>>:CELIX_AUTO_START_3=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>, >\\n>\\
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>>:CELIX_AUTO_START_4=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>, >\\n>\\
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>>:CELIX_AUTO_START_5=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>, >\\n>\\
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>>:CELIX_AUTO_START_6=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>, >\\n>\\
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_INSTALL>>:CELIX_AUTO_INSTALL=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_INSTALL>, >\\n>\\
-$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_EMBEDDED_PROPERTIES>,\\n\\
->\";
+ const char * config = CELIX_MULTI_LINE_STRING(
+{
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>>:\"CELIX_AUTO_START_0\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>>:\"CELIX_AUTO_START_1\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>>:\"CELIX_AUTO_START_2\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>>:\"CELIX_AUTO_START_3\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>>:\"CELIX_AUTO_START_4\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>>:\"CELIX_AUTO_START_5\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>>:\"CELIX_AUTO_START_6\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_INSTALL>>:\"CELIX_AUTO_INSTALL\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_INSTALL>, >\"$<COMMA>>
+ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_EMBEDDED_PROPERTIES>,$<COMMA>
+ >$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_EMBEDDED_PROPERTIES>>:$<COMMA>>
+ \"CELIX_BUNDLES_PATH\":\"bundles\"$<COMMA>
+ \"CELIX_CONTAINER_NAME\":\"$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_NAME>\"
+});
celix_properties_t *embeddedProps;
celix_status_t status = celix_properties_loadFromString2(config, 0, &embeddedProps);
@@ -277,18 +277,20 @@ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_EMBEDDED_PROPERTIES>,\\n\
if (CONTAINER_USE_CONFIG)
file(GENERATE
OUTPUT "${STAGE1_PROPERTIES}"
- CONTENT "CELIX_CONTAINER_NAME=$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_NAME>
-CELIX_BUNDLES_PATH=bundles
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>>:CELIX_AUTO_START_0=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>, >>
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>>:CELIX_AUTO_START_1=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>, >>
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>>:CELIX_AUTO_START_2=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>, >>
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>>:CELIX_AUTO_START_3=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>, >>
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>>:CELIX_AUTO_START_4=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>, >>
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>>:CELIX_AUTO_START_5=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>, >>
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>>:CELIX_AUTO_START_6=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>, >>
-$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_INSTALL>>:CELIX_AUTO_INSTALL=$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_INSTALL>, >>
-$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_RUNTIME_PROPERTIES>,
->"
+ CONTENT "{
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>>:\"CELIX_AUTO_START_0\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_0>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>>:\"CELIX_AUTO_START_1\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_1>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>>:\"CELIX_AUTO_START_2\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_2>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>>:\"CELIX_AUTO_START_3\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_3>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>>:\"CELIX_AUTO_START_4\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_4>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>>:\"CELIX_AUTO_START_5\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_5>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>>:\"CELIX_AUTO_START_6\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_LEVEL_6>, >\"$<COMMA>>
+ $<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_INSTALL>>:\"CELIX_AUTO_INSTALL\":\"$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_BUNDLES_INSTALL>, >\"$<COMMA>>
+ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_EMBEDDED_PROPERTIES>,$<COMMA>
+ >$<$<BOOL:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_EMBEDDED_PROPERTIES>>:$<COMMA>>
+ \"CELIX_BUNDLES_PATH\":\"bundles\"$<COMMA>
+ \"CELIX_CONTAINER_NAME\":\"$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_NAME>\"
+}"
)
file(GENERATE
OUTPUT "${CONTAINER_PROPS}"
@@ -297,9 +299,10 @@ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_RUNTIME_PROPERTIES>,
else ()
file(GENERATE
OUTPUT "${STAGE1_PROPERTIES}"
- CONTENT "$<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_RUNTIME_PROPERTIES>,
->
-"
+ CONTENT "{
+ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_RUNTIME_PROPERTIES>,$<COMMA>
+ >
+}"
)
#Condition is there so that config.properties file will only be generated if there are runtime properties
file(GENERATE
@@ -374,13 +377,6 @@ $<JOIN:$<TARGET_PROPERTY:${CONTAINER_TARGET},CONTAINER_RUNTIME_PROPERTIES>,
set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES "${CLEANFILES}")
endfunction()
-
-#NOTE can be used for drivers/proxies/endpoints bundle dirs
-function(deploy_bundles_dir)
- message(DEPRECATION "deploy_bundles_dir is depecrated, use celix_container_bundles_dir instead.")
- celix_container_bundles_dir(${ARGN})
-endfunction()
-
#[[
Copy the specified bundles to a specified dir in the container build dir.
@@ -463,11 +459,6 @@ function(celix_container_bundles_dir)
endforeach()
endfunction()
-function(deploy_bundles)
- message(DEPRECATION "deploy_bundles is depecrated, use celix_container_bundles instead.")
- celix_container_bundles(${ARGN})
-endfunction()
-
#[[
Add a selection of bundles to the Celix container.
@@ -572,6 +563,7 @@ function(celix_container_bundles)
endif ()
endforeach()
+ list(REMOVE_DUPLICATES BUNDLES)
if (BUNDLES_INSTALL)
set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_BUNDLES_INSTALL" "${BUNDLES}")
else () #bundle level 0,1,2,3,4,5 or 6
@@ -609,8 +601,36 @@ function(_celix_container_check_duplicate_bundles)
endforeach()
endfunction()
-function(deploy_properties)
- celix_container_runtime_properties(${ARGN})
+#[[
+Internal function that converts a property string to a JSON field entry.
+The result is stored in the OUTPUT_VAR_NAME variable.
+
+In the key the char `=` is not allowed and should be escaped as `\=` (in CMake this is `\\=`, because \ is already an
+escape char in CMake).
+In the value the char `=` is allowed.
+
+To handle \= string sequences the \= entries are replaced with a placeholder (__<CELIX_ESCAPED_EQUAL>__) and after the
+split the placeholder is replaced with =.
+
+```CMake
+_celix_convert_property_to_json("prop1=val1" OUTPUT_VAR_NAME) # OUTPUT_VAR_NAME will be set to "\"prop1\":\"val1\""
+_celix_convert_property_to_json("prop1=va=l1" OUTPUT_VAR_NAME) # OUTPUT_VAR_NAME will be set to "\"prop1\":\"va=l1\""
+_celix_convert_property_to_json("prop\\=1=val1" OUTPUT_VAR_NAME) # OUTPUT_VAR_NAME will be set to "\"prop=1\":\"val1\""
+```
+]]
+function(_celix_convert_property_to_json INPUT_STR OUTPUT_VAR_NAME)
+ set(PLACEHOLDER "__<CELIX_ESCAPED_EQUAL>__")
+ string(REPLACE "\\=" "${PLACEHOLDER}" TEMP_INPUT_STR "${INPUT_STR}")
+
+ string(REGEX MATCH "([^=]+)=(.*)" _ ${TEMP_INPUT_STR})
+ set(KEY ${CMAKE_MATCH_1})
+ set(VALUE ${CMAKE_MATCH_2})
+
+ #Replace replaced \= and \\ with = and \
+ string(REPLACE "${PLACEHOLDER}" "=" KEY "${KEY}")
+ string(REPLACE "${PLACEHOLDER}" "=" VALUE "${VALUE}")
+
+ set(${OUTPUT_VAR_NAME} "\"${KEY}\":\"${VALUE}\"" PARENT_SCOPE)
endfunction()
#[[
@@ -634,17 +654,13 @@ function(celix_container_runtime_properties)
get_target_property(PROPS ${CONTAINER_TARGET} "CONTAINER_RUNTIME_PROPERTIES")
foreach(PROP IN ITEMS ${ARGN})
+ _celix_convert_property_to_json(${PROP} PROP)
list(APPEND PROPS ${PROP})
endforeach()
set_target_properties(${CONTAINER_TARGET} PROPERTIES "CONTAINER_RUNTIME_PROPERTIES" "${PROPS}")
endfunction()
-function(deploy_embedded_properties)
- message(DEPRECATION "deploy_embedded_properties is depecrated, use celix_container_embedded_properties instead.")
- celix_container_embedded_properties(${ARGN})
-endfunction()
-
#[[
Add the provided properties to the target Celix container config properties.
These properties will be embedded into the generated Celix launcher.
@@ -666,6 +682,7 @@ function(celix_container_embedded_properties)
get_target_property(PROPS ${CONTAINER_TARGET} "CONTAINER_EMBEDDED_PROPERTIES")
foreach(PROP IN ITEMS ${ARGN})
+ _celix_convert_property_to_json(${PROP} PROP)
list(APPEND PROPS ${PROP})
endforeach()
diff --git a/examples/celix-examples/bundle_with_private_lib/CMakeLists.txt b/examples/celix-examples/bundle_with_private_lib/CMakeLists.txt
index ab963418b..8c839f504 100644
--- a/examples/celix-examples/bundle_with_private_lib/CMakeLists.txt
+++ b/examples/celix-examples/bundle_with_private_lib/CMakeLists.txt
@@ -19,7 +19,7 @@ add_library(tlib SHARED
tlib/src/test.c
)
target_include_directories(tlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tlib/include)
-set_library_version(tlib "4.3.2") # sets target propery VERSION to 4.3.2 and SOVERSION to 4
+celix_set_library_version(tlib "4.3.2") # sets target propery VERSION to 4.3.2 and SOVERSION to 4
add_celix_bundle(hellotest
VERSION "1.2"
diff --git a/examples/celix-examples/hello_world_c/CMakeLists.txt b/examples/celix-examples/hello_world_c/CMakeLists.txt
index de275ead0..1ae721f5d 100644
--- a/examples/celix-examples/hello_world_c/CMakeLists.txt
+++ b/examples/celix-examples/hello_world_c/CMakeLists.txt
@@ -21,9 +21,10 @@ add_celix_bundle(hello_world_c
)
add_celix_container(hello_world_c_container
+ C
GROUP c_examples
BUNDLES
Celix::shell
Celix::shell_tui
hello_world_c
-)
\ No newline at end of file
+)
diff --git a/libs/framework/gtest/config.properties.in b/libs/framework/gtest/config.properties.in
index f5931a4a5..f594096d2 100644
--- a/libs/framework/gtest/config.properties.in
+++ b/libs/framework/gtest/config.properties.in
@@ -1,19 +1,4 @@
-# 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.
-
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
\ No newline at end of file
+{
+ "LOGHELPER_ENABLE_STDOUT_FALLBACK":true,
+ "CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true
+}
diff --git a/libs/framework/gtest/framework1.properties.in b/libs/framework/gtest/framework1.properties.in
index 567d19732..1d72fbbd7 100644
--- a/libs/framework/gtest/framework1.properties.in
+++ b/libs/framework/gtest/framework1.properties.in
@@ -1,20 +1,5 @@
-# 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.
-
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
-CELIX_FRAMEWORK_FRAMEWORK_CACHE_DIR=.cacheFramework1
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+{
+ "CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true,
+ "CELIX_FRAMEWORK_FRAMEWORK_CACHE_DIR":".cacheFramework1",
+ "LOGHELPER_ENABLE_STDOUT_FALLBACK":true
+}
diff --git a/libs/framework/gtest/framework2.properties.in b/libs/framework/gtest/framework2.properties.in
index 234b7a20e..d9ff4738e 100644
--- a/libs/framework/gtest/framework2.properties.in
+++ b/libs/framework/gtest/framework2.properties.in
@@ -1,20 +1,5 @@
-# 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.
-
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
-CELIX_FRAMEWORK_FRAMEWORK_CACHE_DIR=.cacheFramework2
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+{
+ "CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true,
+ "CELIX_FRAMEWORK_FRAMEWORK_CACHE_DIR":".cacheFramework2",
+ "LOGHELPER_ENABLE_STDOUT_FALLBACK":true
+}
diff --git a/libs/framework/gtest/install_and_start_bundles.properties.in b/libs/framework/gtest/install_and_start_bundles.properties.in
index d51721efe..f7fdc6dca 100644
--- a/libs/framework/gtest/install_and_start_bundles.properties.in
+++ b/libs/framework/gtest/install_and_start_bundles.properties.in
@@ -1,29 +1,8 @@
-# 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.
-
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
-
-#3 bundles, where 2 are valid and 1 non existing
-CELIX_AUTO_START_1=@SIMPLE_TEST_BUNDLE1@ @SIMPLE_TEST_BUNDLE2@ Invalid1.zip
-
-#3 bundles, 1 is valid, 1 non existing and 1 already started
-CELIX_AUTO_START_3=@SIMPLE_TEST_BUNDLE2@ @SIMPLE_TEST_BUNDLE3@ Invalid2.zip
-
-#4 bundles, 2 valid, 1 non existing and 1 already started
-CELIX_AUTO_INSTALL=@SIMPLE_TEST_BUNDLE3@ @SIMPLE_TEST_BUNDLE4@ @SIMPLE_TEST_BUNDLE5@ Invalid3.zip
+{
+ "CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true,
+ "CELIX_AUTO_START_1":"@SIMPLE_TEST_BUNDLE1@ @SIMPLE_TEST_BUNDLE2@ Invalid1.zip",
+ "CELIX_AUTO_START_3":"@SIMPLE_TEST_BUNDLE2@ @SIMPLE_TEST_BUNDLE3@ Invalid2.zip",
+ "CELIX_AUTO_INSTALL":"@SIMPLE_TEST_BUNDLE3@ @SIMPLE_TEST_BUNDLE4@ @SIMPLE_TEST_BUNDLE5@ Invalid3.zip"
+}
diff --git a/libs/framework/src/celix_launcher.c b/libs/framework/src/celix_launcher.c
index e3a72e29c..2d2791292 100644
--- a/libs/framework/src/celix_launcher.c
+++ b/libs/framework/src/celix_launcher.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#ifndef CELIX_NO_CURLINIT
#include <curl/curl.h>
@@ -45,6 +46,8 @@ static celix_properties_t* celixLauncher_createConfig(const char* configFile, ce
static void celixLauncher_printUsage(char* progName);
static void celixLauncher_printProperties(celix_properties_t* embeddedProps, const char* configFile);
static int celixLauncher_createBundleCache(celix_properties_t* embeddedProperties, const char* configFile);
+static celix_status_t celixLauncher_loadConfigProperties(const char* configFile,
+ celix_properties_t** outConfigProperties);
#define DEFAULT_CONFIG_FILE "config.properties"
@@ -92,10 +95,6 @@ int celixLauncher_launchWithArgv(int argc,
}
}
- if (configFile == NULL) {
- configFile = DEFAULT_CONFIG_FILE;
- }
-
if (embeddedConfig == NULL) {
embeddedConfig = celix_properties_create();
}
@@ -187,7 +186,7 @@ static void celixLauncher_printUsage(char* progName) {
}
static void celixLauncher_printProperties(celix_properties_t* embeddedProps, const char* configFile) {
- celix_properties_t* keys = celix_properties_create(); // only to store the keys
+ celix_autoptr(celix_properties_t) keys = celix_properties_create(); // only to store the keys
printf("Embedded properties:\n");
if (embeddedProps == NULL || celix_properties_size(embeddedProps) == 0) {
@@ -200,14 +199,9 @@ static void celixLauncher_printProperties(celix_properties_t* embeddedProps, con
}
printf("\n");
- celix_properties_t* runtimeProps = NULL;
- if (configFile != NULL) {
- celix_status_t status = celix_properties_load2(configFile, 0, &runtimeProps);
- if (status != CELIX_SUCCESS) {
- celix_err_printErrors(stderr, "Error loading config file.", NULL);
- }
- }
- printf("Runtime properties (input %s):\n", configFile);
+ celix_autoptr(celix_properties_t) runtimeProps;
+ (void)celixLauncher_loadConfigProperties(configFile, &runtimeProps);
+ printf("Runtime properties (input %s):\n", configFile ? configFile : "none");
if (runtimeProps == NULL || celix_properties_size(runtimeProps) == 0) {
printf("|- Empty!\n");
} else {
@@ -233,15 +227,13 @@ static void celixLauncher_printProperties(celix_properties_t* embeddedProps, con
}
}
printf("\n");
-
- if (runtimeProps != NULL) {
- celix_properties_destroy(runtimeProps);
- }
- celix_properties_destroy(keys);
}
static int celixLauncher_createBundleCache(celix_properties_t* embeddedProperties, const char* configFile) {
celix_properties_t* config = celixLauncher_createConfig(configFile, embeddedProperties);
+ if (!config) {
+ return CELIX_LAUNCHER_ERROR_EXIT_CODE;
+ }
celix_framework_t* fw = celix_frameworkFactory_createFramework(config);
if (!fw) {
fprintf(stderr, "Failed to create framework for bundle cache creation\n");
@@ -266,14 +258,37 @@ static celix_properties_t* celixLauncher_createConfig(const char* configFile, ce
if (!embeddedProperties) {
embeddedProperties = celix_properties_create();
}
-
- celix_autoptr(celix_properties_t) configProperties = NULL;
- celix_status_t status = celix_properties_load2(configFile, 0, &configProperties);
+ celix_autoptr(celix_properties_t) configProperties;
+ celix_status_t status = celixLauncher_loadConfigProperties(configFile, &configProperties);
if (status != CELIX_SUCCESS) {
- fprintf(stderr, "Error loading config file %s\n", configFile);
celix_properties_destroy(embeddedProperties);
return NULL;
}
celixLauncher_combineProperties(embeddedProperties, configProperties);
return embeddedProperties;
}
+
+/**
+ * @brief Load the config properties from the given file.
+ * If configFile is NULL, config properties will only be loaded if DEFAULT_CONFIG_FILE exists.
+ */
+static celix_status_t celixLauncher_loadConfigProperties(const char* configFile,
+ celix_properties_t** outConfigProperties) {
+ celix_properties_t* configProperties = NULL;
+ bool loadConfig = configFile != NULL;
+ if (!loadConfig) {
+ struct stat buffer;
+ loadConfig = stat(DEFAULT_CONFIG_FILE, &buffer) == 0;
+ configFile = DEFAULT_CONFIG_FILE;
+ }
+ if (loadConfig) {
+ celix_status_t status = celix_properties_load2(configFile, 0, &configProperties);
+ if (status != CELIX_SUCCESS) {
+ celix_err_printErrors(stderr, "Error loading config file: ", NULL);
+ *outConfigProperties = NULL;
+ return status;
+ }
+ }
+ *outConfigProperties = configProperties;
+ return CELIX_SUCCESS;
+}
diff --git a/libs/utils/gtest/CMakeLists.txt b/libs/utils/gtest/CMakeLists.txt
index 0d717e1fa..be04e0a75 100644
--- a/libs/utils/gtest/CMakeLists.txt
+++ b/libs/utils/gtest/CMakeLists.txt
@@ -56,8 +56,8 @@ if (CELIX_CXX17)
endif ()
####### generating zip file used for testing ##########################################################################
-file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/zip_content/top.properties" CONTENT "level=1\n")
-file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/zip_content/subdir/sub.properties" CONTENT "level=2\n")
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/zip_content/top.properties" CONTENT "{\"level\":1}")
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/zip_content/subdir/sub.properties" CONTENT "{\"level\":2}")
set(TEST_ZIP_FILE "${CMAKE_CURRENT_BINARY_DIR}/test.zip")
if(ZIP_COMMAND)
add_custom_command(OUTPUT ${TEST_ZIP_FILE}
diff --git a/misc/experimental/bundles/config_admin/config_admin_tst/config.properties.in b/misc/experimental/bundles/config_admin/config_admin_tst/config.properties.in
index d4db56716..0d3133d7e 100644
--- a/misc/experimental/bundles/config_admin/config_admin_tst/config.properties.in
+++ b/misc/experimental/bundles/config_admin/config_admin_tst/config.properties.in
@@ -1,20 +1,5 @@
-# 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.
-
-CELIX_FRAMEWORK_FRAMEWORK_CACHE_DIR=@config_admin_bundle_file@ @example_test_bundle_file@ @example_test2_bundle_file@
-LOGHELPER_ENABLE_STDOUT_FALLBACK=true
-CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE=true
\ No newline at end of file
+{
+ "CELIX_FRAMEWORK_FRAMEWORK_CACHE_DIR":"@config_admin_bundle_file@ @example_test_bundle_file@ @example_test2_bundle_file@",
+ "LOGHELPER_ENABLE_STDOUT_FALLBACK":true,
+ "CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE":true
+}
\ No newline at end of file