Building and Running

Note: Currently there is one build that builds Celix, the dependency manager and several small test bundles. This will be split into several small modules. Requirements

To be able to build Celix, the following is needed:

CMake (2.8.4 and higher)
GNU Make (3.81)
GCC (4.2.1)
Celix sources
Sub-project dependencies

Note: Currently the framework and the examples are in one large project, this results in required libraries which aren't used by the framework itself. The following is a list of libraries per sub-project:

Utils:
- Apache Portable Runtime
- CUnit

Framework:
- Apache Portable Runtime
- CUnit
- ZLib
- Utils (Celix sub-project)

Shell:
- all framework dependencies
- cURL

Remote Services:
- all framework dependencies
- Jansson (library for encoding/decoding JSON)
- Apache Portable Runtime Utils

Paint example:
- all framework dependencies
- GTK (2.14 or higher)

Building

Celix uses CMake to generate makefile. There are cmake scripts to build the libraries, but also to deploy created bundles to a named target. To start building and using Celix these makefiles have to be created. CMake supports out-of-source builds, for Celix the build directory is used for this.

// First extract the sources
svn co https://svn.apache.org/repos/asf/incubator/celix/trunk/ celix
cd celix

// Create and go to the build directory to be able to do an out-of-source build
mkdir build
cd build

// Generate the make files in the current directory
cmake ..

After generating the make files, the sources can be build. There are several build targets to build the bundles, deploy and package them. The following targets are available: // Build all libraries, bundles and packages make all -> build all libraries, bundles and packages

// Deploy all deployment targets
make deploy -> deploys all deployments

// Build a single bundle (and its dependencies)
make {bundle_name}

// Deploy a singe deployment target (and its dependencies)
make deploy_{deployment_name} -> deploys a single deployment (and dependencies)

// Clean the entire build, including deployment, bundles, libraries etc
make clean -> removes all deployments, bundles, libraries etc

// Build a "framework.zip" file with the framework, headers and selected bundles
make install-fw

Also it is possible to enter sub directories of the build and run the build from there. So when running make from "build/shell" only the shell (and dependencies) will be build. This is the same as running "make shell" in the build root.

Note: The build files are recursive. If a target is build, all required dependencies are build (bundles, libraries etc).

Bundles

In Celix a bundle is a library packed in a zip file. A bundle is a top level build target and can be added using the following macro:

bundle(<bundle_name> 
       SOURCES source1 source2 ... sourceN 
       [DIRECTORIES dir1 dir2 ... dirN] 
       [FILES file1 file2 ... fileN])

Include directories and link libraries can be defined using the standard CMake commands. The given examples are simplified for basic usage, see the CMake documentation for more information and advanced options.

include_directories(dir1 dir2 ...)
target_link_libraries(<bundle_name> [lib1 [lib2 [...]]])

To export files (eg a header file describing the service), a package is created using the "package" command.

package(<bundle_name> 
        [DIRECTORIES dir1 dir2 ... dirN] 
        [FILES file1 file2 ... fileN])

This can be used to create a package which contains the bundle and additional files (headers etc) needed to use the bundle in different projects.

Targets

A named target is used to deploy a group of bundles and create a default configuration file. To create a target the following command is needed:

deploy(<target_name> BUNDLES bundle1 bundle2 ... bundleN)

A target is deployed to the build directory where the deploy macro is used. So if in /examples a deploy macro is used, the deployment can be found in //examples.

Running

After building a target, it can be run. To run a target a launcher is needed. This launcher is build as part of the standard Celix build, and is located in build/launcher. The launcher is a simple executable requiring a configuration file in which required bundles are listed. If a target is deployed using the "deploy" macro, a configuration file is created by the build system. Finally before the launcher can be executed, the Celix library needs to be available on the library path. This depends on the OS being used:

Linux

export LD_LIBRARY_PATH={build_root}/celix

Mac

export DYLD_LIBRARY_PATH={build_root}/celix

If the library path is set, the launcher can be started.

{build_root}/launcher/launcher

Note: for the provided examples a "run.sh" script is generated which takes care of setting up the library path.

Requirements

  • CMake (2.8.4 and higher)
  • GCC (4.2.1)
  • GNU Make (3.81)
  • ZLib
  • CUnit
  • Celix Source