Skip to content

Commit

Permalink
Add devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
kmichaelk committed Oct 13, 2024
1 parent 27dc06d commit 0f508ff
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM mcr.microsoft.com/devcontainers/base:jammy

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install \
gcc g++ \
mpich openmpi-bin libopenmpi-dev libomp-dev \
cppcheck valgrind \
python3-pip \
clangd \
&& apt-get autoremove -y && apt-get clean -y

COPY ./reinstall-cmake.sh /tmp/
RUN chmod +x /tmp/reinstall-cmake.sh \
&& /tmp/reinstall-cmake.sh 3.25.0 \
&& rm -f /tmp/reinstall-cmake.sh

RUN pip install --no-cache-dir xlsxwriter==3.2.0
16 changes: 16 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// https://aka.ms/devcontainer.json
{
"name": "Ubuntu",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.cpptools",
"ms-vscode.cmake-tools"
]
}
}
}
59 changes: 59 additions & 0 deletions .devcontainer/reinstall-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
set -e

CMAKE_VERSION=${1:-"none"}

if [ "${CMAKE_VERSION}" = "none" ]; then
echo "No CMake version specified, skipping CMake reinstallation"
exit 0
fi

# Cleanup temporary directory and associated files when exiting the script.
cleanup() {
EXIT_CODE=$?
set +e
if [[ -n "${TMP_DIR}" ]]; then
echo "Executing cleanup of tmp files"
rm -Rf "${TMP_DIR}"
fi
exit $EXIT_CODE
}
trap cleanup EXIT


echo "Installing CMake..."
apt-get -y purge --auto-remove cmake
mkdir -p /opt/cmake

architecture=$(dpkg --print-architecture)
case "${architecture}" in
arm64)
ARCH=aarch64 ;;
amd64)
ARCH=x86_64 ;;
*)
echo "Unsupported architecture ${architecture}."
exit 1
;;
esac

CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt"
TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX)

echo "${TMP_DIR}"
cd "${TMP_DIR}"

curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O

sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}"
sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license

ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mpich
cmake-build-release*
cmake-build-debug*
.idea/
.vscode/
scripts/variants.csv
scripts/variants.xlsx
venv*
Expand Down
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.cmake-tools",
"eamodio.gitlens",
"matepek.vscode-catch2-test-adapter",
]
}
127 changes: 127 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"C_Cpp.intelliSenseEngine": "disabled",
"[cpp]": {
"editor.formatOnSave": true,
},
"cmake.configureArgs": [
"-D USE_SEQ=ON",
"-D USE_MPI=ON",
"-D USE_OMP=ON",
"-D USE_TBB=ON",
"-D USE_STL=ON",
"-D USE_FUNC_TESTS=ON",
"-D USE_PERF_TESTS=ON",
"-D USE_CPPCHECK=ON"
],
"testMate.cpp.debug.configTemplate": {
"type": "cppvsdbg",
"linux": {
"type": "cppdbg",
"MIMode": "gdb"
},
"darwin": {
"type": "cppdbg",
"MIMode": "lldb"
},
"win32": {
"type": "cppvsdbg"
},
"program": "${exec}",
"args": "${argsArray}",
"cwd": "${cwd}",
"env": "${envObj}",
"environment": "${envObjArray}",
"sourceFileMap": "${sourceFileMapObj}",
},
"testMate.cpp.test.advancedExecutables": [
// rest
{
"pattern": "build/bin/*_tests"
},
// mpi
{
"pattern": "build/bin/mpi_func_tests",
"runTask": {
"before": [
"CMake: build mpi_func_tests",
],
},
},
{
"pattern": "build/bin/mpi_perf_tests",
"runTask": {
"before": [
"CMake: build mpi_perf_tests",
],
},
},
// omp
{
"pattern": "build/bin/omp_func_tests",
"runTask": {
"before": [
"CMake: build omp_func_tests",
],
},
},
{
"pattern": "build/bin/omp_perf_tests",
"runTask": {
"before": [
"CMake: build omp_perf_tests",
],
},
},
// seq
{
"pattern": "build/bin/seq_func_tests",
"runTask": {
"before": [
"CMake: build seq_func_tests",
],
},
},
{
"pattern": "build/bin/seq_perf_tests",
"runTask": {
"before": [
"CMake: build seq_perf_tests",
],
},
},
// stl
{
"pattern": "build/bin/stl_func_tests",
"runTask": {
"before": [
"CMake: build stl_func_tests",
],
},
},
{
"pattern": "build/bin/stl_perf_tests",
"runTask": {
"before": [
"CMake: build stl_perf_tests",
],
},
},
// tbb
{
"pattern": "build/bin/tbb_func_tests",
"runTask": {
"before": [
"CMake: build tbb_func_tests",
],
},
},
{
"pattern": "build/bin/tbb_perf_tests",
"runTask": {
"before": [
"CMake: build tbb_perf_tests",
],
},
}
]
}
125 changes: 125 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cmake",
"label": "CMake: build all",
"command": "build",
"targets": [
"all"
],
"group": "build",
"problemMatcher": []
},

// mpi
{
"type": "cmake",
"label": "CMake: build mpi_func_tests",
"command": "build",
"targets": [
"mpi_func_tests"
],
"group": "build",
"problemMatcher": []
},
{
"type": "cmake",
"label": "CMake: build mpi_perf_tests",
"command": "build",
"targets": [
"mpi_perf_tests"
],
"group": "build",
"problemMatcher": []
},

// omp
{
"type": "cmake",
"label": "CMake: build omp_func_tests",
"command": "build",
"targets": [
"omp_func_tests"
],
"group": "build",
"problemMatcher": []
},
{
"type": "cmake",
"label": "CMake: build omp_perf_tests",
"command": "build",
"targets": [
"omp_perf_tests"
],
"group": "build",
"problemMatcher": []
},

// seq
{
"type": "cmake",
"label": "CMake: build seq_func_tests",
"command": "build",
"targets": [
"seq_func_tests"
],
"group": "build",
"problemMatcher": []
},
{
"type": "cmake",
"label": "CMake: build seq_perf_tests",
"command": "build",
"targets": [
"seq_perf_tests"
],
"group": "build",
"problemMatcher": []
},

// stl
{
"type": "cmake",
"label": "CMake: build stl_func_tests",
"command": "build",
"targets": [
"stl_func_tests"
],
"group": "build",
"problemMatcher": []
},
{
"type": "cmake",
"label": "CMake: build stl_perf_tests",
"command": "build",
"targets": [
"stl_perf_tests"
],
"group": "build",
"problemMatcher": []
},

// tbb
{
"type": "cmake",
"label": "CMake: build tbb_func_tests",
"command": "build",
"targets": [
"tbb_func_tests"
],
"group": "build",
"problemMatcher": []
},
{
"type": "cmake",
"label": "CMake: build tbb_perf_tests",
"command": "build",
"targets": [
"tbb_perf_tests"
],
"group": "build",
"problemMatcher": []
}
]
}

0 comments on commit 0f508ff

Please sign in to comment.