Repository navigation
Add dedicated C++ devcontainer #1606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bferanmi806-sketch
wants to merge
1
commit into
PowerGridModel:main
Choose a base branch
from
bferanmi806-sketch:feature/1272-cpp-devcontainer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+211
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
| # | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| # Dedicated C++ development container for power-grid-model. | ||
| # Matches the Linux CI toolchain (Ubuntu 26.04, GCC/G++ 16, Clang 22) and the | ||
| # C++ dependencies listed in docs/advanced_documentation/build-guide.md. | ||
| # clang-tidy remains on version 18 on purpose: CI does the same (see PR #1631). | ||
| FROM mcr.microsoft.com/devcontainers/base:resolute | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| build-essential \ | ||
| gcc-16 g++-16 \ | ||
| clang-22 lld-22 libclang-rt-22-dev clang-tidy-18 \ | ||
| cmake ninja-build gdb \ | ||
| libboost-dev libeigen3-dev nlohmann-json3-dev libmsgpack-cxx-dev doctest-dev \ | ||
| gcovr lcov pkg-config git curl ca-certificates \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # The CMake presets resolve `gcc`/`g++`/`clang`/`clang++` via PATH | ||
| # (same approach as CI, which symlinks the versioned binaries). | ||
| RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-16 100 \ | ||
| && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-16 100 \ | ||
| && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-22 100 \ | ||
| && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-22 100 \ | ||
| && update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 100 | ||
|
|
||
| # uv provides the Python runtime for the repository's uv-managed tooling. | ||
| # pre-commit, REUSE and clang-format are installed from uv.lock by the | ||
| # postCreateCommand, so they stay in sync with CI instead of being duplicated | ||
| # as global tools here. | ||
| ENV UV_INSTALL_DIR=/usr/local/bin | ||
| RUN curl -LsSf https://astral.sh/uv/install.sh | sh | ||
|
|
||
| ENV CC=gcc CXX=g++ | ||
| ENV DEBIAN_FRONTEND=dialog | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| { | ||
| // Dedicated C++ development container (issue #1272). | ||
| // The default Python container in .devcontainer/devcontainer.json is unchanged; | ||
| // VS Code offers both configurations when reopening in a container. | ||
| "name": "power-grid-model (C++)", | ||
| "build": { | ||
| "dockerfile": "Dockerfile", | ||
| "context": "." | ||
| }, | ||
|
|
||
| "workspaceFolder": "/power-grid-model", | ||
| "workspaceMount": "source=${localWorkspaceFolder},target=/power-grid-model,type=bind", | ||
|
|
||
| // Keep CMake build trees inside the container. Sharing cpp_build/ with the | ||
| // host leaves absolute paths from the host in CMakeCache.txt, which makes | ||
| // presets such as clang-debug fail with "CMakeCache.txt directory ... is | ||
| // different than the directory ... where CMakeCache.txt was created". | ||
| // ${devcontainerId} keeps the volume per checkout, so parallel worktrees do | ||
| // not share a cache either. | ||
| "mounts": ["type=volume,source=power-grid-model-cpp-build-${devcontainerId},target=/power-grid-model/cpp_build"], | ||
|
|
||
| "remoteUser": "vscode", | ||
|
|
||
| "remoteEnv": { | ||
| "CC": "gcc", | ||
| "CXX": "g++" | ||
| }, | ||
|
|
||
| "postCreateCommand": "sudo chown -R vscode:vscode cpp_build && uv sync --frozen --group lint --group test && uv run --frozen pre-commit install && gcc --version && g++ --version && clang --version && clang-tidy --version && uv run --frozen clang-format --version && cmake --version && ninja --version && cmake --list-presets", | ||
|
|
||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": [ | ||
| "ms-vscode.cpptools", | ||
| "ms-vscode.cmake-tools", | ||
| "matepek.vscode-catch2-test-adapter", | ||
| "jeff-hykin.better-cpp-syntax", | ||
| "tamasfe.even-better-toml", | ||
| "xaver.clang-format" | ||
| ], | ||
| "settings": { | ||
| // NOTE: there is no supported setting that pre-selects a CMake configure | ||
| // preset. After the container is created, run `CMake: Select Configure | ||
| // Preset` in VS Code and choose `gcc-debug` (`clang-debug` works too). | ||
| "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", | ||
| // Use the clang-format version pinned in uv.lock (the same one CI uses | ||
| // through `uv run --frozen clang-format`) instead of a system package. | ||
| "clang-format.executable": "/power-grid-model/.venv/bin/clang-format", | ||
| "clang-format.style": "file", | ||
| "[c]": { | ||
| "editor.defaultFormatter": "xaver.clang-format" | ||
| }, | ||
| "[cpp]": { | ||
| "editor.defaultFormatter": "xaver.clang-format" | ||
| }, | ||
| "editor.formatOnSave": true | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
|
|
||
| SPDX-License-Identifier: MPL-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,3 +16,4 @@ | |
| *.h text eol=lf | ||
| *.cpp text eol=lf | ||
| *.hpp text eol=lf | ||
| Dockerfile text eol=lf | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.