Skip to content

Commit

Permalink
Merge branch 'main' into feature/added-mingw-configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanKa authored Mar 4, 2024
2 parents b3783e2 + 8cf8a67 commit 97f7bee
Show file tree
Hide file tree
Showing 36 changed files with 861 additions and 353 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Build directories and binary files
build/
out/
cmake-build-*/

# User spesific settings
CMakeUserPresets.json
112 changes: 112 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# [Choice] focal (20.04), jammy (22.04), lunar (23.04)
ARG VARIANT="lunar"
FROM ubuntu:${VARIANT}

# Restate the variant to use it later on in the llvm and cmake installations
ARG VARIANT
ARG CMAKE_VERSION=3.28.3
ENV PATH="${PATH}:/cmake-${CMAKE_VERSION}-linux-x86_64/bin/:"

# Install necessary packages available from standard repos
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
software-properties-common wget apt-utils file zip \
openssh-client gpg-agent socat rsync \
make ninja-build git pipx \
python3 python3-pip python3-venv python3-setuptools

# Ensure pipx is in PATH
ENV PATH="${PATH}:/root/.local/bin"

# Install conan
RUN pipx install conan && conan --version

# By default, anything you run in Docker is done as superuser.
# Conan runs some install commands as superuser, and will prepend `sudo` to
# these commands, unless `CONAN_SYSREQUIRES_SUDO=0` is in your env variables.
ENV CONAN_SYSREQUIRES_SUDO 0
# Some packages request that Conan use the system package manager to install
# a few dependencies. This flag allows Conan to proceed with these installations;
# leaving this flag undefined can cause some installation failures.
ENV CONAN_SYSREQUIRES_MODE enabled

# User-settable versions:
# This Dockerfile should support gcc-[10, 11, 12, 13] and clang-[10, 11, 12, 13, 14, 15, 16, 17]
# Earlier versions of clang will require significant modifications to the IWYU section
ARG GCC_VER="12"
# Add gcc-${GCC_VER}
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
gcc-${GCC_VER} g++-${GCC_VER} gdb

# Set gcc-${GCC_VER} as default gcc
RUN update-alternatives --install /usr/bin/gcc gcc $(which gcc-${GCC_VER}) 100
RUN update-alternatives --install /usr/bin/g++ g++ $(which g++-${GCC_VER}) 100

ARG LLVM_VER="15"
# Add clang-${LLVM_VER}
ARG LLVM_URL="http://apt.llvm.org/${VARIANT}/"
ARG LLVM_PKG="llvm-toolchain-${VARIANT}-${LLVM_VER}"
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 2>/dev/null && \
add-apt-repository -y "deb ${LLVM_URL} ${LLVM_PKG} main" && \
apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
clang-${LLVM_VER} lldb-${LLVM_VER} lld-${LLVM_VER} clangd-${LLVM_VER} \
llvm-${LLVM_VER}-dev libclang-${LLVM_VER}-dev clang-tidy-${LLVM_VER}

# Set the default clang-tidy, so CMake can find it
RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-${LLVM_VER}) 1

# Set clang-${LLVM_VER} as default clang
RUN update-alternatives --install /usr/bin/clang clang $(which clang-${LLVM_VER}) 100
RUN update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-${LLVM_VER}) 100

# Add install cmake/ccmake
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh \
&& chmod +x cmake-${CMAKE_VERSION}-linux-x86_64.sh \
&& ./cmake-${CMAKE_VERSION}-linux-x86_64.sh --include-subdir --skip-license \
&& rm cmake-${CMAKE_VERSION}-linux-x86_64.sh

# Install editors
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
neovim emacs nano

# Install optional dependecies
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
doxygen graphviz ccache cppcheck xz-utils

# Install include-what-you-use
RUN mkdir iwyu && cd iwyu \
&& git clone --branch clang_${LLVM_VER} https://github.com/include-what-you-use/include-what-you-use.git \
&& mkdir build && cd build \
&& cmake -G "Ninja" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${LLVM_VER} ../include-what-you-use \
&& ninja install \
&& cd ../.. \
&& rm -rf iwyu

## Cleanup cached apt data we don't need anymore
RUN apt-get autoremove -y && apt-get clean && \
rm -rf /var/lib/apt/lists/*

## Install ARM GCC toolchain
RUN wget -O archive.tar.xz "https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz?rev=7bd049b7a3034e64885fa1a71c12f91d&hash=732D909FA8F68C0E1D0D17D08E057619" && \
echo 84be93d0f9e96a15addd490b6e237f588c641c8afdf90e7610a628007fc96867 archive.tar.xz > /tmp/archive.sha256 && sha256sum -c /tmp/archive.sha256 && rm /tmp/archive.sha256 && \
tar xf archive.tar.xz -C /opt

# Allow the user to set compiler defaults
ARG USE_CLANG
# if --build-arg USE_CLANG=1, set CC to 'clang' or set to null otherwise.
ENV CC=${USE_CLANG:+"clang"}
ENV CXX=${USE_CLANG:+"clang++"}
# if CC is null, set it to 'gcc' (or leave as is otherwise).
ENV CC=${CC:-"gcc"}
ENV CXX=${CXX:-"g++"}

# Include project
#ADD . /workspaces/cpp_project
#WORKDIR /workspaces/cpp_project

CMD ["/bin/bash"]
52 changes: 52 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/cpp
{
"name": "C++",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu OS version. Options: [focal, jammy, lunar]. Default: lunar
// Update 'GCC_VER' to pick a gcc and g++ version. Options: [10, 11, 12, 13]. Default: 12
// Update 'LLVM_VER' to pick clang version. Options: [10, 11, 12, 13, 14, 15, 16, 17]. Default: 17
// Update 'USE_CLANG' to set clang as the default C and C++ compiler. Options: [1, null]. Default null
// "args": {
// "VARIANT": "focal",
// "GCC_VER": "12",
// "LLVM_VER": "15"
// }
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"cmake.configureOnOpen": true,
"editor.formatOnSave": true
},
// Add the IDs of extensions you want installed when the container is created.
"customizations/vscode/extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"twxs.cmake",
"ms-vscode.cpptools-themes",
"cschlosser.doxdocgen",
"eamodio.gitlens",
"ms-python.python",
"ms-python.vscode-pylance",
"mutantdino.resourcemonitor"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
//"postCreateCommand": "uname -a",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
//"remoteUser": "vscode",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=delegated",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"features": {
"git": "latest",
"git-lfs": "latest",
"powershell": "latest"
}
}
129 changes: 117 additions & 12 deletions .github/workflows/build_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
shell: bash
run: cd docker && ./build-dev-image.sh

- name: Build .devcontainer docker image
shell: bash
run: cd .devcontainer && DOCKER_BUILDKIT=1 docker build -t devcontainer:latest .

linux:
name: ${{ matrix.os }}, ${{ matrix.compiler.name }}, C++${{ matrix.cxx }}, ${{ matrix.buildtype }}
runs-on: ${{ matrix.os }}
Expand All @@ -37,9 +41,6 @@ jobs:
compiler: [ {name: 'GCC 10', preset: gcc-10, pkgs: 'gcc-10 g++-10 lib32gcc-10-dev gcc-multilib'},
{name: 'GCC 11', preset: gcc-11, pkgs: 'gcc-11 g++-11 lib32gcc-11-dev gcc-multilib'},
{name: 'GCC 12', preset: gcc-12, pkgs: 'gcc-12 g++-12 lib32gcc-12-dev gcc-multilib'},
{name: 'Clang 12', preset: clang-12, pkgs: 'clang-12 llvm-12'},
{name: 'Clang 13', preset: clang-13, pkgs: 'clang-13 llvm-13'},
{name: 'Clang 14', preset: clang-14, pkgs: 'clang-14 llvm-14'},
{name: 'Clang 15', preset: clang-15, pkgs: 'clang-15 llvm-15'}
]
cxx: [17, 20]
Expand All @@ -60,7 +61,61 @@ jobs:
- name: Install conan
shell: bash
run: |
python3 -m pip install --upgrade pip setuptools conan==1.59
python3 -m pip install --upgrade pip setuptools conan
source ~/.profile
- name: Install dependencies
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo apt update
sudo apt install ninja-build ${{ matrix.compiler.pkgs }}
shell: bash

- name: Configure via CMake
shell: bash
run: cmake --preset unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }} -DCXX_STANDARD=${{ matrix.cxx }}

- name: Build
shell: bash
run: cmake --build --preset build-unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }}

- name: Test
shell: bash
run: ctest --preset test-unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }}

# because of an bug in github actions: https://github.com/actions/runner-images/issues/8659
# we use clang 12, clang 13, clang 14 only in C++17 mode
linux-clang-smaller-15:
name: ${{ matrix.os }}, ${{ matrix.compiler.name }}, C++${{ matrix.cxx }}, ${{ matrix.buildtype }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix entry fails.
matrix:
os: [ubuntu-22.04]
buildtype: [debug]
compiler: [ {name: 'Clang 12', preset: clang-12, pkgs: 'clang-12 llvm-12'},
{name: 'Clang 13', preset: clang-13, pkgs: 'clang-13 llvm-13'},
{name: 'Clang 14', preset: clang-14, pkgs: 'clang-14 llvm-14'}
]
cxx: [17]

steps:
- uses: actions/checkout@v3

- name: Cache
uses: actions/cache@v3
env:
cache-name: cache-conan-modules
with:
path: |
${{ env.CONAN_USER_HOME }}
~/.cache/pip
key: ${{ runner.os }}-${{ env.BUILD_TYPE }}-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('cmake/Conan.cmake') }}

- name: Install conan
shell: bash
run: |
python3 -m pip install --upgrade pip setuptools conan
source ~/.profile
- name: Install dependencies
Expand Down Expand Up @@ -108,7 +163,7 @@ jobs:
- name: Install conan
shell: bash
run: |
python3 -m pip install --upgrade pip setuptools conan==1.59
python3 -m pip install --upgrade pip setuptools conan
source ~/.profile
- name: Install dependencies
Expand Down Expand Up @@ -164,7 +219,7 @@ jobs:
- name: Install conan
shell: bash
run: |
python3 -m pip install --upgrade pip setuptools conan==1.59
python3 -m pip install --upgrade pip setuptools conan
source ~/.profile
- name: Install dependencies
Expand Down Expand Up @@ -196,11 +251,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
buildtype: [debug]
compiler: [ {name: 'Clang 12', preset: clang-12, pkgs: 'clang-12 llvm-12'},
{name: 'Clang 13', preset: clang-13, pkgs: 'clang-13 llvm-13'},
{name: 'Clang 14', preset: clang-14, pkgs: 'clang-14 llvm-14'},
{name: 'Clang 15', preset: clang-15, pkgs: 'clang-15 llvm-15'}
]
compiler: [ {name: 'Clang 15', preset: clang-15, pkgs: 'clang-15 llvm-15'} ]

steps:
- uses: actions/checkout@v3
Expand All @@ -218,7 +269,7 @@ jobs:
- name: Install conan
shell: bash
run: |
python3 -m pip install --upgrade pip setuptools conan==1.59
python3 -m pip install --upgrade pip setuptools conan
source ~/.profile
- name: Install dependencies
Expand Down Expand Up @@ -271,3 +322,57 @@ jobs:

- name: Test
run: ctest --preset test-win32-gcc-x64-mingw-${{ matrix.buildtype }}

linux-qt:
name: ${{ matrix.os }}, QT ${{ matrix.compiler.name }}, C++${{ matrix.cxx }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix entry fails.
matrix:
os: [ubuntu-22.04]
compiler: [ {name: 'Clang 15', preset: clang-15, pkgs: 'clang-15 llvm-15'} ]
cxx: [20]

steps:
- uses: actions/checkout@v3

- name: Cache
uses: actions/cache@v3
env:
cache-name: cache-conan-modules
with:
path: |
${{ env.CONAN_USER_HOME }}
~/.cache/pip
key: ${{ runner.os }}-${{ env.BUILD_TYPE }}-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('cmake/Conan.cmake') }}

- name: Install conan
shell: bash
run: |
python3 -m pip install --upgrade pip setuptools conan
source ~/.profile
- name: Install dependencies
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo apt update
sudo apt install ninja-build ${{ matrix.compiler.pkgs }} libx11-xcb-dev libfontenc-dev libice-dev \
libsm-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev libxi-dev \
libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev \
libxss-dev libxt-dev libxtst-dev libxv-dev libxxf86vm-dev libxcb-render0-dev libxcb-render-util0-dev \
libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev \
libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-dri3-dev uuid-dev libxcb-cursor-dev \
libxcb-util-dev libxcb-util0-dev libx11-xcb1 libx11-dev libgl-dev libgl1-mesa-dev
shell: bash

- name: Configure via CMake
shell: bash
run: cmake --preset ${{ matrix.compiler.preset }}-qt -DCXX_STANDARD=${{ matrix.cxx }}

- name: Build
shell: bash
run: cmake --build --preset build-${{ matrix.compiler.preset }}-qt

- name: Test
shell: bash
run: ctest --preset test-${{ matrix.compiler.preset }}-qt
Loading

0 comments on commit 97f7bee

Please sign in to comment.