For Apache Celix several cmake command are added to be able to work with Apache Celix bundles and deployments.
Add a Celix bundle to the project. There are three variants:
Optional arguments are:
add_celix_bundle(<bundle_target_name>
SOURCES source1 source2 ...
[NAME bundle_name]
[SYMBOLIC_NAME bundle_symbolic_name]
[DESCRIPTION bundle_description]
[GROUP bundle_group]
[VERSION bundle_version]
[FILENAME bundle_filename]
[PRIVATE_LIBRARIES private_lib1 private_lib2 ...]
[HEADERS "header1: header1_value" "header2: header2_value" ...]
)
add_celix_bundle(<bundle_target_name>
ACTIVATOR <activator_lib>
[NAME bundle_name]
[SYMBOLIC_NAME bundle_symbolic_name]
[DESCRIPTION bundle_description]
[GROUP bundle_group]
[VERSION bundle_version]
[FILENAME bundle_filename]
[PRIVATE_LIBRARIES private_lib1 private_lib2 ...]
[HEADERS "header1: header1_value" "header2: header2_value" ...]
)
add_celix_bundle(<bundle_target_name>
NO_ACTIVATOR
[NAME bundle_name]
[SYMBOLIC_NAME bundle_symbolic_name]
[DESCRIPTION bundle_description]
[GROUP bundle_group]
[VERSION bundle_version]
[FILENAME bundle_filename]
[PRIVATE_LIBRARIES private_lib1 private_lib2 ...]
[HEADERS "header1: header1_value" "header2: header2_value" ...]
)
Add libraries to a bundle. The libraries should be cmake library targets or an absolute path to an existing library.
The libraries will be copied into the bundle zip and activator library will be linked (PRIVATE) against them.
Apache Celix uses dlopen with RTLD_LOCAL to load the activator library in a bundle. It is important to note that dlopen will always load the activator library, but not always load the libraries the bundle activator library is linked against. If the activator library is linked against a library which is already loaded, the already loaded library will be used. More specifically dlopen will decide this based on the NEEDED header in the activator library and the SO_NAME headers of the already loaded libraries.
For example installing in order:
This also applies if multiple Celix frameworks are created in the same process. For example installed in order:
Will result in BundleA from framework B to use the libfoo loaded in BundleA from framework A.
celix_bundle_private_libs(<bundle_target>
lib1 lib2 ...
)
Add files to the target bundle. DESTINATION is relative to the bundle archive root. The rest of the command is conform file(COPY …) cmake command. See cmake file(COPY …) command for more info.
Note with celix_bundle_files files are copied cmake generation time. Updates are not copied !
celix_bundle_files(<bundle_target>
files... DESTINATION <dir>
[FILE_PERMISSIONS permissions...]
[DIRECTORY_PERMISSIONS permissions...]
[NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]
[FILES_MATCHING]
[ [PATTERN <pattern> | REGEX <regex>]
[EXCLUDE] [PERMISSIONS permissions...] ]
[...]
)
Append the provided headers to the target bundle manifest.
celix_bundle_headers(<bundle_target>
"header1: header1_value"
"header2: header2_value"
...
)
Set bundle symbolic name
celix_bundle_symbolic_name(<bundle_target> symbolic_name)
Set bundle name
celix_bundle_name(<bundle_target> name)
Set bundle version
celix_bundle_version(<bundle_target> version)
Set bundle description
celix_bundle_description(<bundle_target> description)
Set bundle group.
celix_bundle_group(<bundle_target> bundle group)
Get bundle filename from an (imported) bundle target taking into account the used CMAKE_BUILD_TYPE and available bundle configurations.
celix_get_bundle_filename(<bundle_target> VARIABLE_NAME)
Example: celix_get_bundle_filename(Celix::shell SHELL_BUNDLE_FILENAME)
will result in celix_shell.zip
for a RelWithDebInfo
cmake build type and in celix_shell-Debug.zip
for a Debug
cmake build type (if the a debug bundle version exists).
Get bundle file (absolute path to a bundle) from an (imported) bundle target taking into account the used CMAKE_BUILD_TYPE and available bundle configurations.
celix_get_bundle_file(<bundle_target> VARIABLE_NAME)
Example: celix_get_bundle_file(Celix::shell SHELL_BUNDLE_FILE)
Add bundles as dependencies to a cmake target, so that the bundle zip files will be created before the cmake target.
add_celix_bundle_dependencies(<cmake_target>
bundles...
)
Install bundle when ‘make install’ is executed.
Bundles are installed at <install-prefix>/share/<project_name>/bundles
.
Headers are installed at <install-prefix>/include/<project_name>/<bundle_name>
Resources are installed at <install-prefix>/shared/<project_name>/<bundle_name>
Optional arguments:
install_celix_bundle(<bundle_target>
[EXPORT] export_name
[PROJECT_NAME] project_name
[BUNDLE_NAME] bundle_name
[HEADERS header_file1 header_file2 ...]
[RESOURCES resource1 resource2 ...]
)
Generate and install a Celix Targets cmake file which contains CMake commands to create imported targets for the bundles install using the provided <export_name>. These imported CMake targets can be used in CMake projects using the installed bundles.
Optional Arguments:
install_celix_targets(<export_name>
NAMESPACE <namespace>
[FILE <celix_target_filename>]
[PROJECT_NAME <project_name>]
[DESTINATION <celix_targets_destination>]
)
Example:
install_celix_targets(celix NAMESPACE Celix:: DESTINATION share/celix/cmake FILE CelixTargets)
The ‘add_celix_container’ Celix CMake command can be used to create Celix containers. Celix containers are executables preconfigured with configuration properties and bundles to run.
Add a Celix container, consisting out of a selection of bundles and a Celix launcher.
Celix containers can be used to run/test a selection of bundles in the celix framework.
A Celix container will be build in <cmake_build_dir>/deploy[/<group_name>]/<celix_container_name>
.
Use the <celix_container_name>
executable to run the containers.
There are three variants of ‘add_celix_container’:
add_executable
target) is provided that will be used as Celix launcher.Creating a Celix containers using ‘add_celix_container’ will lead to a CMake executable target (expect if a LAUNCHER is used). These targets can be used to run/debug Celix containers from a IDE (if the IDE supports CMake).
Optional Arguments:
<cmake_build_dir>/deploy
.add_celix_container(<celix_container_name>
[COPY]
[NO_COPY]
[CXX]
[C]
[USE_CONFIG]
[GROUP group_name]
[NAME celix_container_name]
[DIR dir]
[BUNDLES <bundle1> <bundle2> ...]
[INSTALL_BUNDLES <bundle1> <bundle2> ...]
[PROPERTIES "prop1=val1" "prop2=val2" ...]
[EMBEDDED_PROPERTIES "prop1=val1" "prop2=val2" ...]
[RUNTIME_PROPERTIES "prop1=val1" "prop2=val2" ...]
)
add_celix_container(<celix_container_name>
LAUNCHER launcher
[COPY]
[NO_COPY]
[CXX]
[C]
[USE_CONFIG]
[GROUP group_name]
[NAME celix_container_name]
[DIR dir]
[BUNDLES <bundle1> <bundle2> ...]
[INSTALL_BUNDLES <bundle1> <bundle2> ...]
[PROPERTIES "prop1=val1" "prop2=val2" ...]
[EMBEDDED_PROPERTIES "prop1=val1" "prop2=val2" ...]
[RUNTIME_PROPERTIES "prop1=val1" "prop2=val2" ...]
)
add_celix_container(<celix_container_name>
LAUNCHER_SRC launcher_src
[COPY]
[NO_COPY]
[CXX]
[C]
[USE_CONFIG]
[GROUP group_name]
[NAME celix_container_name]
[DIR dir]
[BUNDLES <bundle1> <bundle2> ...]
[INSTALL_BUNDLES <bundle1> <bundle2> ...]
[PROPERTIES "prop1=val1" "prop2=val2" ...]
[EMBEDDED_PROPERTIES "prop1=val1" "prop2=val2" ...]
[RUNTIME_PROPERTIES "prop1=val1" "prop2=val2" ...]
)
Add the selected bundles to the Celix container. These bundles are (if configured) copied to the container build dir and are added to the configuration properties so that they are installed and started when the Celix container executed.
The Celix framework supports 7 (0 - 6) run levels. Run levels can be used to control the start and stop order of bundles. Bundles in run level 0 are started first and bundles in run level 6 are started last. When stopping bundles in run level 6 are stopped first and bundles in run level 0 are stopped last. Within a run level the order of configured decides the start order; bundles added earlier are started first.
Optional Arguments:
celix_container_bundles(<celix_container_target_name>
[LEVEL (0..6)]
[INSTALL]
bundle1
bundle2
...
)
Add the provided properties to the target Celix container config properties. If the USE_CONFIG option is used these configuration properties will be added to the ‘config.properties’ file else they will be added to the generated Celix launcher.
celix_container_properties(<celix_container_target_name>
"prop1=val1"
"prop2=val2"
...
)
Add the provided properties to the target Celix container config properties. These properties will be embedded into the generated Celix launcher.
celix_container_embedded_properties(<celix_container_target_name>
"prop1=val1"
"prop2=val2"
...
)
Add the provided properties to the target Celix container config properties. These properties will be added to the config.properties in the container build dir.
celix_container_runtime_properties(<celix_container_target_name>
"prop1=val1"
"prop2=val2"
...
)
The add_celix_docker
Apache Celix CMake command can be used to create Apache Celix docker directories.
These directories can be used (with ‘docker build’ or podman) to create very small Apache Celix docker images.
Adds a docker target dir, containing a all the required executables, libraries, filesystem files and selected bundles needed to run a Apache Celix framework in a docker container.
The ‘add_celix_docker’ target is a executable target and can be used to link libraries which are needed in the docker image.
The docker dir can be found in <cmake_build_dir>/docker[/<group_name>]/<docker_name>
.
The docker directories are build with the target celix-build-docker-dirs
, this does not create the
docker images and can also be executed on systems without docker. The celix-build-docker-dirs
is trigger
with make all
.
The docker images are build with the target celix-build-docker-images
. For this to work docker needs te installed
and the user executing the celix-build-docker-images
should have right to create docker images.
The celix-build-docker-images
is not triggered with make all
There are three variants of ‘add_celix_docker’:
add_executable
target) is provided that will be used as Celix launcher.Optional arguments:
add_celix_docker(<docker_target_name>
[CXX]
[GROUP group_name]
[NAME deploy_name]
[FROM docker_from_image]
[BUNDLES_DIR bundle_dir_in_docker_image]
[WORKDIR workdir_in_docker_image]
[IMAGE_NAME docker_image_name]
[BUNDLES <bundle1> <bundle2> ...]
[PROPERTIES "prop1=val1" "prop2=val2" ...]
[INSTRUCTIONS "instr1" "instr2" ...]
)
add_celix_docker(<docker_target_name>
LAUNCHER_SRC launcher_src
[CXX]
[GROUP group_name]
[NAME deploy_name]
[FROM docker_from_image]
[BUNDLES_DIR bundle_dir_in_docker_image]
[WORKDIR workdir_in_docker_image]
[IMAGE_NAME docker_image_name]
[BUNDLES <bundle1> <bundle2> ...]
[PROPERTIES "prop1=val1" "prop2=val2" ...]
[INSTRUCTIONS "instr1" "instr2" ...]
)
add_celix_docker(<docker_target_name>
LAUNCHER launcher
[CXX]
[GROUP group_name]
[NAME deploy_name]
[FROM docker_from_image]
[BUNDLES_DIR bundle_dir_in_docker_image]
[WORKDIR workdir_in_docker_image]
[IMAGE_NAME docker_image_name]
[BUNDLES <bundle1> <bundle2> ...]
[PROPERTIES "prop1=val1" "prop2=val2" ...]
[INSTRUCTIONS "instr1" "instr2" ...]
)
Add the selected bundles to the Celix docker image. These bundles are copied to the docker build dir and are added to the configuration properties so that they are installed and started when the Celix docker container is created and started.
The Celix framework support 7 (0 - 6) run levels. Run levels can be used to control the start and stop order of bundles. Bundles in run level 0 are started first and bundles in run level 6 are started last. When stopping bundles in run level 6 are stopped first and bundles in run level 0 are stopped last. Within a run level the order of configured decides the start order; bundles added earlier are started first.
Optional Arguments:
celix_docker_bundles(<celix_container_target_name>
[LEVEL (0..5)]
bundle1
bundle2
...
)
Same as celix_container_properties
, but then for the celix container
in the docker image.
celix_docker_properties(<docker_target_name>
"prop1=val1"
"prop2=val2"
...
)
Same as celix_container_embedded_properties
, but then for the celix container
in the docker image.
celix_docker_embedded_properties(<docker_target_name>
"prop1=val1"
"prop2=val2"
...
)
Add the provided docker instruction to the end of the generated Dockerfile.
celix_docker_instructions(<docker_target_name>
"instruction1"
"instruction2"
...
)