Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .devcontainer/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 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.

FROM docker.io/library/ubuntu:24.04@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30 as base

# Install dependencies
RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
build-essential \
ccache \
cmake \
gcc \
g++ \
make \
zip \
ninja-build \
clang-tidy \
lcov \
sudo \
python3 \
pipx && \
apt-get clean

# Build image using conan & cmake
FROM base as conan-build

ARG USERNAME=celixdev
ARG USER_UID=1000
ARG USER_GID=1000

RUN userdel -r ubuntu && \
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

USER ${USERNAME}
WORKDIR /home/${USERNAME}

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

FROM conan-build as conan-dev

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 && \
apt-get clean

USER ${USERNAME}
WORKDIR /home/${USERNAME}
108 changes: 108 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<!--
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.
-->

# Apache Celix Development Container

## Introduction

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 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 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.
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 and SSH agent forwarding
are available in the container.

## CLion Usage

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$`

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`

## 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}
```

Note: `CONAN_PROFILE`, `CONAN_OPTS` and `CONAN_CONF` are environments variables in the dev container.

## 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, run tests from the build directory after configuring/building:

```shell
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.
43 changes: 43 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "Apache Celix Dev Container",
"build": {
"dockerfile": "Containerfile",
"target": "conan-dev"
},
"runArgs": [
"--userns=keep-id"
],
"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 -o *:shared=True",
"CONAN_CONF": "--conf tools.cmake.cmaketoolchain:generator=Ninja"
},
"securityOpt": [
"label=disable"
],
"remoteUser": "celixdev",
"containerUser": "celixdev",
"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"
}
}
}
20 changes: 13 additions & 7 deletions .github/workflows/conan_create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,36 @@ jobs:
CC: ${{ matrix.compiler[0] }}
CXX: ${{ matrix.compiler[1] }}
run: |
conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:build_all=True -o celix/*:enable_ccache=True -pr:b default -pr:h default -s:h build_type=${{ matrix.type }} -tf examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True
conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:build_all=True -o celix/*:enable_ccache=True -o celix/*:enable_testing_on_ci=True -pr:b default -pr:h default -s:h build_type=${{ matrix.type }} -tf examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True
- name: Dependency Deduction Test
env:
CC: ${{ matrix.compiler[0] }}
CXX: ${{ matrix.compiler[1] }}
run: |
conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ && !/build_all/ { if(output) print $1} /^options/ {output=1} /^options_definitions/ {output=0}' | while read option; do conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:${option}=True -pr:b default -pr:h default -s:h build_type=${{ matrix.type }} -of ${option}_dir -o celix/*:celix_cxx17=True -o celix/*:enable_ccache=True -o celix/*:celix_install_deprecated_api=True || exit 1; done
conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ && !/build_all/ { if(output) print $1} /^options/ {output=1} /^options_definitions/ {output=0}' | while read option; do conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:${option}=True -pr:b default -pr:h default -s:h build_type=${{ matrix.type }} -of ${option}_dir -o celix/*:celix_cxx17=True -o celix/*:enable_ccache=True -o celix/*:enable_testing_on_ci=True -o celix/*:celix_install_deprecated_api=True || exit 1; done
- name: Remove Celix
run: |
conan remove -c celix/*
conan remove -c celix/*

mac-build:
runs-on: macOS-11
runs-on: macOS-15
timeout-minutes: 120
steps:
- name: Checkout source code
uses: actions/checkout@v3.3.0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install build dependencies
run: |
brew install python ninja
brew install ninja
pip3 install -U conan
- name: Setup Conan Profile
run: |
conan profile detect -f
echo "[tool_requires]" >> `conan profile path default`
echo "cmake/3.26.4" >> `conan profile path default`
- name: Conan Cache
id: cache-conan
uses: actions/cache@v3
Expand All @@ -110,10 +116,10 @@ jobs:
${{ runner.os }}-ccache-Release-
- name: Create Celix
run: |
conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:build_all=True -o celix/*:enable_ccache=True -pr:b default -pr:h default -s:b build_type=Release -s:h build_type=Release -tf examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True
conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:build_all=True -o celix/*:enable_ccache=True -o celix/*:enable_testing_on_ci=True -pr:b default -pr:h default -s:b build_type=Release -s:h build_type=Release -tf examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True
- name: Dependency Deduction Test
run: |
conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ && !/build_all/ && !/build_rsa_remote_service_admin_shm_v2/ && !/build_rsa_discovery_zeroconf/ && !/build_shell_bonjour/ { if(output) print $1} /^options/ {output=1} /^options_definitions/ {output=0}' | while read option; do conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:${option}=True -pr:b default -pr:h default -s:b build_type=Release -s:h build_type=Release -of ${option}_dir -o celix/*:celix_cxx17=True -o celix/*:enable_ccache=True -o celix/*:celix_install_deprecated_api=True || exit 1; done
conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ && !/build_all/ && !/build_rsa_remote_service_admin_shm_v2/ && !/build_rsa_discovery_zeroconf/ && !/build_shell_bonjour/ { if(output) print $1} /^options/ {output=1} /^options_definitions/ {output=0}' | while read option; do conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:${option}=True -pr:b default -pr:h default -s:b build_type=Release -s:h build_type=Release -of ${option}_dir -o celix/*:celix_cxx17=True -o celix/*:enable_ccache=True -o celix/*:enable_testing_on_ci=True -o celix/*:celix_install_deprecated_api=True || exit 1; done
- name: Remove Celix
run: |
conan remove -c celix/*
63 changes: 63 additions & 0 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Celix Containers

on:
push:
pull_request:

jobs:
container-conan-build-ubuntu:
runs-on: ubuntu-24.04
timeout-minutes: 120
steps:
- name: Checkout source code
uses: actions/checkout@v3.3.0
- name: Cache Conan
uses: actions/cache@v3
with:
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
uses: actions/cache@v3
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 container image
run: |
cd .devcontainer && \
docker build --tag apache/celix-2.4-conan-build:latest --target conan-build --file Containerfile .
- name: Build Celix
run: |
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:/home/celixdev/.ccache \
-v $(pwd):/home/celixdev/workspace apache/celix-2.4-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 \
--options celix/*:enable_testing_on_ci=True \
--conf:build tools.cmake.cmaketoolchain:generator=Ninja"
- name: Test Celix
run: |
docker run --rm \
-v ~/.conan2-container-package-cache:/home/celixdev/.conan2/p \
-v $(pwd):/home/celixdev/workspace apache/celix-2.4-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-24.04
timeout-minutes: 120
steps:
- name: Checkout source code
uses: actions/checkout@v3.3.0
- name: Build dev container images
run: |
cd .devcontainer && \
docker build --tag apache/celix-2.4-conan-dev:latest --target conan-dev --file Containerfile .
Loading
Loading