v0.2.0: clang + import std; isolated Windows cross-build (llvm-mingw + SDL3)

This commit is contained in:
EnderTheCoder
2026-09-12 02:04:25 +08:00
parent b35372da52
commit 1d12e4e099
23 changed files with 393 additions and 267 deletions
+19 -17
View File
@@ -1,7 +1,9 @@
# syntax=docker/dockerfile:1
# dev target: full toolchain + debug tools for development and debugging.
# Base image and compiler are the latest stable (ubuntu:26.04 ships gcc/g++ 16).
# Linux build environment. Isolated from the Windows cross image (Dockerfile.win)
# so the two toolchains and their standard libraries never interfere.
#
# dev target: clang + libc++ (for `import std;`) + SDL3 + debug tools.
FROM ubuntu:26.04 AS dev
ENV DEBIAN_FRONTEND=noninteractive
@@ -23,44 +25,44 @@ RUN --mount=type=cache,target=/var/lib/apt,sharing=locked \
sleep 5; \
done \
&& apt-get -o Acquire::Retries=5 install -y --no-install-recommends \
build-essential \
ca-certificates \
clang-21 \
clang-tools-21 \
cmake \
g++-16 \
gdb \
git \
libc++-21-dev \
libc++abi-21-dev \
libsdl3-dev \
ninja-build \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Pin the toolchain to GCC 16 (the distro default is still GCC 15).
ENV CC=gcc-16
ENV CXX=g++-16
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-16 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-16 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-16 100
ENV CC=clang-21
ENV CXX=clang++-21
WORKDIR /work
COPY . .
# C++26 modules need CMake >= 3.28, the Ninja generator and a module-aware gcc.
RUN cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build -j \
&& ctest --test-dir build --output-on-failure
RUN cmake -S . -B build/linux -G Ninja -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build/linux -j \
&& ctest --test-dir build/linux --output-on-failure
# deploy target: runtime dependencies + final binary, minimal and fast.
FROM ubuntu:26.04 AS deploy
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -o Acquire::Retries=5 update \
RUN --mount=type=cache,target=/var/lib/apt,sharing=locked \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get -o Acquire::Retries=5 update \
&& apt-get -o Acquire::Retries=5 install -y --no-install-recommends \
libc++1 \
libc++abi1 \
libsdl3-0 \
libstdc++6 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=dev /work/build/bin/openra3 /app/openra3
COPY --from=dev /work/build/linux/bin/openra3 /app/openra3
ENTRYPOINT ["/app/openra3"]