Skip to content

Commit

Permalink
Merge pull request #31 from StephanKa/bugfix/dev-container
Browse files Browse the repository at this point in the history
Fixed Dev Container for Ubuntu Lunar
  • Loading branch information
StephanKa authored Mar 4, 2024
2 parents dbd4e3f + fd4dbe0 commit 276ec16
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 34 deletions.
45 changes: 15 additions & 30 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ 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 && \
Expand All @@ -29,7 +31,7 @@ ENV CONAN_SYSREQUIRES_SUDO 0
ENV CONAN_SYSREQUIRES_MODE enabled

# User-settable versions:
# This Dockerfile should support gcc-[10, 11, 12] and clang-[10, 11, 12, 13, 14, 15]
# 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}
Expand Down Expand Up @@ -60,15 +62,11 @@ RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-t
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/"
# FALLBACK because lunar isn't support yet by kitware
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
# 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 && \
Expand All @@ -81,26 +79,13 @@ RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
doxygen graphviz ccache cppcheck xz-utils

# 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
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 && \
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"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]. Default: 15
// 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",
Expand All @@ -25,7 +25,7 @@
"editor.formatOnSave": true
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"customizations/vscode/extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"twxs.cmake",
Expand Down
4 changes: 4 additions & 0 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 Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ FROM ubuntu:23.04 as cpp-docker-common

ARG DEBIAN_FRONTEND=noninteractive
ARG CLANG_COMPILER_VERSION=15
ARG CMAKE_VERSION=3.26.3
ENV PATH="${PATH}:/cmake-3.26.3-linux-x86_64/bin/:"
ARG CMAKE_VERSION=3.28.3
ENV PATH="${PATH}:/cmake-${CMAKE_VERSION}-linux-x86_64/bin/:"

RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install --fix-missing \
binutils \
Expand Down

0 comments on commit 276ec16

Please sign in to comment.