TRX/tools/shared/docker/game-win/Dockerfile

187 lines
4.4 KiB
Text
Raw Normal View History

2023-09-26 16:22:29 +02:00
# TR1X building toolchain.
#
# This is a multi-stage Docker image. It is designed to keep the final image
# size low. Each stage builds an external dependency. The final stage takes the
# artifacts (binaries, includes etc.) from previous stages and installs all the
2023-09-26 16:22:29 +02:00
# tools necessary to build TR1X.
# MinGW
2024-08-18 23:02:00 +02:00
FROM ubuntu:latest AS mingw
2021-11-17 12:08:20 +01:00
# don't prompt during potential installation/update of tzinfo
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Warsaw
2021-11-17 12:08:20 +01:00
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
gcc-mingw-w64-i686 \
2021-11-14 23:42:18 +01:00
g++-mingw-w64-i686 \
2021-11-17 12:08:20 +01:00
git \
make
2021-11-20 22:40:57 +01:00
# pcre
2024-08-18 23:02:00 +02:00
FROM mingw AS pcre2
RUN git clone https://github.com/PCRE2Project/pcre2
RUN apt-get -y install libtool
RUN cd pcre2 \
&& autoreconf -fi \
&& ./configure \
--host=i686-w64-mingw32 \
--prefix=/ext/ \
&& make -j 4 \
&& make install
2025-02-11 22:19:01 +01:00
2021-11-20 22:40:57 +01:00
# zlib
2024-08-18 23:02:00 +02:00
FROM mingw AS zlib
RUN git clone https://github.com/madler/zlib --branch=v1.3.1
2021-11-20 22:40:57 +01:00
RUN cd zlib \
&& make -f win32/Makefile.gcc \
SHARED_MODE=1 \
BINARY_PATH=/ext/bin \
INCLUDE_PATH=/ext/include \
LIBRARY_PATH=/ext/lib \
2021-11-20 22:40:57 +01:00
PREFIX=i686-w64-mingw32- \
-j 4 install
2025-02-11 22:19:01 +01:00
# libav
2024-08-18 23:02:00 +02:00
FROM mingw AS libav
RUN apt-get install -y \
nasm
2021-12-04 18:45:39 +01:00
RUN git clone \
--depth 1 \
2025-02-10 23:18:50 +01:00
--branch "n7.1" \
2021-12-04 18:45:39 +01:00
https://github.com/FFmpeg/FFmpeg
COPY --from=zlib /ext/ /usr/i686-w64-mingw32/
COPY ./tools/ffmpeg_flags.txt /tmp/ffmpeg_flags.txt
2021-11-20 22:40:57 +01:00
RUN cd FFmpeg \
&& ./configure \
--arch=x86 \
--target-os=mingw32 \
--cross-prefix=i686-w64-mingw32- \
--prefix=/ext/ \
2021-11-20 22:40:57 +01:00
--cc=i686-w64-mingw32-gcc \
2025-02-10 23:18:50 +01:00
--cxx=i686-w64-mingw32-g++ \
--host-cc=i686-w64-mingw32-gcc \
2021-12-07 13:58:37 +01:00
--strip=i686-w64-mingw32-strip \
2021-11-20 22:40:57 +01:00
--pkg-config=i686-w64-mingw32-pkg-config \
--enable-static \
--disable-shared \
$(cat /tmp/ffmpeg_flags.txt) \
2021-11-20 22:40:57 +01:00
&& make -j 4 \
&& make install
# SDL
2024-08-18 23:02:00 +02:00
FROM mingw AS sdl
RUN git clone https://github.com/libsdl-org/SDL -b SDL2
RUN apt-get install -y automake
RUN cd SDL \
&& aclocal -I acinclude \
&& autoconf \
&& mkdir build \
&& cd build \
&& ../configure \
--host=i686-w64-mingw32 \
--build=i686-pc-mingw32 \
--prefix=/ext/ \
--enable-shared \
2021-12-07 12:54:44 +01:00
--enable-static \
&& make -j 4 \
&& make install
# SDL3 - Compiles fine, but meson cannot find it.
# TODO - fix that once SDL reaches maturity and releases 3.x as a stable version
# RUN git clone https://github.com/libsdl-org/SDL
# RUN apt-get install -y cmake
# RUN cd SDL \
# && mkdir build \
# && cd build \
# && cmake .. \
# --toolchain build-scripts/cmake-toolchain-mingw64-i686.cmake \
# -DCMAKE_INSTALL_PREFIX=/ext/ \
# -DCMAKE_BUILD_TYPE=Release \
# -DSDL_VULKAN=ON \
# -DSDL_TEST=ON \
# && cmake --build . \
# && make -j 4 \
# && make install
# uthash
FROM mingw AS uthash
RUN mkdir /ext/
WORKDIR /tmp/
RUN apt-get install -y wget xz-utils
RUN wget https://github.com/troydhanson/uthash/archive/v2.3.0.tar.gz
RUN tar -xvf v2.3.0.tar.gz
RUN cp -rL uthash-2.3.0/* /ext/
2025-02-11 22:19:01 +01:00
# GLEW
FROM mingw as glew
RUN git clone https://github.com/nigels-com/glew.git
RUN apt-get install -y \
build-essential \
libxmu-dev \
libxi-dev \
libgl-dev \
python3
RUN cd glew/auto \
&& PYTHON=python3 make
RUN mkdir -p /ext/lib \
&& export \
SYSTEM=linux-mingw32 \
GLEW_NO_GLU=-DGLEW_NO_GLU \
GLEW_DEST=/ext \
&& cd glew \
&& make \
&& make install
RUN sed -i "s/Cflags: .*/\\0 -DGLEW_STATIC/" /ext/lib/pkgconfig/glew.pc
2023-09-26 16:22:29 +02:00
# TR1X
FROM mingw
2021-11-17 12:08:20 +01:00
# set the build dir - actual files are mounted with a Docker volume
RUN mkdir /app
WORKDIR /app
# system dependencies
2021-12-07 12:54:26 +01:00
# configure pkgconfig manually
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=967969
2022-12-15 12:10:51 +01:00
RUN apt-get install -y \
2021-12-07 12:54:26 +01:00
mingw-w64-tools \
pkg-config \
upx \
python3-pip \
2024-04-30 21:32:03 +02:00
&& python3 -m pip install --break-system-packages \
pyjson5 \
meson \
ninja
2025-02-11 22:19:01 +01:00
COPY --from=pcre2 /ext/ /ext/
COPY --from=zlib /ext/ /ext/
COPY --from=libav /ext/ /ext/
COPY --from=sdl /ext/ /ext/
COPY --from=uthash /ext/ /ext/
COPY --from=glew /ext/ /ext/
ENV PKG_CONFIG_LIBDIR=/ext/lib/
ENV PKG_CONFIG_PATH=/ext/lib/pkgconfig/
ENV C_INCLUDE_PATH=/ext/include/
2024-03-25 11:09:05 +01:00
ENV PYTHONPATH=/app/tools/
2025-03-31 00:32:09 +02:00
ENTRYPOINT ["/app/tools/shared/docker/game-win/entrypoint.sh"]