Skip to content

Commit

Permalink
move cross-compiling deps into a separate devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
nornagon authored Jan 9, 2024
1 parent 08cf028 commit 7cba0a7
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 68 deletions.
56 changes: 0 additions & 56 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,6 @@
FROM mcr.microsoft.com/devcontainers/cpp:0-ubuntu-22.04

# NOTE: Uninstall CMake extensions
# This is not a supported method by CDDA maintainers and it's confusing have this in the editor
# TODO: Not possible yet, waiting on upstream.
# Considered trying to get cheeky and deleting the folder but I believe that is held on the host
# This would require building out a more full featured container. Easier to wait and see.
# RUN code --uninstall-extension ms-vscode.cmake-tools && \
# code --uninstall-extensiontwxs.cmake

ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2"

# 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.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends libsdl2-dev libsdl2-ttf-dev libharfbuzz-dev \
libsdl2-image-dev libjpeg-turbo8-dev libtiff-dev libwebp-dev libzip-dev libzstd-dev \
libsdl2-mixer-dev libflac-dev libasound2-dev libfreetype6-dev build-essential astyle ccache

# [Optional] comment out this section unless you want to compile the Object Creator. Install some QT libraries
RUN apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools

# [Optional] comment out this section unless you want to cross-compile from Linux to Windows
# This section should align with doc/COMPILING/COMPILING.md#cross-compile-to-windows-from-linux
# With the exception of the installation of packages that are already installed earlier in the Dockerfile
# Like: astyle, cmake
RUN apt-get -y install autoconf automake autopoint bash bison bzip2 flex gettext git g++ \
gperf intltool libffi-dev libgdk-pixbuf2.0-dev libtool libltdl-dev libssl-dev \
libxml-parser-perl lzip make mingw-w64 openssl p7zip-full patch perl pkg-config \
python3 ruby scons sed unzip wget xz-utils g++-multilib libc6-dev-i386 libtool-bin python3-mako

WORKDIR /opt
RUN mkdir -p mxe
RUN mkdir -p libbacktrace
RUN git clone https://github.com/mxe/mxe.git ./mxe
WORKDIR /opt/mxe

# because of https://github.com/mxe/mxe/issues/2659, we have to link python 3 to python
RUN ln /usr/bin/python3 /usr/bin/python
# Builds windows version of SDL2 which is required to later cross-compile CDDA.
RUN make -j4 MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' \
MXE_PLUGIN_DIRS=plugins/gcc12 sdl2 sdl2_ttf sdl2_image sdl2_mixer gettext
WORKDIR /opt/libbacktrace
RUN wget https://github.com/Qrox/libbacktrace/releases/download/2020-01-03/libbacktrace-x86_64-w64-mingw32.tar.gz
RUN wget https://github.com/Qrox/libbacktrace/releases/download/2020-01-03/libbacktrace-i686-w64-mingw32.tar.gz
RUN tar -xzf libbacktrace-x86_64-w64-mingw32.tar.gz --exclude=LICENSE -C /opt/mxe/usr/x86_64-w64-mingw32.static
RUN tar -xzf libbacktrace-i686-w64-mingw32.tar.gz --exclude=LICENSE -C /opt/mxe/usr/i686-w64-mingw32.static

#Additional steps to cross compile object_creator. comment this out if you don't want to cross-compile the object cretor
WORKDIR /opt/mxe
RUN make MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' qtbase
RUN export PATH=/opt/mxe/usr/bin:$PATH
62 changes: 62 additions & 0 deletions .devcontainer/cross-compile/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM mcr.microsoft.com/devcontainers/cpp:0-ubuntu-22.04

# NOTE: Uninstall CMake extensions
# This is not a supported method by CDDA maintainers and it's confusing have this in the editor
# TODO: Not possible yet, waiting on upstream.
# Considered trying to get cheeky and deleting the folder but I believe that is held on the host
# This would require building out a more full featured container. Easier to wait and see.
# RUN code --uninstall-extension ms-vscode.cmake-tools && \
# code --uninstall-extensiontwxs.cmake

ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2"

# 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.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends libsdl2-dev libsdl2-ttf-dev libharfbuzz-dev \
libsdl2-image-dev libjpeg-turbo8-dev libtiff-dev libwebp-dev libzip-dev libzstd-dev \
libsdl2-mixer-dev libflac-dev libasound2-dev libfreetype6-dev build-essential astyle ccache

# [Optional] comment out this section unless you want to compile the Object Creator. Install some QT libraries
RUN apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools

# [Optional] comment out this section unless you want to cross-compile from Linux to Windows
# This section should align with doc/COMPILING/COMPILING.md#cross-compile-to-windows-from-linux
# With the exception of the installation of packages that are already installed earlier in the Dockerfile
# Like: astyle, cmake
RUN apt-get -y install autoconf automake autopoint bash bison bzip2 flex gettext git g++ \
gperf intltool libffi-dev libgdk-pixbuf2.0-dev libtool libltdl-dev libssl-dev \
libxml-parser-perl lzip make mingw-w64 openssl p7zip-full patch perl pkg-config \
python3 ruby scons sed unzip wget xz-utils g++-multilib libc6-dev-i386 libtool-bin python3-mako

WORKDIR /opt
RUN mkdir -p mxe
RUN mkdir -p libbacktrace
RUN git clone https://github.com/mxe/mxe.git ./mxe
WORKDIR /opt/mxe

# because of https://github.com/mxe/mxe/issues/2659, we have to link python 3 to python
RUN ln /usr/bin/python3 /usr/bin/python
# Builds windows version of SDL2 which is required to later cross-compile CDDA.
RUN make -j4 MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' \
MXE_PLUGIN_DIRS=plugins/gcc12 sdl2 sdl2_ttf sdl2_image sdl2_mixer gettext
WORKDIR /opt/libbacktrace
RUN wget https://github.com/Qrox/libbacktrace/releases/download/2020-01-03/libbacktrace-x86_64-w64-mingw32.tar.gz
RUN wget https://github.com/Qrox/libbacktrace/releases/download/2020-01-03/libbacktrace-i686-w64-mingw32.tar.gz
RUN tar -xzf libbacktrace-x86_64-w64-mingw32.tar.gz --exclude=LICENSE -C /opt/mxe/usr/x86_64-w64-mingw32.static
RUN tar -xzf libbacktrace-i686-w64-mingw32.tar.gz --exclude=LICENSE -C /opt/mxe/usr/i686-w64-mingw32.static

#Additional steps to cross compile object_creator. comment this out if you don't want to cross-compile the object cretor
WORKDIR /opt/mxe
RUN make MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' qtbase
RUN export PATH=/opt/mxe/usr/bin:$PATH
35 changes: 35 additions & 0 deletions .devcontainer/cross-compile/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": "Standard",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"github.vscode-github-actions",
"ms-vscode.makefile-tools",
"ms-vscode.cpptools-extension-pack",
"EditorConfig.EditorConfig",
"chiehyu.vscode-astyle"
]
}
}

// 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"
}

25 changes: 13 additions & 12 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
// 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": "Cataclysm",
"name": "Standard",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"github.vscode-github-actions",
"ms-vscode.makefile-tools",
"EditorConfig.EditorConfig",
"chiehyu.vscode-astyle"
]
}
}
},
"customizations": {
"vscode": {
"extensions": [
"github.vscode-github-actions",
"ms-vscode.makefile-tools",
"ms-vscode.cpptools-extension-pack",
"EditorConfig.EditorConfig",
"chiehyu.vscode-astyle"
]
}
}

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

0 comments on commit 7cba0a7

Please sign in to comment.