This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/master by this push:
new 5030f273e gh-819: Simplify devcontainer setup (#820)
5030f273e is described below
commit 5030f273ec8eaaebecbbf185bbdd98fab3b2afc0
Author: Pepijn Noltes <[email protected]>
AuthorDate: Tue Feb 24 22:37:46 2026 +0100
gh-819: Simplify devcontainer setup (#820)
gh-819: Simplify devcontainer setup
- Remove the build script and conan profiles.
- Simplify the devcontainer Containerfile
- Change the setup to support Conan
- Update the building and testing documentation
---------
Co-authored-by: PengZheng <[email protected]>
---
.devcontainer/Containerfile | 110 +++++------------
.devcontainer/README.md | 89 ++++++++++----
.devcontainer/build-devcontainer-image.sh | 33 -----
.devcontainer/build-project-with-conan.sh | 24 ----
.devcontainer/conan-container-debug-profile | 26 ----
.devcontainer/conan-container-default-profile | 26 ----
.devcontainer/devcontainer.json | 36 +++++-
.devcontainer/run-devcontainer.sh | 133 ---------------------
.devcontainer/setup-project-with-apt.sh | 36 ------
.devcontainer/setup-project-with-conan.sh | 26 ----
.github/workflows/containers.yml | 78 +++---------
.github/workflows/coverage.yml | 8 +-
.github/workflows/fuzzing.yml | 28 +++--
.github/workflows/macos.yml | 8 +-
.github/workflows/ubuntu.yml | 11 +-
conanfile.py | 13 +-
documents/building/README.md | 166 +++++++++++++++-----------
documents/building/testing.md | 57 +++++----
18 files changed, 306 insertions(+), 602 deletions(-)
diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile
index cc2b2f8ca..2f145c4a6 100644
--- a/.devcontainer/Containerfile
+++ b/.devcontainer/Containerfile
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-FROM
docker.io/library/ubuntu:24.04@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30
as build
+FROM
docker.io/library/ubuntu:24.04@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30
as base
# Install dependencies
RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
@@ -28,101 +28,45 @@ RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
make \
zip \
ninja-build \
+ clang-tidy \
lcov \
sudo \
python3 \
pipx && \
apt-get clean
-#python3-pip && \
-
# Build image using conan & cmake
-FROM build as conan-build
-
-# Install conan
-#RUN pip3 install conan && pip3 cache purge
-##RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y
--no-install-recommends \
-# python3-conan && \
-# apt-get clean
-ENV PATH="${PATH}:/root/.local/bin"
-RUN pipx install conan
-
-# Setup conan profile for root
-COPY conan-container-default-profile /root/.conan2/profiles/default
-COPY conan-container-debug-profile /root/.conan2/profiles/debug
-
-# Build image using apt dependencies
-FROM build as apt-build
+FROM base as conan-build
-# Install celix dependencies (note git needed for cloning gtest)
-RUN DEBIAN_FRONTEND="noninteractive" sudo apt-get update && \
- DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y
--no-install-recommends \
- git \
- civetweb \
- libavahi-compat-libdnssd-dev \
- libcivetweb-dev \
- libcpputest-dev \
- libcurl4-openssl-dev \
- libczmq-dev \
- libffi-dev \
- libjansson-dev \
- libxml2-dev \
- libzip-dev \
- libuv1-dev \
- rapidjson-dev \
- uuid-dev && \
- sudo apt-get clean
+ARG USERNAME=celixdev
+ARG USER_UID=1000
+ARG USER_GID=1000
-#Note from build not conan-build, because conan-dev uses a celixdev user
-FROM build as conan-dev
-
-# Remove ubuntu user and add celixdev with sudo rights and a "celixdev"
password
RUN userdel -r ubuntu && \
- groupadd --gid 1000 celixdev && \
- useradd --uid 1000 --gid 1000 -m \
- -s /bin/bash -G sudo celixdev && \
- echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
- echo "celixdev:celixdev" | chpasswd
-USER celixdev
-WORKDIR /home/celixdev
-
-#Create workdir, used in vscode
-#RUN sudo mkdir -p /workspaces/celix/build && sudo chown -R celixdev:celixdev
/workspaces
+ groupadd --gid ${USER_GID} ${USERNAME} && \
+ useradd --uid ${USER_UID} --gid ${USER_GID} --create-home --shell
/bin/bash ${USERNAME} && \
+ usermod -aG sudo ${USERNAME} && \
+ echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
-# Setup python venv for celixdev and install conan
-ENV PATH="${PATH}:/home/celixdev/.local/bin"
-RUN pipx install conan
+USER ${USERNAME}
+WORKDIR /home/${USERNAME}
-# Setup conan profile for celixdev
-COPY --chown=celixdev:celixdev conan-container-default-profile
/home/celixdev/.conan2/profiles/default
-COPY --chown=celixdev:celixdev conan-container-debug-profile
/home/celixdev/.conan2/profiles/debug
+ENV PATH="${PATH}:/home/${USERNAME}/.local/bin"
+RUN pipx install conan && \
+ conan profile detect --force && \
+ cp /home/${USERNAME}/.conan2/profiles/default
/home/${USERNAME}/.conan2/profiles/release && \
+ cp /home/${USERNAME}/.conan2/profiles/default
/home/${USERNAME}/.conan2/profiles/debug && \
+ sed -i 's/^build_type=.*/build_type=Release/'
/home/${USERNAME}/.conan2/profiles/release && \
+ sed -i 's/^build_type=.*/build_type=Debug/'
/home/${USERNAME}/.conan2/profiles/debug
-#Install development dependencies
-RUN sudo DEBIAN_FRONTEND="noninteractive" apt-get update && \
- sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y
--no-install-recommends \
- gnupg2 dos2unix git locales-all rsync tar ssh tzdata sudo vim
openssh-server cmake-curses-gui gdb \
- wget curl && \
- sudo apt-get clean
+FROM conan-build as conan-dev
-RUN sudo mkdir /run/sshd
-
-FROM apt-build as apt-dev
-
-# Remove ubuntu user and add celixdev with sudo rights and a "celixdev"
password
-RUN userdel -r ubuntu && \
- groupadd --gid 1000 celixdev && \
- useradd --uid 1000 --gid 1000 -m \
- -s /bin/bash -G sudo celixdev && \
- echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
- echo "celixdev:celixdev" | chpasswd
-USER celixdev
-WORKDIR /home/celixdev
-
-#Install development dependencies
-RUN sudo DEBIAN_FRONTEND="noninteractive" apt-get update && \
- sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y
--no-install-recommends \
- gnupg2 dos2unix git locales-all rsync tar ssh tzdata sudo vim
openssh-server cmake-curses-gui gdb \
+USER root
+RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
+ DEBIAN_FRONTEND="noninteractive" apt-get install -y
--no-install-recommends \
+ gnupg2 dos2unix locales-all ssh rsync tar tzdata sudo vim cmake-curses-gui
gdb \
wget curl && \
- sudo apt-get clean
+ apt-get clean \
-RUN sudo mkdir /run/sshd
+USER ${USERNAME}
+WORKDIR /home/${USERNAME}
diff --git a/.devcontainer/README.md b/.devcontainer/README.md
index f521d8c29..2b0130ff8 100644
--- a/.devcontainer/README.md
+++ b/.devcontainer/README.md
@@ -21,49 +21,88 @@ limitations under the License.
This directory contains a [DevContainer](https://containers.dev) setup for
developing Apache Celix inside a container.
-Although Apache Celix can be built using CMake with APT-installed dependencies
or Conan with Conan-installed/built
-dependencies, this DevContainer setup currently only supports Conan.
+Although Apache Celix can be built using CMake with APT-installed dependencies
or Conan
+with Conan-installed/built dependencies, this DevContainer setup is based on
Conan.
Please note, the DevContainer setup is not broadly tested and might not work
on all systems.
-It has been tested on Ubuntu 23.10 and Fedora 40.
+It has been tested on MacOS 26 and Fedora 43, using podman.
+
+## Mounts
+
+The devcontainer uses the following container volumes to ensure dependency
build and project
+building is more efficient, even after recreating a devcontainer:
+
+- celixdev-conan-package-cache
+- celixdev-conan-download-cache
+- celixdev-ccache-cache
+
+Use `podman volume rm` / `docker volume rm` to remove the volumes if you do no
longer use them.
## VSCode Usage
VSCode has built-in support for DevContainers.
-Simply launch VSCode using the Celix workspace folder, and you will be
prompted to open the workspace in a container.
+Launch VSCode using the Celix workspace folder, and you will be prompted to
+open the workspace in a container.
-VSCode ensures that your host `.gitconfig` file, `.gnupg` directory, and SSH
agent forwarding are available in the
-container.
+VSCode ensures that your host `.gitconfig` file and SSH agent forwarding
+are available in the container.
## CLion Usage
-At the time of writing this readme, CLion does not fully support DevContainers,
-but there is some support focusing on Docker. Using a container and remote
development via SSH with CLion works.
+CLion 2025.3.1 includes DevContainer support (including Podman), so you can
open this repository directly
+using the IDE's DevContainer workflow. Once the container is built, enable and
select the conan-debug (generated)
+profile.
+
+When running "All CTests" from the CLion UI (2025.3.2), ensure that the
correct ctest args are used:
+ - ALT-SHIFT-F10 (`Run...`)
+ - Hover `All CTests`
+ - Click `Edit...`
+ - Configure CTest arguments to: `--preset conan-debug --extra-verbose -j1`
+ - Configure working directory to: `$ProjectFileDir$`
-To start developing in a container with build a CevContainer image using the
`build-devcontainer-image.sh` script
-and then start a container with SSHD running and interactively set up
`.gitconfig`, `.gnupg`, and SSH agent
-forwarding, using the `.devcontainer/run-dev-container.sh` script:
+When running gtests from the CLion UI (2025.3.2) directly from gtest sources,
ensure that the environment is
+correctly configured:
+ - Click "play" button next to the line numbers
+ - Click `Modify Run Configuration...`
+ - Click `Edit environment variables` (file icon in the `Environment
variables` textfield)
+ - Click `Browse` from "Load variables from file"
+ - Browse to `build/Debug/generators/conanrun.sh`
+ - Click `OK`, Click `Apply`, Click `Ok`
-```bash
-cd ${CELIX_ROOT}
-./.devcontainer/build-devcontainer-image.sh
-./.devcontainer/run-devcontainer.sh
-ssh -p 2233 celixdev@localhost
+## Conan Install
+
+Run conan install to install required dependencies and tools and generate the
needed cmake configuration files
+
+```shell
+conan install . --build missing --profile ${CONAN_PROFILE} ${CONAN_OPTS}
${CONAN_CONF}
```
-In CLion, open the Remote Development window by navigating to "File -> Remote
Development..." and add a new
-configuration. When a new configuration is added, you can start a new project
using `/home/celixdev/workspace` as the
-project root and selecting CLion as the IDE.
+Note: `CONAN_PROFILE`, `CONAN_OPTS` and `CONAN_CONF` are environments
variables in the dev container.
-Also ensure the CMake profile from the - conan generated -
`CMakeUserPresets.json` is used: Enable the profile in the
-Settings -> "Build, Execution, Deployment" -> CMake menu.
+## CMake Configure
+
+CMake configure can be done from the root workspace dir:
+
+```shell
+cmake --preset conan-debug
+```
+
+## Building
+
+Build can be done from the root workspace dir:
+
+```shell
+cmake --build --preset conan-debug --parallel
+```
## Running tests
+
Tests can be run using ctest.
-When building with conan, the conanrun.sh script will setup the environment
for the
-built dependencies. To run the tests, execute the following commands:
+When building with Conan, run tests from the build directory after
configuring/building:
```shell
-cd build
-ctest --output-on-failure --test-command ./workspaces/celix/build/conanrun.sh
+ctest --preset conan-debug --output-on-failure -j1
```
+
+Note `-j1` is needed to prevent ctest from running tests parallel; running
tests in parallel is currently not supported
+in Apache Celix.
diff --git a/.devcontainer/build-devcontainer-image.sh
b/.devcontainer/build-devcontainer-image.sh
deleted file mode 100755
index 65641c574..000000000
--- a/.devcontainer/build-devcontainer-image.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-#
-# 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.
-
-SCRIPT_LOCATION=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
-CELIX_REPO_ROOT=$(realpath "${SCRIPT_LOCATION}/..")
-IMAGE_TARGET="${1:-conan-dev}"
-
-# Check which container engine is available.
-# Check for podman first, because the 'podman-docker' package might be
installed providing a dummy 'docker' command.
-if command -v podman > /dev/null 2>&1; then
- CONTAINER_ENGINE="podman"
-else
- CONTAINER_ENGINE="docker"
-fi
-
-cd "${SCRIPT_LOCATION}"
-${CONTAINER_ENGINE} build -t apache/celix-${IMAGE_TARGET} -f Containerfile
--target ${IMAGE_TARGET} .
diff --git a/.devcontainer/build-project-with-conan.sh
b/.devcontainer/build-project-with-conan.sh
deleted file mode 100755
index d9819dec1..000000000
--- a/.devcontainer/build-project-with-conan.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-#
-# 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.
-
-conan build . --profile debug \
- --options celix/*:build_all=True --options
celix/*:enable_address_sanitizer=True \
- --options celix/*:enable_testing=True --options
celix/*:enable_ccache=True \
- --conf:build tools.cmake.cmaketoolchain:generator=Ninja \
- --output-folder build
diff --git a/.devcontainer/conan-container-debug-profile
b/.devcontainer/conan-container-debug-profile
deleted file mode 100644
index c10d4ab7a..000000000
--- a/.devcontainer/conan-container-debug-profile
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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.
-
-#Based on gcc from ubuntu:24.04 base image
-[settings]
-arch=x86_64
-build_type=Debug
-compiler=gcc
-compiler.cppstd=17
-compiler.libcxx=libstdc++11
-compiler.version=13
-os=Linux
diff --git a/.devcontainer/conan-container-default-profile
b/.devcontainer/conan-container-default-profile
deleted file mode 100644
index 93ca74d75..000000000
--- a/.devcontainer/conan-container-default-profile
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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.
-
-#Based on gcc from ubuntu:24.04 base image
-[settings]
-arch=x86_64
-build_type=Release
-compiler=gcc
-compiler.cppstd=17
-compiler.libcxx=libstdc++11
-compiler.version=13
-os=Linux
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 7c9ee3307..b8dd32653 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -4,12 +4,40 @@
"dockerfile": "Containerfile",
"target": "conan-dev"
},
- "runArgs" : [
+ "runArgs": [
"--userns=keep-id"
],
- "securityOpt":["label=disable"],
+ "mounts": [
+
"type=volume,source=celixdev-conan-package-cache,target=/home/celixdev/.conan2/p",
+
"type=volume,source=celixdev-conan-download-cache,target=/home/celixdev/.conan2/d",
+
"type=volume,source=celixdev-ccache-cache,target=/home/celixdev/.ccache"
+ ],
+ "containerEnv": {
+ "CONAN_PROFILE": "debug",
+ "CONAN_OPTS": "--options celix/*:build_all=True -o
celix/*:enable_address_sanitizer=True -o celix/*:enable_testing=True -o
celix/*:enable_ccache=True -o celix/*:enable_code_coverage=True",
+ "CONAN_CONF": "--conf tools.cmake.cmaketoolchain:generator=Ninja",
+ },
+ "securityOpt": [
+ "label=disable"
+ ],
"remoteUser": "celixdev",
"containerUser": "celixdev",
- "onCreateCommand": "sh .devcontainer/setup-project-with-conan.sh",
- "postCreateCommand": "sh .devcontainer/build-project-with-conan.sh"
+ "onCreateCommand": "conan install . --build missing --profile
${CONAN_PROFILE} ${CONAN_OPTS} ${CONAN_CONF}",
+ "features": {
+ "ghcr.io/devcontainers/features/git:1": {},
+ "ghcr.io/devcontainers/features/github-cli:1": {}
+ },
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "ms-vscode.cpptools-extension-pack",
+ "ms-vscode.cpptools",
+ "matepek.vscode-catch2-test-adapter",
+ "ms-vscode.cmake-tools"
+ ]
+ },
+ "jetbrains": {
+ "backend": "CLion"
+ }
+ }
}
diff --git a/.devcontainer/run-devcontainer.sh
b/.devcontainer/run-devcontainer.sh
deleted file mode 100755
index 7af6b7a6d..000000000
--- a/.devcontainer/run-devcontainer.sh
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-# Start a Celix dev container with all needed dependencies
-# pre-installed already.
-
-SCRIPT_LOCATION=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
-CELIX_REPO_ROOT=$(realpath "${SCRIPT_LOCATION}/..")
-CELIX_CONTAINER_ROOT="/home/celixdev/workspace"
-
-CONTAINER_SSH_PORT=2233
-CONTAINER_COMMAND_DEFAULT="sudo chown -R celixdev:celixdev
${CELIX_CONTAINER_ROOT} && sudo /usr/sbin/sshd -D -e -p ${CONTAINER_SSH_PORT}"
-CONTAINER_COMMAND=${1:-${CONTAINER_COMMAND_DEFAULT}}
-CONTAINER_NAME="celixdev"
-
-# Check which container engine is available.
-# Check for podman first, because the 'podman-docker' package might be
installed providing a dummy 'docker' command.
-if command -v podman > /dev/null 2>&1; then
- CONTAINER_ENGINE="podman"
-else
- CONTAINER_ENGINE="docker"
-fi
-
-ask_and_execute() {
- local QUESTION="$1"
- local FUNC_NAME="$2"
-
- # Prompt the user with the question
- while true; do
- read -p "${QUESTION} (yes/no): " yn
- case $yn in
- [Yy]* )
- # Call the provided function if the answer is yes
- ${FUNC_NAME}
- echo ""
- break;;
- [Nn]* )
- # Exit if the answer is no
- break;;
- * )
- echo "Please answer yes or no.";;
- esac
- done
-}
-
-remove_celixdev_container() {
- echo "Removing container '${CONTAINER_NAME}'"
- ${CONTAINER_ENGINE} rm -f ${CONTAINER_NAME}
-}
-# Check if container celixdev already exists
-if [ "$(${CONTAINER_ENGINE} ps -a --format '{{.Names}}' | grep
${CONTAINER_NAME})" ]; then
- ask_and_execute "Container '${CONTAINER_NAME}' already exists. Do you want
to remove it?" remove_celixdev_container
-fi
-
-# Check again if container celixdev already exists and exit if it does
-if [ "$(${CONTAINER_ENGINE} ps -a --format '{{.Names}}' | grep
${CONTAINER_NAME})" ]; then
- echo "Container '${CONTAINER_NAME}' already exists. Exiting."
- exit 1
-fi
-
-ADDITIONAL_ARGS=""
-
-GNUPG_DIR_MOUNTED=false
-add_gnupg_mount() {
- echo "Adding .gnupg directory mount arguments"
- ADDITIONAL_ARGS="${ADDITIONAL_ARGS} --volume
${HOME}/.gnupg:/home/celixdev/.gnupg:O"
- GNUPG_DIR_MOUNTED=true
-}
-if [ -e "${HOME}/.gnupg" ]; then
- ask_and_execute "Do you want to mount the .gnupg directory to the container
(as an overlayfs)?" add_gnupg_mount
-fi
-
-add_gitconfig_mount() {
- echo "Adding .gitconfig file mount arguments"
- ADDITIONAL_ARGS="${ADDITIONAL_ARGS} --volume
${HOME}/.gitconfig:/home/celixdev/.gitconfig:ro"
-}
-if [ -e "${HOME}/.gitconfig" ]; then
- ask_and_execute "Do you want to mount the .gitconfig file to the container
(as read-only)?" add_gitconfig_mount
-fi
-
-add_sshagent_forward()
-{
- echo "Adding SSH agent forwarding"
- ADDITIONAL_ARGS="${ADDITIONAL_ARGS} --volume ${SSH_AUTH_SOCK}:/ssh-agent
--env SSH_AUTH_SOCK=/ssh-agent"
-}
-if [ -n "${SSH_AUTH_SOCK}" ]; then
- ask_and_execute "Do you want to forward the SSH agent to the container?"
add_sshagent_forward
-fi
-
-# Start a container with all the Celix dependencies pre-installed
-# --userns=keep-id is used to keep the user id the same in the
container as on the host
-# --privileged to allow the unit tests to change thread priorities
-# -d runs the container in detached mode
-# -it starts the container in interactive mode
-# --rm removes the container when it is stopped
-# --net=host is used to allow e.g. communication with etcd
-# --volume & --workdir are set to the Celix repo root (to allow building
and editing of the Celix repo)
-# --security-opt disables SELinux for the container
-echo "Starting container '${CONTAINER_NAME}' with command:
${CONTAINER_COMMAND}"
-${CONTAINER_ENGINE} run -it --rm --privileged -d \
- --name ${CONTAINER_NAME} \
- --userns=keep-id \
- --net=host \
- ${ADDITIONAL_ARGS} \
- --volume "${CELIX_REPO_ROOT}":${CELIX_CONTAINER_ROOT} \
- --workdir "${CELIX_CONTAINER_ROOT}" \
- --security-opt label=disable \
- apache/celix-conan-dev:latest bash -c
"${CONTAINER_COMMAND}"
-echo ""
-
-build_conan_deps() {
- echo "Building Celix dependencies with Conan"
- ${CONTAINER_ENGINE} exec -it ${CONTAINER_NAME} bash -c "cd
${CELIX_CONTAINER_ROOT} && .devcontainer/setup-project-with-conan.sh"
-}
-ask_and_execute "Do you want to build Celix dependencies with Conan?"
build_conan_deps
-
-echo "Done. You can connect with ssh using 'ssh -p 2233 celixdev@localhost'
and password 'celixdev'"
diff --git a/.devcontainer/setup-project-with-apt.sh
b/.devcontainer/setup-project-with-apt.sh
deleted file mode 100755
index 403fb7379..000000000
--- a/.devcontainer/setup-project-with-apt.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-#
-# 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.
-
-BUILD_TYPE=${1:-Debug}
-LC_BUILD_TYPE=$(echo ${BUILD_TYPE} | tr '[:upper:]' '[:lower:]')
-
-mkdir -p cmake-build-${LC_BUILD_TYPE}
-
-cmake -S . \
- -G Ninja \
- -B cmake-build-${LC_BUILD_TYPE} \
- -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
- -DCMAKE_INSTALL_PREFIX=/tmp/celix-install \
- -DENABLE_TESTING=ON \
- -DENABLE_ADDRESS_SANITIZER=ON \
- -DRSA_JSON_RPC=ON \
- -DRSA_SHM=ON \
- -DRSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON
-
-cmake --build cmake-build-${LC_BUILD_TYPE} --parallel
diff --git a/.devcontainer/setup-project-with-conan.sh
b/.devcontainer/setup-project-with-conan.sh
deleted file mode 100755
index 0a9539997..000000000
--- a/.devcontainer/setup-project-with-conan.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-#
-# 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.
-
-mkdir build
-
-conan install . --build missing --profile debug \
- --options celix/*:build_all=True --options
celix/*:enable_address_sanitizer=True \
- --options celix/*:enable_testing=True --options
celix/*:enable_ccache=True \
- --conf:build tools.cmake.cmaketoolchain:generator=Ninja \
- --output-folder build
diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml
index a47c1a197..c59fd9a9e 100644
--- a/.github/workflows/containers.yml
+++ b/.github/workflows/containers.yml
@@ -14,7 +14,7 @@ jobs:
- name: Cache Conan
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf #v4.2.2
with:
- path: ~/.conan2-container
+ path: ~/.conan2-container-package-cache
key: cache-conan-container-${{ runner.os }}-${{ github.job }}-${{
hashFiles('conanfile.py', '.devcontainer/*') }}
restore-keys: cache-conan-container-${{ runner.os }}-${{ github.job
}}-
- name: Cache ccache
@@ -27,68 +27,29 @@ jobs:
run: |
cd .devcontainer && \
docker build --tag apache/celix-conan-build:latest --target
conan-build --file Containerfile .
- - name: Build Celix dependencies
- run: | #Using .conan2-container so that the steps can be reproduced
locally without affecting the host conan
- mkdir -p ~/.conan2-container/profiles && \
- cp .devcontainer/conan-container-default-profile
~/.conan2-container/profiles/default && \
- cp .devcontainer/conan-container-debug-profile
~/.conan2-container/profiles/debug && \
- docker run --rm -v ~/.conan2-container:/root/.conan2 -v
$(pwd):/workspace \
- apache/celix-conan-build:latest /bin/bash -c \
- "cd /workspace && \
- conan install . --build missing --profile debug \
- --options celix/*:build_all=True --options
celix/*:enable_address_sanitizer=True \
- --options celix/*:enable_testing=True --options
celix/*:enable_ccache=True \
- --conf:build tools.cmake.cmaketoolchain:generator=Ninja \
- --output-folder build"
- name: Build Celix
run: |
- mkdir -p ~/.ccache-container && \
- docker run --rm -v ~/.conan2-container:/root/.conan2 -v
~/.ccache-container:/root/.ccache \
- -v $(pwd):/workspace apache/celix-conan-build:latest /bin/bash -c \
- "cd /workspace && \
- conan build . --profile debug \
+ mkdir -p ~/.conan2-container-package-cache
+ chmod -R 777 ~/.conan2-container-package-cache
+ mkdir -p ~/.ccache-container
+ chmod -R 777 ~/.ccache-container
+ chmod -R 777 ${GITHUB_WORKSPACE}
+ docker run --rm \
+ -v ~/.conan2-container-package-cache:/home/celixdev/.conan2/p \
+ -v ~/.ccache-container:/bome/celixdev/.ccache \
+ -v $(pwd):/home/celixdev/workspace apache/celix-conan-build:latest
/bin/bash -c \
+ "cd /home/celixdev/workspace && \
+ conan build . -pr:b release -pr:h debug --build=missing \
--options celix/*:build_all=True --options
celix/*:enable_address_sanitizer=True \
--options celix/*:enable_testing=True --options
celix/*:enable_ccache=True \
- --conf:build tools.cmake.cmaketoolchain:generator=Ninja \
- --output-folder build"
- - name: Test Celix
- run: |
- docker run --rm -v ~/.conan2-container:/root/.conan2 -v
$(pwd):/workspace \
- apache/celix-conan-build:latest /bin/bash -c \
- "cd /workspace/build && \
- source conanrun.sh && \
- ctest --output-on-failure"
-
- container-apt-build-ubuntu:
- runs-on: ubuntu-22.04
- timeout-minutes: 120
- steps:
- - name: Checkout source code
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0
- - name: Build container image
- run: |
- cd .devcontainer && \
- docker build --tag apache/celix-apt-build:latest --target apt-build
--file Containerfile .
- - name: Cache ccache
- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf #v4.2.2
- with:
- path: ~/.ccache-container
- key: cache-ccache-container-${{ runner.os }}-${{ github.job }}-${{
github.sha }}
- restore-keys: cache-ccache-container-${{ runner.os }}-${{ github.job
}}-
- - name: Build Celix
- run: |
- docker run --rm -v ~/.ccache-container:/root/.ccache -v
$(pwd):/workspace \
- apache/celix-apt-build:latest /bin/bash -c \
- "mkdir /workspace/build && cd /workspace/build && \
- cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_EXPERIMENTAL=ON
-DENABLE_TESTING=ON -DRSA_JSON_RPC=ON \
- -DRSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON -DENABLE_CCACHE=ON .. && \
- make -j"
+ --conf:build tools.cmake.cmaketoolchain:generator=Ninja"
- name: Test Celix
run: |
- docker run --rm -v $(pwd):/workspace apache/celix-apt-build:latest
/bin/bash -c \
- "cd /workspace/build && \
- ctest --output-on-failure"
-
+ docker run --rm \
+ -v ~/.conan2-container-package-cache:/home/celixdev/.conan2/p \
+ -v $(pwd):/home/celixdev/workspace apache/celix-conan-build:latest
/bin/bash -c \
+ "cd /home/celixdev/workspace && \
+ ctest --preset conan-debug --output-on-failure -j1"
build-dev-container-images:
runs-on: ubuntu-22.04
timeout-minutes: 120
@@ -98,5 +59,4 @@ jobs:
- name: Build dev container images
run: |
cd .devcontainer && \
- docker build --tag apache/celix-conan-dev:latest --target conan-dev
--file Containerfile . && \
- docker build --tag apache/celix-apt-dev:latest --target apt-dev
--file Containerfile .
+ docker build --tag apache/celix-conan-dev:latest --target conan-dev
--file Containerfile .
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 4ad7a2339..451c0f8de 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -63,13 +63,13 @@ jobs:
-o celix/*:enable_testing_on_ci=True
-o celix/*:enable_ccache=True
run: |
- conan build . -pr:b release -pr:h default -of build
${CONAN_BUILD_OPTIONS} -b missing
+ conan build . -pr:b release -pr:h default ${CONAN_BUILD_OPTIONS} -b
missing
- name: Test with coverage
run: |
- cd build
- source conanrun.sh
+ cd build/Debug
+ source generators/conanrun.sh
make coverage
- source deactivate_conanrun.sh
+ source generators/deactivate_conanrun.sh
lcx="lcov --output-file=coverage.info " && for i in `find . -name
"*.info.cleaned"`; do lcx+=" --add-tracefile=$i"; done && $lcx
- name: Codecov
uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c
#v4.4.1
diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml
index 242b47567..f78916085 100644
--- a/.github/workflows/fuzzing.yml
+++ b/.github/workflows/fuzzing.yml
@@ -32,11 +32,16 @@ jobs:
${{ runner.os }}-conan-
- name: Setup Conan Profile
run: |
- conan profile detect
- - name: Conan install
- run: conan install . --output-folder=build --build=missing -o
"celix/*:build_utils=True" -o "celix/*:enable_fuzzing=True" -o
"celix/*:enable_address_sanitizer=True" -o
"celix/*:enable_undefined_sanitizer=True"
+ conan profile detect
- name: Conan build
- run: conan build . --output-folder=build -o "celix/*:build_utils=True"
-o "celix/*:enable_fuzzing=True" -o "celix/*:enable_address_sanitizer=True" -o
"celix/*:enable_undefined_sanitizer=True" -o
"celix/*:celix_err_buffer_size=5120"
+ env:
+ CONAN_BUILD_OPTIONS: |
+ -o celix/*:build_utils=True
+ -o celix/*:enable_fuzzing=True
+ -o celix/*:enable_address_sanitizer=True
+ -o celix/*:enable_undefined_sanitizer=True
+ -o celix/*:celix_err_buffer_size=5120
+ run: conan build -c tools.cmake.cmaketoolchain:generator=Ninja
${CONAN_BUILD_OPTIONS} -b missing
- name: Set fuzzer run time
id: set-runtime
run: |
@@ -47,13 +52,16 @@ jobs:
fi
- name: Run properties fuzzer
run: |
- source build/conanrun.sh
- ./build/libs/utils/fuzzing/celix_properties_fuzzer
-max_total_time=$FUZZ_TIME ./build/libs/utils/fuzzing/properties_corpus
+ cd build/Release
+ source generators/conanrun.sh
+ ./libs/utils/fuzzing/celix_properties_fuzzer
-max_total_time=$FUZZ_TIME ./libs/utils/fuzzing/properties_corpus
- name: Run version fuzzer
run: |
- source build/conanrun.sh
- ./build/libs/utils/fuzzing/celix_version_fuzzer
-max_total_time=$FUZZ_TIME ./build/libs/utils/fuzzing/version_corpus
+ cd build/Release
+ source generators/conanrun.sh
+ ./libs/utils/fuzzing/celix_version_fuzzer -max_total_time=$FUZZ_TIME
./libs/utils/fuzzing/version_corpus
- name: Run filter fuzzer
run: |
- source build/conanrun.sh
- ./build/libs/utils/fuzzing/celix_filter_fuzzer
-max_total_time=$FUZZ_TIME ./build/libs/utils/fuzzing/filter_corpus
+ cd build/Release
+ source generators/conanrun.sh
+ ./libs/utils/fuzzing/celix_filter_fuzzer -max_total_time=$FUZZ_TIME
./libs/utils/fuzzing/filter_corpus
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index f8279ae81..806ee35bd 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -64,13 +64,9 @@ jobs:
-o celix/*:framework_curlinit=False
-o celix/*:enable_ccache=True
run: |
- conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b
default -pr:h default -s:b build_type=Release -s:h build_type=Release -of build
${CONAN_BUILD_OPTIONS} -b missing
+ conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b
default -pr:h default -s:b build_type=Release -s:h build_type=Release
${CONAN_BUILD_OPTIONS} -b missing
- name: Test
- run: |
- cd build
- source conanrun.sh
- ctest --output-on-failure
- source deactivate_conanrun.sh
+ run: ctest --preset conan-release --output-on-failure -j1
macos-build-brew:
runs-on: macOS-15
diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml
index 640d34552..0532f37ca 100644
--- a/.github/workflows/ubuntu.yml
+++ b/.github/workflows/ubuntu.yml
@@ -82,13 +82,12 @@ jobs:
-o celix/*:framework_curlinit=False
-o celix/*:enable_ccache=True
run: |
- conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b
release -pr:h default -of build ${CONAN_BUILD_OPTIONS} -b missing
+ conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b
release -pr:h default ${CONAN_BUILD_OPTIONS} -b missing
- name: Test
- run: |
- cd build
- source conanrun.sh
- ctest --output-on-failure
- source deactivate_conanrun.sh
+ env:
+ CONAN_PRESET: ${{ matrix.type == 'Debug' && 'conan-debug'' ||
'conan-release' }}
+ run: ctest --preset ${CONAN_PRESET} --output-on-failure -j1
+
linux-build-apt:
runs-on: ubuntu-22.04
diff --git a/conanfile.py b/conanfile.py
index 104a9e52a..bdf002d31 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -17,7 +17,7 @@
from conan import ConanFile, conan_version
from conan.errors import ConanInvalidConfiguration
-from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain
+from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.scm import Version
from conan.tools.files import copy
import os
@@ -87,7 +87,6 @@ class CelixConan(ConanFile):
"build_event_admin_remote_provider_mqtt": False,
"celix_cxx14": True,
"celix_cxx17": True,
- "celix_install_deprecated_api": False,
"celix_use_compression_for_bundle_zips": True,
"enable_cmake_warning_tests": False,
"enable_testing_on_ci": False,
@@ -235,7 +234,6 @@ class CelixConan(ConanFile):
options["build_framework"] = True
options["build_log_helper"] = True
options["build_celix_dfi"] = True
- options["celix_install_deprecated_api"] = True
if options["build_event_admin"]:
options["build_framework"] = True
@@ -277,8 +275,6 @@ class CelixConan(ConanFile):
if options["build_log_service_api"]:
options["build_utils"] = True
- if options["celix_install_deprecated_api"]:
- options["build_framework"] = True
if options["build_components_ready_check"]:
options["build_framework"] = True
@@ -377,10 +373,15 @@ class CelixConan(ConanFile):
self.requires("mosquitto/[>=2.0.3 <3.0.0]")
self.validate()
+ def layout(self):
+ cmake_layout(self)
+
def generate(self):
tc = CMakeToolchain(self)
+ conan_internal_options = ["build_all"] #options are not used in CMake
for opt in self._celix_defaults.keys():
- tc.cache_variables[opt.upper()] = self.options.get_safe(opt)
+ if opt not in conan_internal_options:
+ tc.cache_variables[opt.upper()] = self.options.get_safe(opt)
if self.options.enable_testing:
lst = [x.ref.name for x in self.requires.values()]
if "mdnsresponder" in lst:
diff --git a/documents/building/README.md b/documents/building/README.md
index 7d01b8bb7..7e27d2a95 100644
--- a/documents/building/README.md
+++ b/documents/building/README.md
@@ -20,13 +20,11 @@ limitations under the License.
-->
# Building and Installing Apache Celix
+
Apache Celix aims to be support a broad range of UNIX platforms.
Currently, the [continuous integration build server] builds and tests Apache
Celix for:
-* Ubuntu Focal Fossa (20.04)
- * GCC
- * CLang
* Ubuntu Jammy Jellyfish (22.04)
* GCC
* CLang
@@ -43,6 +41,7 @@ git clone --single-branch --branch master
https://github.com/apache/celix.git
```
## Building and installing
+
Apache Celix can be build using [Conan](https://conan.io) as package
manager/build system or by directly using
[CMake](https://cmake.org).
@@ -50,10 +49,8 @@ Apache Celix can be build using [Conan](https://conan.io) as
package manager/bui
The following packages (libraries + headers) should be installed on your
system:
* Development Environment
- * build-essentials (gcc/g++ or clang/clang++)
- * java or zip (for packaging bundles)
- * make (3.14 or higher)
- * git
+ * build-essentials
+ * zip (for packaging bundles)
* cmake (3.19 or higher)
* Conan (2 or higher)
@@ -69,45 +66,66 @@ sudo apt-get install -yq --no-install-recommends \
ninja-build
#Install conan
-pip3 install -U conan
+pip3 install -U conan
```
-Configure conan default profile using automatic detection of the system
+Configure the Conan default profile using automatic detection of the system:
```bash
conan profile detect
```
-Create Apache Celix package - and build the dependencies - in the Conan cache:
+Conan 2 uses a two-step workflow: first generate the CMake presets and
toolchain files with `conan install`,
+then configure and build with CMake. The project provides convenient presets
when you run `conan install`.
+
+Create a build directory and install dependencies (this will generate
CMakePresets.json / CMakeUserPresets.json in the source or build folder):
+
```bash
cd <celix_source_dir>
-conan create . --build missing -o build_all=True
-#Optionally build with CMake->Ninja, instead of CMake->Make. Note this
includes building dependencies with Ninja.
-conan create . --build missing -o build_all=True -c
tools.cmake.cmaketoolchain:generator=Ninja
+# Create an output folder for the conan-generated files
+conan install . --build=missing --profile:build default --profile:host debug \
+ -o "celix/*:build_all=True" \
+ -o "celix/*:enable_testing=True" \
+ -o "celix/*:enable_ccache=True" \
+ --conf tools.cmake.cmaketoolchain:generator=Ninja
```
-Note installing Apache Celix is not required when using Conan, because Conan
will install the Apache Celix package
-in the local Conan cache.
+Notes:
+- Use `--profile:host debug` or `--profile:host default` depending on the host
(target) profile you want to generate builds for.
+- Replace or add `-o` options to selectively enable/disable bundles (see
below).
+
+Configure and build using the generated CMake preset (Conan will create
presets named like `conan-debug` when
+using `--profile:host debug`, assuming the build_type is `Debug`):
-It is also possible to only build a selection of the Apache Celix bundles
and/or libs. This can be done by providing
-build options for the required parts instead of the `build_all=True` option.
For example to only build the Apache Celix
-framework library and the Apache Celix utils library use the following command:
```bash
-conan create . --build missing -o build_framework=True -o build_utils=True
+# Configure with a conan-generated preset (conan-debug in this case)
+ cmake --build --preset conan-debug --parallel
```
-To see a complete overview of the available build options use the following
command:
+When using Conan you typically do not "install" Celix system-wide; Conan
places package artifacts in the local Conan
+cache and the generated build files allow you to produce executables and run
tests.
+
+It is also possible to only build a selection of the Apache Celix bundles
and/or libraries.
+This can be done by passing per-package options instead of building
everything.
+For example, to only build the framework and utils libraries:
+```bash
+conan install . --build=missing --profile:build default --profile:host debug \
+ -o "celix/*:build_framework=True" \
+ -o "celix/*:build_utils=True"
+ cmake --build --preset conan-debug --parallel
+```
+
+To see a complete overview of the available build options in the recipe you
can inspect the recipe metadata (this works for local recipes too):
```bash
conan inspect . | grep build_
```
-#### CMake Private Linking Workaround
+#### CMake Private Linking Workaround (Conan)
-When using Celix via Conan, you may encounter an
[issue](https://github.com/apache/celix/issues/642) where libzip.so is not
found by linker.
-This is due to a [bug in Conan](https://github.com/conan-io/conan/issues/7192).
+When using Celix via Conan, you may encounter an
[issue](https://github.com/apache/celix/issues/642) where `libzip.so` is not
found by the linker. This is due to a [bug in
Conan](https://github.com/conan-io/conan/issues/7192).
-A workaround we adopt in Celix is adding the following to conanfile.py:
+A workaround we adopt in Celix is adding the following to `conanfile.py` (the
same approach applies for Conan 2's `generate()`):
-```python
+```text
def generate(self):
deps = CMakeDeps(self)
deps.generate()
@@ -125,58 +143,65 @@ The following packages (libraries + headers) should be
installed on your system:
* Development Environment
* build-essentials (gcc/g++ or clang/clang++)
- * java or zip (for packaging bundles)
- * make (3.19 or higher)
- * git
+ * zip (for packaging bundles)
+ * cmake (3.19 or higher)
+ * ninja (to build with ninja instead of make)
* Apache Celix Dependencies
* libzip
* uuid
* zlib
* curl (only initialized in the Celix framework)
- * jansson (for serialization in libdfi)
+ * jansson (json properties and manifest handling)
* libffi (for libdfi)
* libxml2 (for remote services and bonjour shell)
* rapidjson (for C++ remote service discovery)
+ * libavahi (for remote service discovery)
+ * libuv (for threading abstraction)
+ * libcurl (used in framwork for setup and (among others) in remote services
For Ubuntu 22.04, use the following commands:
+
```bash
-#### get dependencies
-sudo apt-get install -yq --no-install-recommends \
- build-essential \
- cmake \
- git \
- curl \
- uuid-dev \
- libjansson-dev \
- libcurl4-openssl-dev \
- default-jdk \
- libffi-dev \
- libzip-dev \
- libxml2-dev \
- libcpputest-dev \
- rapidjson-dev
+sudo apt-get update
+sudo apt-get install --no-install-recommends \
+ build-essential \
+ ninja-build \
+ curl \
+ uuid-dev \
+ libzip-dev \
+ libjansson-dev \
+ libcurl4-openssl-dev \
+ libbenchmark-dev \
+ libuv1-dev \
+ cmake \
+ libffi-dev \
+ libxml2-dev \
+ rapidjson-dev \
+ libavahi-compat-libdnssd-dev \
+ ccache
```
For OSX systems with brew installed, use the following commands:
```bash
brew update && \
-brew install lcov libffi libzip rapidjson libxml2 cmake jansson && \
-brew link --force libffi
+brew install lcov jansson rapidjson libzip ccache ninja [email protected]
google-benchmark libuv
```
-Use CMake and make to build Apache Celix
+Use CMake to configure and build Apache Celix (prefer CMake's --build and
--install helper commands over raw make):
```bash
cd celix
-mkdir build
-cd build
-cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
-make -j
+# configure using CMake and Ninja generator
+cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja -S . -B build
+# build using CMake
+cmake --build build --parallel
+# (optional) install
+sudo cmake --install build
```
## Editing Build options
-With use of CMake, Apache Celix makes it possible to edit build options. This
enabled users, among other options, to configure a install location and select
additional bundles.
-To edit the options use ccmake or cmake-gui. For cmake-gui an additional
package install can be necessary (Fedora: `dnf install cmake-gui`).
+With use of CMake, Apache Celix makes it possible to edit build options. This
enabled users, among other options,
+to configure a install location and select additional bundles.
```bash
cd celix/build
@@ -190,9 +215,8 @@ For this guide we assume the CMAKE_INSTALL_PREFIX is
`/usr/local`.
## Installing Apache Celix
```bash
-cd celix/build
-make -j
-sudo make install
+cmake --build build --parallel
+sudo cmake --install build
```
## Running Apache Celix
@@ -209,33 +233,33 @@ For more info how to build your own projects and/or
running the Apache Celix exa
```bash
#bash
git clone [email protected]:apache/celix.git
-mkdir celix/build
-cd celix/build
-cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../libs/etcdlib
-make -j
-sudo make install
+cd celix
+# Configure the build from the top-level source dir, but point CMake to the
etcdlib source
+cmake -S libs/etcdlib -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
+cmake --build build --parallel
+sudo cmake --install build
```
# Building Celix Promises library standalone
```bash
#bash
git clone [email protected]:apache/celix.git
-mkdir celix/build
-cd celix/build
-cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../libs/promises
-make -j
-sudo make install
+cd celix
+# Configure the build from the top-level source dir, but point CMake to the
promises source
+cmake -S libs/promises -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
+cmake --build build --parallel
+sudo cmake --install build
```
# Building Celix Push Streams library standalone
```bash
#bash
git clone [email protected]:apache/celix.git
-mkdir celix/build
-cd celix/build
-cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../libs/pushstreams
-make -j
-sudo make install
+cd celix
+# Configure the build from the top-level source dir, but point CMake to the
pushstreams source
+cmake -S libs/pushstreams -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
+cmake --build build --parallel
+sudo cmake --install build
```
# Further Reading
diff --git a/documents/building/testing.md b/documents/building/testing.md
index 557258ce0..10288f21a 100644
--- a/documents/building/testing.md
+++ b/documents/building/testing.md
@@ -22,44 +22,53 @@ limitations under the License.
# Testing Apache Celix
This document describes how to build and run tests for Apache Celix.
+Building and testing can be done with Conan 2 (recommended) or with system
CMake (manual dependencies).
-## Building Tests
+## Build & test using Conan 2 (recommended)
-Celix uses CMake and Google Test for its unit and integration tests. To build
the tests, ensure you have all dependencies installed, then run:
+If the [building](README.md) instructions for conan where followed, there
should be a `build/Debug` build directory
+and a `conan-debug` cmake preset. This preset can be used to run the tests
using ctest:
-```sh
-cmake -B build -DENABLE_TESTING=ON -DCMAKE_BUILD_TYPE=Debug
-cmake --build build
+```bash
+ctest --preset conan-debug --output-on-failure -j1
```
-```sh
-#conan
+Notes:
+ - `-j1` is needed because the Apache Celix tests are using cache directories
and are not prepared for parallel testing.
+ - Use `-o "celix/*:enable_address_sanitizer=True"` during `conan install` to
enable AddressSanitizer (ASAN).
+ - Use `-o "celix/*:enable_undefined_sanitizer"` during `conan install` to
enable UndefinedBehaviorSanitizer (UBSAN).
-To enable AddressSanitizer (ASAN) when building tests, configure CMake with
the `ENABLE_ASAN` option:
+## Running specific tests
-```sh
-cmake -B build -DENABLE_TESTING=ON -DENABLE_ADDRESS_SANITIZER=ON
-DCMAKE_BUILD_TYPE=Debug
-cmake --build build
-```
-
-This will build Apache Celix and its tests with ASAN enabled, helping to
detect memory errors during test execution.
+- Run tests matching a regex (useful to run a single test case or test binary):
-## Running Tests
+```bash
+# Run tests whose names match "MyTestName"
+ctest --preset conan-debug -R shell --output-on-failure -j1
+```
-After building, you can run all tests using CTest:
+- Run a test binary directly (executable path depends on your build layout):
-```sh
-ctest --output-on-failure --test-dir build
+```bash
+source build/Debug/generators/conanrun.sh
+./build/Debug/bundles/components_ready_check/tests/components_ready_check_test
+source build/Debug/generators/deactivate_conanrun.sh
```
-Or run a test for a specific subdir, e.g.:
+## Build & test using plain CMake (system dependencies)
+
+If you prefer to use your system packages rather than Conan, install the
required dev packages
+(see `documents/building/README.md` for package lists) then configure CMake
with testing enabled.
-```sh
-ctest --output-on-failure --test-dir build/bundles/shell
+Example (configure & build only):
+```bash
+cmake -DENABLE_TESTING=ON -DENABLE_ADDRESS_SANITIZER=ON
-DENABLE_UNDEFINED_SANITIZER=ON -DCMAKE_BUILD_TYPE=Debug -G Ninja -S . -B build
+cmake --build build --parallel
+ctest --test-dir build --output-on-failure
```
-Or run a specific test binary directly from the `build` directory, e.g.:
+- with apt & cmake you can also run only tests in a certain build-tree
subdirectory:
-```sh
-./build/bundles/components_ready_check/tests/components_ready_check_test
+```bash
+ctest --output-on-failure --test-dir build/Debug/bundles/shell
```