Skip to content

Commit

Permalink
add codespaces-configuration (#87)
Browse files Browse the repository at this point in the history
* Create devcontainer.json

Signed-off-by: ptahmose <jbohl@h-quer.de>

* Update devcontainer.json

Signed-off-by: ptahmose <jbohl@h-quer.de>

* configure codespaces

* Update devcontainer.json

Signed-off-by: ptahmose <jbohl@h-quer.de>

* test

* Update Dockerfile

Signed-off-by: ptahmose <jbohl@h-quer.de>

* Update devcontainer.json

Signed-off-by: ptahmose <jbohl@h-quer.de>

* test

* undo changes

* remove launch.json

* cosmetic

* linter

* linter

* cosmetic

* reuse

* linter

* add some documentation

* use "external eigen3"

---------

Signed-off-by: ptahmose <jbohl@h-quer.de>
  • Loading branch information
ptahmose committed Dec 11, 2023
1 parent 9affb0e commit 2539ce5
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM mcr.microsoft.com/devcontainers/cpp:1-debian-12

ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"

# Optionally install the cmake for vcpkg
COPY ./reinstall-cmake.sh /tmp/

RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh

# [Optional] Uncomment this section to install additional vcpkg ports.
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"

# [Optional] Uncomment this section to install additional packages.
#
# Install apt packages which are required for builing libCZI (and CZICmd) with all features
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends libcurl4-openssl-dev rapidjson-dev libfreetype6-dev libpng-dev libeigen3-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{
"name": "C++",
"build": {
"dockerfile": "Dockerfile"
},
"settings": {
// configure those options for the CMake-configure run (in VSCode) in the container - we enable the curl-based stream, prefer
// the external package libcurl, disable the dynamic library, enable builing CZICmd and instruct to use an external package for Eigen3
"cmake.configureArgs": [
"-DLIBCZI_BUILD_CURL_BASED_STREAM=ON",
"-DLIBCZI_BUILD_PREFER_EXTERNALPACKAGE_LIBCURL=ON",
"-DLIBCZI_BUILD_DYNLIB=OFF",
"-DLIBCZI_BUILD_CZICMD=ON",
"-DLIBCZI_BUILD_PREFER_EXTERNALPACKAGE_EIGEN3=ON"
]
// Add other settings here as needed
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// 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": "gcc -v",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
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
2 changes: 2 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ DISABLE_LINTERS:
- REPOSITORY_TRIVY # this linter seems currently broken, so we disable it here for now
C_CPPLINT_ARGUMENTS: --verbose=2
CPP_CPPLINT_ARGUMENTS: --verbose=2
JSON_JSONLINT_ARGUMENTS: --comments # Allow comments in JSON files
DOCKERFILE_HADOLINT_ARGUMENTS: --ignore DL3008 # Ignore "pin versions in pip" warning
SHOW_ELAPSED_TIME: true
FILEIO_REPORTER: false
UPDATED_SOURCES_REPORTER: false
Expand Down
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Files: Src/JxrDecode/jxrlib/*
Copyright: Microsoft Corp.
License: BSD-3-Clause

Files: .github/*
Files: .github/* .devcontainer/*
Copyright: 2017-2022 Carl Zeiss Microscopy GmbH
License: CC0-1.0

0 comments on commit 2539ce5

Please sign in to comment.