Skip to content

Commit 276ec16

Browse files
authored
Merge pull request #31 from StephanKa/bugfix/dev-container
Fixed Dev Container for Ubuntu Lunar
2 parents dbd4e3f + fd4dbe0 commit 276ec16

4 files changed

Lines changed: 23 additions & 34 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ FROM ubuntu:${VARIANT}
44

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

810
# Install necessary packages available from standard repos
911
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
@@ -29,7 +31,7 @@ ENV CONAN_SYSREQUIRES_SUDO 0
2931
ENV CONAN_SYSREQUIRES_MODE enabled
3032

3133
# User-settable versions:
32-
# This Dockerfile should support gcc-[10, 11, 12] and clang-[10, 11, 12, 13, 14, 15]
34+
# This Dockerfile should support gcc-[10, 11, 12, 13] and clang-[10, 11, 12, 13, 14, 15, 16, 17]
3335
# Earlier versions of clang will require significant modifications to the IWYU section
3436
ARG GCC_VER="12"
3537
# Add gcc-${GCC_VER}
@@ -60,15 +62,11 @@ RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-t
6062
RUN update-alternatives --install /usr/bin/clang clang $(which clang-${LLVM_VER}) 100
6163
RUN update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-${LLVM_VER}) 100
6264

63-
# Add current cmake/ccmake, from Kitware
64-
ARG CMAKE_URL="https://apt.kitware.com/ubuntu/"
65-
# FALLBACK because lunar isn't support yet by kitware
66-
ARG CMAKE_PKG=${VARIANT}
67-
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \
68-
| gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
69-
apt-add-repository -y "deb ${CMAKE_URL} ${CMAKE_PKG} main" && \
70-
apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
71-
apt-get install -y --no-install-recommends cmake cmake-curses-gui
65+
# Add install cmake/ccmake
66+
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh \
67+
&& chmod +x cmake-${CMAKE_VERSION}-linux-x86_64.sh \
68+
&& ./cmake-${CMAKE_VERSION}-linux-x86_64.sh --include-subdir --skip-license \
69+
&& rm cmake-${CMAKE_VERSION}-linux-x86_64.sh
7270

7371
# Install editors
7472
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
@@ -81,26 +79,13 @@ RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
8179
doxygen graphviz ccache cppcheck xz-utils
8280

8381
# Install include-what-you-use
84-
ENV IWYU /home/iwyu
85-
ENV IWYU_BUILD ${IWYU}/build
86-
ENV IWYU_SRC ${IWYU}/include-what-you-use
87-
RUN mkdir -p ${IWYU_BUILD} && \
88-
git clone --branch clang_${LLVM_VER} \
89-
https://github.com/include-what-you-use/include-what-you-use.git \
90-
${IWYU_SRC}
91-
RUN CC=clang-${LLVM_VER} CXX=clang++-${LLVM_VER} cmake -S ${IWYU_SRC} \
92-
-B ${IWYU_BUILD} \
93-
-G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${LLVM_VER} && \
94-
cmake --build ${IWYU_BUILD} -j && \
95-
cmake --install ${IWYU_BUILD}
96-
97-
# Per https://github.com/include-what-you-use/include-what-you-use#how-to-install:
98-
# `You need to copy the Clang include directory to the expected location before
99-
# running (similarly, use include-what-you-use -print-resource-dir to learn
100-
# exactly where IWYU wants the headers).`
101-
RUN mkdir -p $(include-what-you-use -print-resource-dir 2>/dev/null)
102-
RUN ln -s $(readlink -f /usr/lib/clang/${LLVM_VER}/include) \
103-
$(include-what-you-use -print-resource-dir 2>/dev/null)/include
82+
RUN mkdir iwyu && cd iwyu \
83+
&& git clone --branch clang_${LLVM_VER} https://github.com/include-what-you-use/include-what-you-use.git \
84+
&& mkdir build && cd build \
85+
&& cmake -G "Ninja" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${LLVM_VER} ../include-what-you-use \
86+
&& ninja install \
87+
&& cd ../.. \
88+
&& rm -rf iwyu
10489

10590
## Cleanup cached apt data we don't need anymore
10691
RUN apt-get autoremove -y && apt-get clean && \

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dockerfile": "Dockerfile",
77
// Update 'VARIANT' to pick an Ubuntu OS version. Options: [focal, jammy, lunar]. Default: lunar
88
// Update 'GCC_VER' to pick a gcc and g++ version. Options: [10, 11, 12, 13]. Default: 12
9-
// Update 'LLVM_VER' to pick clang version. Options: [10, 11, 12, 13, 14, 15]. Default: 15
9+
// Update 'LLVM_VER' to pick clang version. Options: [10, 11, 12, 13, 14, 15, 16, 17]. Default: 17
1010
// Update 'USE_CLANG' to set clang as the default C and C++ compiler. Options: [1, null]. Default null
1111
// "args": {
1212
// "VARIANT": "focal",
@@ -25,7 +25,7 @@
2525
"editor.formatOnSave": true
2626
},
2727
// Add the IDs of extensions you want installed when the container is created.
28-
"extensions": [
28+
"customizations/vscode/extensions": [
2929
"ms-vscode.cpptools",
3030
"ms-vscode.cmake-tools",
3131
"twxs.cmake",

.github/workflows/build_cmake.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ jobs:
2626
shell: bash
2727
run: cd docker && ./build-dev-image.sh
2828

29+
- name: Build .devcontainer docker image
30+
shell: bash
31+
run: cd .devcontainer && DOCKER_BUILDKIT=1 docker build -t devcontainer:latest .
32+
2933
linux:
3034
name: ${{ matrix.os }}, ${{ matrix.compiler.name }}, C++${{ matrix.cxx }}, ${{ matrix.buildtype }}
3135
runs-on: ${{ matrix.os }}

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ FROM ubuntu:23.04 as cpp-docker-common
66

77
ARG DEBIAN_FRONTEND=noninteractive
88
ARG CLANG_COMPILER_VERSION=15
9-
ARG CMAKE_VERSION=3.26.3
10-
ENV PATH="${PATH}:/cmake-3.26.3-linux-x86_64/bin/:"
9+
ARG CMAKE_VERSION=3.28.3
10+
ENV PATH="${PATH}:/cmake-${CMAKE_VERSION}-linux-x86_64/bin/:"
1111

1212
RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install --fix-missing \
1313
binutils \

0 commit comments

Comments
 (0)