From 912acbf96d4ef32cefdc6353f259066a01a0a2ac Mon Sep 17 00:00:00 2001 From: dcvz Date: Sun, 19 May 2024 13:53:34 +0200 Subject: [PATCH] Add devcontainer definition --- .devcontainer/Dockerfile | 12 +++++++++++ .devcontainer/devcontainer.json | 21 +++++++++++++++++++ .devcontainer/install-sdl2.sh | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/install-sdl2.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..c635ab8 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-22.04 + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends ninja-build libsdl2-dev libgtk-3-dev lld llvm clang-15 + +ARG INSTALL_SDL2_VERSION_FROM_SOURCE="2.26.1" + +COPY ./install-sdl2.sh /tmp/ +RUN if [ "${INSTALL_SDL2_VERSION_FROM_SOURCE}" != "none" ]; then \ + chmod +x /tmp/install-sdl2.sh && /tmp/install-sdl2.sh ${INSTALL_SDL2_VERSION_FROM_SOURCE}; \ + fi \ + && rm -f /tmp/install-sdl2.sh \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..a2fb44d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,21 @@ +{ + "name": "Zelda64Recomp", + "build": { + "dockerfile": "Dockerfile", + }, + + // 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" +} \ No newline at end of file diff --git a/.devcontainer/install-sdl2.sh b/.devcontainer/install-sdl2.sh new file mode 100644 index 0000000..1609971 --- /dev/null +++ b/.devcontainer/install-sdl2.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e + +SDL2_VERSION=${1:-"none"} + +if [ "${SDL2_VERSION}" = "none" ]; then + echo "No SDL2 version specified, skipping SDL2 installation" + 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..." + +wget https://www.libsdl.org/release/SDL2-${SDL2_VERSION}.tar.gz +tar -xzf SDL2-${SDL2_VERSION}.tar.gz +cd SDL2-${SDL2_VERSION} +./configure +make -j 10 +sudo make install + +if [ "$(uname -m)" == "x86_64" ]; then + sudo cp -av /usr/local/lib/libSDL* /lib/x86_64-linux-gnu/ +else + sudo cp -av /usr/local/lib/libSDL* /usr/lib/aarch64-linux-gnu/ +fi