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: - With SOURCES the bundle will be created using a list of sources files as input for the bundle activator library. - With ACTIVATOR the bundle will be created using the library target or absolute path to existing library as activator library. - With the NO_ACTIVATOR option will create a bundle without a activator (i.e. a pure resource bundle).
Optional arguments are:
- NAME: The (human readable) name of the bundle. This will be used as Bundle-Name manifest entry. Default is the
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.
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)
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: - EXPORT: Associates the installed bundle with a export_name. The export name can be used to generate a Celix Targets cmake file (see install_celix_bundle_targets) - PROJECT_NAME: The project name for installing. Default is the cmake project name. - BUNDLE_NAME: The bundle name used when installing headers/resources. Default is the bundle target name. - HEADERS: A list of headers to install for the bundle. - RESOURCES: A list of resources to install for the bundle.
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
Optional Arguments:
- FILE: The Celix Targets cmake filename to used. Default is
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.cmake)
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’:
- If no launcher is specified a custom Celix launcher will be generated. This launcher also contains the configured properties.
- If a LAUNCHER_SRC is provided a Celix launcher will be build using the provided sources. Additional sources can be added with the
CMake ‘target_sources’ command.
- If a LAUNCHER (absolute path to a executable of CMake 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:
- COPY: With this option the used bundles are copied to the container build dir in the ‘bundles’ dir.
A additional result of this is that the configured references to the bundles are then relative instead of absolute.
- CXX: With this option the generated Celix launcher (if used) will be a C++ source instead of a C source.
A additional result of this is that Celix launcher is also linked against stdlibc++.
- USE_CONFIG: With this option config properties are generated in a ‘config.properties’ instead of embedded in the Celix launcher.
- GROUP: If configured the build location will be prefixed the GROUP. Default is empty.
- NAME: The name of the executable. Default is <cmake_build_dir>/deploy
.
- BUNDLES: A list of bundles to configured for the Celix container to install and start.
These bundle will be configured for run level 3. See ‘celix_container_bundles’ for more info.
- PROPERTIES: A list of configuration properties, these can be used to configure the Celix framework and/or bundles.
Normally this will be EMBEDED_PROPERTIES, but if the USE_CONFIG option is used this will be RUNTIME_PROPERTIES.
See the framework library or bundles documentation about the available configuration options.
- EMBEDDED_PROPERTIES: A list of configuration properties which will be used in the generated Celix launcher.
- RUNTIME_PROPERTIES: A list of configuration properties which will be used in the generated config.properties file.
add_celix_container(<celix_container_name>
[COPY]
[CXX]
[USE_CONFIG]
[GROUP group_name]
[NAME celix_container_name]
[DIR dir]
[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]
[CXX]
[USE_CONFIG]
[GROUP group_name]
[NAME celix_container_name]
[DIR dir]
[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]
[CXX]
[USE_CONFIG]
[GROUP group_name]
[NAME celix_container_name]
[DIR dir]
[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 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: - LEVEL: The run level for the added bundles. Default is 3.
celix_container_bundles(<celix_container_target_name>
[LEVEL (0..5)]
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’:
- If no launcher is specified a custom Celix launcher will be generated. This launcher also contains the configured properties.
- If a LAUNCHER_SRC is provided a Celix launcher will be build using the provided sources. Additional sources can be added with the
CMake ‘target_sources’ command.
- If a LAUNCHER (absolute path to a executable of CMake add_executable
target) is provided that will be used as Celix launcher.
Optional arguments:
- CXX: With this option the generated Celix launcher (if used) will be a C++ source instead of a C source.
A additional result of this is that Celix launcher is also linked against stdlibc++.
- GROUP: If configured the build location will be prefixed the GROUP. Default is empty.
- NAME: The name of the executable. Default is
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: - LEVEL: The run level for the added bundles. Default is 3.
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"
...
)