From 7b36859652fed0cb714d824eae27e9d82df09a92 Mon Sep 17 00:00:00 2001 From: Pepijn Noltes Date: Fri, 6 Feb 2026 17:07:28 +0000 Subject: [PATCH 1/5] gh-819: Simplify devcontainer setup Remove the build script and conan profiles. Change the setup to support Conan --- .devcontainer/Containerfile | 108 ++++---------- .devcontainer/README.md | 56 ++++---- .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 | 37 ++++- .devcontainer/run-devcontainer.sh | 133 ------------------ .devcontainer/setup-project-with-apt.sh | 36 ----- .devcontainer/setup-project-with-conan.sh | 26 ---- .github/workflows/containers.yml | 74 +++------- 11 files changed, 104 insertions(+), 475 deletions(-) delete mode 100755 .devcontainer/build-devcontainer-image.sh delete mode 100755 .devcontainer/build-project-with-conan.sh delete mode 100644 .devcontainer/conan-container-debug-profile delete mode 100644 .devcontainer/conan-container-default-profile delete mode 100755 .devcontainer/run-devcontainer.sh delete mode 100755 .devcontainer/setup-project-with-apt.sh delete mode 100755 .devcontainer/setup-project-with-conan.sh diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile index cc2b2f8ca..21b3f8bfb 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,41 @@ 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 - -# Setup python venv for celixdev and install conan -ENV PATH="${PATH}:/home/celixdev/.local/bin" -RUN pipx install conan + 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 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 +USER ${USERNAME} +WORKDIR /home/${USERNAME} -#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 - -RUN sudo mkdir /run/sshd +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 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 +FROM base as conan-dev -#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 \ +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 - -RUN sudo mkdir /run/sshd + apt-get clean \ diff --git a/.devcontainer/README.md b/.devcontainer/README.md index f521d8c29..597bf71da 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -21,49 +21,51 @@ 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. -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: +## Building -```bash -cd ${CELIX_ROOT} -./.devcontainer/build-devcontainer-image.sh -./.devcontainer/run-devcontainer.sh -ssh -p 2233 celixdev@localhost -``` +Build can be done from the root workspace dir: -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. - -Also ensure the CMake profile from the - conan generated - `CMakeUserPresets.json` is used: Enable the profile in the -Settings -> "Build, Execution, Deployment" -> CMake menu. +```shell +cmake --build build --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 --output-on-failure --test-dir build ``` 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..caa694801 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,12 +4,41 @@ "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_OUT": "build", + "CONAN_OPTS": "--options celix/*:build_all=True --options celix/*:enable_address_sanitizer=True --options celix/*:enable_testing=True --options celix/*:enable_ccache=True --options 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" + "postCreateCommand": "conan install . --build missing --profile ${CONAN_PROFILE} ${CONAN_OPTS} ${CONAN_CONF} --output-folder ${CONAN_OUT} && cmake --preset conan-debug", + "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..6254fec1d 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,31 @@ 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 . --profile 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 && \ + 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/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" - - 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" - + ctest --output-on-failure" build-dev-container-images: runs-on: ubuntu-22.04 timeout-minutes: 120 @@ -98,5 +61,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 . From a8196eea15ae547da4be1bb8654548ba0c25bf3e Mon Sep 17 00:00:00 2001 From: Pepijn Noltes Date: Sun, 15 Feb 2026 16:53:33 +0100 Subject: [PATCH 2/5] gh-819: Update Containerfile, change base of conan-dev --- .devcontainer/Containerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile index 21b3f8bfb..2f145c4a6 100644 --- a/.devcontainer/Containerfile +++ b/.devcontainer/Containerfile @@ -59,10 +59,14 @@ RUN pipx install conan && \ 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 base as conan-dev +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} From 5e0703073f0f7bb4a62e83729606f1971f166936 Mon Sep 17 00:00:00 2001 From: Pepijn Noltes Date: Sun, 15 Feb 2026 22:27:04 +0100 Subject: [PATCH 3/5] gh-819: Add conan cmake_layout and update devcontainer setup --- .devcontainer/README.md | 28 ++++++++++++++++++++++++++-- .devcontainer/devcontainer.json | 3 +-- conanfile.py | 5 ++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 597bf71da..819e5790a 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -53,12 +53,33 @@ CLion 2025.3.1 includes DevContainer support (including Podman), so you can open using the IDE's DevContainer workflow. Once the container is built, enable and select the conan-debug (generated) profile. +When running tests from the CLion, ensure that the correct ctest args are used: +`` + +## 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 build --parallel +cmake --build build/Debug --parallel ``` ## Running tests @@ -67,5 +88,8 @@ Tests can be run using ctest. When building with Conan, run tests from the build directory after configuring/building: ```shell -ctest --output-on-failure --test-dir build +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/devcontainer.json b/.devcontainer/devcontainer.json index caa694801..688b8f511 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,7 +14,6 @@ ], "containerEnv": { "CONAN_PROFILE": "debug", - "CONAN_OUT": "build", "CONAN_OPTS": "--options celix/*:build_all=True --options celix/*:enable_address_sanitizer=True --options celix/*:enable_testing=True --options celix/*:enable_ccache=True --options celix/*:enable_code_coverage=True", "CONAN_CONF": "--conf tools.cmake.cmaketoolchain:generator=Ninja" }, @@ -23,7 +22,7 @@ ], "remoteUser": "celixdev", "containerUser": "celixdev", - "postCreateCommand": "conan install . --build missing --profile ${CONAN_PROFILE} ${CONAN_OPTS} ${CONAN_CONF} --output-folder ${CONAN_OUT} && cmake --preset conan-debug", + "postCreateCommand": "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": {} diff --git a/conanfile.py b/conanfile.py index f5c5c6ecd..4941441ca 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 @@ -374,6 +374,9 @@ def requirements(self): self.requires("mosquitto/[>=2.0.3 <3.0.0]") self.validate() + def layout(self): + cmake_layout(self) + def generate(self): tc = CMakeToolchain(self) for opt in self._celix_defaults.keys(): From 4be63b49d233f2f9833c50a4d55c039e5760ef9e Mon Sep 17 00:00:00 2001 From: Pepijn Noltes Date: Mon, 16 Feb 2026 23:04:07 +0100 Subject: [PATCH 4/5] gh-819: Update devcontainer readme for test instructions --- .devcontainer/README.md | 17 +++++++++++++++-- .devcontainer/devcontainer.json | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 819e5790a..510fbfa8a 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -53,8 +53,21 @@ CLion 2025.3.1 includes DevContainer support (including Podman), so you can open using the IDE's DevContainer workflow. Once the container is built, enable and select the conan-debug (generated) profile. -When running tests from the CLion, ensure that the correct ctest args are used: -`` +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 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 688b8f511..ed5270a1d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -15,14 +15,14 @@ "containerEnv": { "CONAN_PROFILE": "debug", "CONAN_OPTS": "--options celix/*:build_all=True --options celix/*:enable_address_sanitizer=True --options celix/*:enable_testing=True --options celix/*:enable_ccache=True --options celix/*:enable_code_coverage=True", - "CONAN_CONF": "--conf tools.cmake.cmaketoolchain:generator=Ninja" + "CONAN_CONF": "--conf tools.cmake.cmaketoolchain:generator=Ninja", }, "securityOpt": [ "label=disable" ], "remoteUser": "celixdev", "containerUser": "celixdev", - "postCreateCommand": "conan install . --build missing --profile ${CONAN_PROFILE} ${CONAN_OPTS} ${CONAN_CONF}", + "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": {} From 2dea67600f69d53a7a39835d4bfefbb604b626b3 Mon Sep 17 00:00:00 2001 From: Pepijn Noltes Date: Mon, 16 Feb 2026 23:04:29 +0100 Subject: [PATCH 5/5] gh-819: Update CI for conan cmake_layout usage --- .github/workflows/containers.yml | 7 +++---- .github/workflows/coverage.yml | 4 ++-- .github/workflows/fuzzing.yml | 12 ++++++------ .github/workflows/macos.yml | 8 ++------ .github/workflows/ubuntu.yml | 11 +++++------ 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 6254fec1d..a79d28bea 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -42,16 +42,15 @@ jobs: conan build . --profile 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" + --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-conan-build:latest /bin/bash -c \ - "cd /home/celixdev/workspace/build && \ + "cd /home/celixdev/workspace && \ source conanrun.sh && \ - ctest --output-on-failure" + ctest --preset conan-release --output-on-failure -j1" build-dev-container-images: runs-on: ubuntu-22.04 timeout-minutes: 120 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4ad7a2339..60126ac47 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -63,10 +63,10 @@ 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 + cd build/Release source conanrun.sh make coverage source deactivate_conanrun.sh diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index 242b47567..5aeeb8492 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -32,11 +32,11 @@ jobs: ${{ runner.os }}-conan- - name: Setup Conan Profile run: | - conan profile detect + 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" + run: conan install . --build=missing -o "celix/*:build_utils=True" -o "celix/*:enable_fuzzing=True" -o "celix/*:enable_address_sanitizer=True" -o "celix/*:enable_undefined_sanitizer=True" - 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" + run: conan 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" - name: Set fuzzer run time id: set-runtime run: | @@ -48,12 +48,12 @@ jobs: - 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 + ./build/Release/libs/utils/fuzzing/celix_properties_fuzzer -max_total_time=$FUZZ_TIME ./build/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 + ./build/Release/libs/utils/fuzzing/celix_version_fuzzer -max_total_time=$FUZZ_TIME ./build/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 + ./build/Release/libs/utils/fuzzing/celix_filter_fuzzer -max_total_time=$FUZZ_TIME ./build/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 0e60cf73c..60e990268 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