Name | Last modified | Size | Description | |
---|---|---|---|---|
Parent Directory | - | |||
For Apache Celix several cmake command are added to be able to work with Apache Celix bundles and deployments.
A bundle is a dynamically loadable collection of shared libraries, configuration files and optional an activation entry that can be dynamically installed and started in a Celix framework.
Add a Celix bundle to the project.
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" ...]
[DO_NOT_CONFIGURE_SYMBOL_VISIBILITY]
)
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" ...]
[DO_NOT_CONFIGURE_SYMBOL_VISIBILITY]
)
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" ...]
[DO_NOT_CONFIGURE_SYMBOL_VISIBILITY]
)
Example:
add_celix_bundle(my_bundle SOURCES src/my_activator.c)
There are three variants:
Optional arguments are:
Add libraries to a bundle.
celix_bundle_private_libs(<bundle_target>
lib1 lib2 ...
)
Example:
celix_bundle_private_libs(my_bundle my_lib1 my_lib2)
A library should be a cmake library target or an absolute path to 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:
Add files to the target bundle.
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...] [...]
)
Example:
celix_bundle_files(my_bundle ${CMAKE_CURRENT_LIST_DIR}/resources/my_file.txt DESTINATION META-INF/subdir)
DESTINATION is relative to the bundle archive root. The rest of the command is based on the 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 !!
Copy to the content of a directory to a bundle.
celix_bundle_add_dir(<bundle_target> <input_dir>
[DESTINATION <relative_path_in_bundle>]
)
Example:
celix_bundle_add_dir(my_bundle bundle_resources/ DESTINATION "resources")
Optional arguments:
Note celix_bundle_add_dir copies the dir and can track changes.
Copy to the content of a directory to a bundle.
celix_bundle_add_files(<bundle_target>
[FILES <file1> <file2> ...]
[DESTINATION <relative_path_in_bundle>]
)
Example:
celix_bundle_add_files(my_bundle FILES my_file1.txt my_file2.txt DESTINATION "resources")
Optional arguments:
Note celix_bundle_add_files copies the files and can track changes.
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)
Get bundle symbolic name from a (imported) bundle target.
celix_get_bundle_symbolic_name(<bundle_target> VARIABLE_NAME)
Example: celix_get_bundle_symbolic_name(Celix::shell SHELL_BUNDLE_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 a (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)
Get bundle file (absolute path to a bundle) from a (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)
Install bundle when ‘make install’ is executed.
install_celix_bundle(<bundle_target>
[EXPORT] export_name
[PROJECT_NAME] project_name
[BUNDLE_NAME] bundle_name
[HEADERS header_file1 header_file2 ...]
[RESOURCES resource1 resource2 ...]
)
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:
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.
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)
Optional Arguments:
Celix containers are executables preconfigured to start a Celix framework with a set of configuration properties and a set of bundles to install or install and start.
Add a Celix container, consisting out of a selection of bundles and a Celix launcher. Celix containers can be used to start a Celix framework together with a selection of bundles.
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
.celix_target_embedded_bundle
for more info about embedded bundles.celix_target_embedded_bundle
for more info about embedded bundles.add_celix_container(<celix_container_name>
[COPY]
[NO_COPY]
[CXX]
[C]
[FAT]
[USE_CONFIG]
[GROUP group_name]
[NAME celix_container_name]
[DIR dir]
[BUNDLES <bundle1> <bundle2> ...]
[INSTALL_BUNDLES <bundle1> <bundle2> ...]
[EMBEDDED_BUNDLES <bundle1> <bundle2> ...]
[INSTALL_EMBEDDED_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]
[FAT]
[USE_CONFIG]
[GROUP group_name]
[NAME celix_container_name]
[DIR dir]
[BUNDLES <bundle1> <bundle2> ...]
[INSTALL_BUNDLES <bundle1> <bundle2> ...]
[EMBEDDED_BUNDLES <bundle1> <bundle2> ...]
[INSTALL_EMBEDDED_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]
[FAT]
[USE_CONFIG]
[GROUP group_name]
[NAME celix_container_name]
[DIR dir]
[BUNDLES <bundle1> <bundle2> ...]
[INSTALL_BUNDLES <bundle1> <bundle2> ...]
[EMBEDDED_BUNDLES <bundle1> <bundle2> ...]
[INSTALL_EMBEDDED_BUNDLES <bundle1> <bundle2> ...]
[PROPERTIES "prop1=val1" "prop2=val2" ...]
[EMBEDDED_PROPERTIES "prop1=val1" "prop2=val2" ...]
[RUNTIME_PROPERTIES "prop1=val1" "prop2=val2" ...]
)
Examples:
#Creates a Celix container in ${CMAKE_BINARY_DIR}/deploy/simple_container which starts 3 bundles located at
#${CMAKE_BINARY_DIR}/deploy/simple_container/bundles.
add_celix_container(simple_container
BUNDLES
Celix::shell
Celix::shell_tui
Celix::log_admin
PROPERTIES
CELIX_LOGGING_DEFAULT_ACTIVE_LOG_LEVEL=debug
)
#Creates a "fat" Celix container in ${CMAKE_BINARY_DIR}/deploy/simple_fat_container which starts 3 bundles embedded
#in the container executable.
add_celix_container(simple_fat_container
FAT
EMBEDDED_BUNDLES
Celix::shell
Celix::shell_tui
Celix::log_admin
PROPERTIES
CELIX_LOGGING_DEFAULT_ACTIVE_LOG_LEVEL=debug
)
Add a selection of bundles to the Celix container.
celix_container_bundles(<celix_container_target_name>
[COPY]
[NO_COPY]
[LEVEL (0..6)]
[INSTALL]
bundle1
bundle2
...
)
Example:
celix_container_bundles(my_container Celix::shell Celix::shell_tui)
The selection of 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 is 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:
Embed a selection of bundles to the Celix container.
celix_container_embedded_bundles(<celix_container_target_name>
[LEVEL (0..6)]
[INSTALL]
bundle1
bundle2
...
)
Example:
celix_container_embedded_bundles(my_container Celix::shell Celix::shell_tui)
The selection of bundles are embedded in the container executable using the
celix_target_embedded_bundle
Celix CMake command and are added to the configuration properties so that they are
installed and started when the Celix container is executed.
See celix_target_embedded_bundle
for how bundle is embedded in a executable.
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:
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"
...
)
Celix provides several CMake commands that operate on the generic CMake targets (executable, shared library, etc).
Celix CMake commands for generic CMake target will always use the keyword signature (PRIVATE
, PUBLIC
, INTERFACE
)
version for linking, adding sources, etc. This means that these command will not work on targets created with
an “all-plain” CMake version command.
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...
)
add_celix_bundle_dependencies(my_exec my_bundle1 my_bundle2)
Embeds a Celix bundle into a CMake target.
celix_target_embedded_bundle(<cmake_target>
BUNDLE <bundle>
[NAME <name>]
)
Example:
celix_target_embedded_bundle(my_executable
BUNDLE Celix::shell
NAME celix_shell
)
# result in the symbols:
# - celix_embedded_bundle_celix_shell_start
# - celix_embedded_bundle_celix_shell_end
# - celix_embedded_bundles = "embedded://celix_shell"
# to be added to `my_executable`
The Celix bundle will be embedded into the CMake target between the symbols: celix_embedded_bundle_${NAME}_start
and
celix_embedded_bundle_${NAME}_end
.
Also a const char * const
symbol with the name celix_embedded_bundles
will be added or updated containing a ,
seperated list of embedded Celix bundle urls. The url will be: embedded://${NAME}
.
For Linux the linking flag --export-dynamic
is added to ensure that the previous mentioned symbols can be retrieved
using dlsym
.
Mandatory Arguments:
Optional Arguments:
Bundles embedded in an executable can be installed/started using the bundle url: “embedded://${NAME}” in
combination with celix_bundleContext_installBundle
(C) or celix::BundleContext::installBundle
(C++).
All embedded bundle can be installed using the framework utils function
celix_framework_utils_installEmbeddedBundles
(C) or celix::installEmbeddedBundles
(C++).
Embed multiple Celix bundles into a CMake target.
celix_target_embedded_bundles(<cmake_target> [<bundle1> <bundle2> ...])
Example:
celix_target_embedded_bundles(my_executable Celix::shell Celix::shell_tui)
The bundles will be embedded using their symbolic name if the bundle is a CMake target or their filename (without extension) if the bundle is a file (absolute path).
Add a compile-definition with a set of comma seperated bundles paths to a target and also adds the bundles as dependency to the target.
celix_target_bundle_set_definition(<cmake_target>
NAME <set_name>
[<bundle1> <bundle2>..]
)
Example:
celix_target_bundle_set_definition(test_example NAME TEST_BUNDLES Celix::shell Celix::shell_tui)
The compile-definition will have the name ${NAME}
and will contain a ,
separated list of bundle paths.
The bundle set can be installed using the Celix framework util function celix_framework_utils_installBundleSet
(C)
or celix::installBundleSet
(C++).
Adding a compile-definition with a set of bundles can be useful for testing purpose.
Configure the symbol visibility preset of the provided target to hidden.
This is done by setting the target properties C_VISIBILITY_PRESET to hidden, the CXX_VISIBILITY_PRESET to hidden and VISIBILITY_INLINES_HIDDEN to ON.
celix_target_hide_symbols(<cmake_target> [RELEASE] [DEBUG] [RELWITHDEBINFO] [MINSIZEREL])
Optional arguments are:
If no optional arguments are provided, the symbols are hidden for all build types.
Example:
celix_target_hide_symbols(my_bundle RELEASE MINSIZEREL)