Skip to content
Draft
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
149 changes: 32 additions & 117 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,120 +1,35 @@
# [Choice] bionic (18.04), focal (20.04)
ARG VARIANT="jammy"
FROM ubuntu:${VARIANT}

# Restate the variant to use it later on in the llvm and cmake installations
ARG VARIANT

# 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 unzip pkg-config \
openssh-client gpg-agent socat rsync \
make ninja-build git \
python3 python3-pip

# Install conan
RUN python3 -m pip install --upgrade pip setuptools && \
python3 -m pip 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-[7, 8, 9, 10, 11] and clang-[10, 11, 12, 13]
# Earlier versions of clang will require significant modifications to the IWYU section
ARG GCC_VER="11"
# 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="13"
# 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 current cmake/ccmake, from Kitware
ARG CMAKE_URL="https://apt.kitware.com/ubuntu/"
ARG CMAKE_PKG=${VARIANT}
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \
| gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
apt-add-repository -y "deb ${CMAKE_URL} ${CMAKE_PKG} main" && \
apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends cmake cmake-curses-gui

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

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

# Install include-what-you-use
ENV IWYU /home/iwyu
ENV IWYU_BUILD ${IWYU}/build
ENV IWYU_SRC ${IWYU}/include-what-you-use
RUN mkdir -p ${IWYU_BUILD} && \
git clone --branch clang_${LLVM_VER} \
https://github.com/include-what-you-use/include-what-you-use.git \
${IWYU_SRC}
RUN CC=clang-${LLVM_VER} CXX=clang++-${LLVM_VER} cmake -S ${IWYU_SRC} \
-B ${IWYU_BUILD} \
-G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${LLVM_VER} && \
cmake --build ${IWYU_BUILD} -j && \
cmake --install ${IWYU_BUILD}

# Per https://github.com/include-what-you-use/include-what-you-use#how-to-install:
# `You need to copy the Clang include directory to the expected location before
# running (similarly, use include-what-you-use -print-resource-dir to learn
# exactly where IWYU wants the headers).`
RUN mkdir -p $(include-what-you-use -print-resource-dir 2>/dev/null)
RUN ln -s $(readlink -f /usr/lib/clang/${LLVM_VER}/include) \
$(include-what-you-use -print-resource-dir 2>/dev/null)/include

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

# 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++"}
#### Base Image
FROM ubuntu:22.04 as setup-cpp-ubuntu

RUN apt-get update -qq && \
# install nodejs
apt-get install -y --no-install-recommends nodejs npm && \
# install setup-cpp
npm install -g setup-cpp@v0.36.2 && \
# install the compiler and tools
setup-cpp \
--nala true \
--compiler llvm \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true && \
# cleanup
nala autoremove -y && \
nala autopurge -y && \
apt-get clean && \
nala clean --lists && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*

# Include project
#ADD . /workspaces/cpp_starter_project
#WORKDIR /workspaces/cpp_starter_project
ADD . /workspaces/cpp_vcpkg_project
WORKDIR /workspaces/cpp_vcpkg_project

CMD ["/bin/bash"]
ENTRYPOINT ["/bin/bash"]
103 changes: 52 additions & 51 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
// 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: [bionic, focal]. Default: focal
// Update 'GCC_VER' to pick a gcc and g++ version. Options: [7, 8, 9, 10, 11]. Default: 11
// Update 'LLVM_VER' to pick clang version. Options: [10, 11, 12, 13]. Default: 13
// Update 'USE_CLANG' to set clang as the default C and C++ compiler. Options: [1, null]. Default null
// "args": {
// "VARIANT": "focal",
// "GCC_VER": "11",
// "LLVM_VER": "13"
// }
},
"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.
"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"
}
}
// 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: [bionic, focal]. Default: focal
// Update 'GCC_VER' to pick a gcc and g++ version. Options: [7, 8, 9, 10, 11]. Default: 11
// Update 'LLVM_VER' to pick clang version. Options: [10, 11, 12, 13]. Default: 13
// Update 'USE_CLANG' to set clang as the default C and C++ compiler. Options: [1, null]. Default null
// "args": {
// "VARIANT": "focal",
// "GCC_VER": "11",
// "LLVM_VER": "13"
// }
},
"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.
"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"
}
}
13 changes: 12 additions & 1 deletion .devcontainer/.dockerignore → .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Build directories and binary files
build/
install/
out/
cmake-build-*/
conan-cache/
.cache/
coverage.xml

# User specific settings
CMakeUserPresets.json
Expand All @@ -14,7 +18,9 @@ CMakeUserPresets.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.*.swp
*.swp
.*~
*~
_ReSharper*
*.log
Expand All @@ -31,4 +37,9 @@ $RECYCLE.BIN/
.TemporaryItems
ehthumbs.db
Thumbs.db
Dockerfile
compile_commands.json

# docker related
#Dockerfile
toolchain/
vcpkg/
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
# and your own projects needs
matrix:
os:
- ubuntu-22.04
- macos-13
- ubuntu-24.04
- macos-14
- macos-15
- windows-2022
compiler:
# you can specify the version after `-` like "llvm-13.0.0".
Expand All @@ -45,23 +45,24 @@ jobs:
include:
# Inject GCOV variable for gcc
- compiler: gcc
GCOV: gcov
GCOV: gcov-13
# Inject GCOV variable for llvm
- compiler: llvm
GCOV: "llvm-cov gcov"

# Only to test non-multiconfig builds
- os: ubuntu-22.04
compiler: gcc-11
CMAKE_GENERATOR: "Unix Makefiles"
GCOV: gcov-11
- os: ubuntu-24.04
compiler: gcc
CMAKE_GENERATOR: "Ninja"
GCOV: gcov-13

- os: windows-2022
compiler: msvc
CMAKE_GENERATOR: "Visual Studio 17 2022"

- os: macos-14
compiler: appleclang
GCOV: gcov

# To exclude a specific job from the matrix (e.g llvm on macos-14), you can use this syntax.
exclude:
Expand Down Expand Up @@ -93,16 +94,14 @@ jobs:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows' )}}

cmake: "3.28.4"
cmake: "3.28.6"
ninja: true
vcpkg: true
ccache: true
clangtidy: true
task: true

cppcheck: true

gcovr: 7.2
gcovr: 8.3
opencppcoverage: true

- name: Initialize CodeQL
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ CMakeUserPresets.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.*.swp
*.swp
.*~
*~
_ReSharper*
*.log
Expand All @@ -35,4 +37,4 @@ $RECYCLE.BIN/
.TemporaryItems
ehthumbs.db
Thumbs.db
compile_commands.json
compile_commands.json
Loading
Loading