# Build environment for the Linux AppImages (tools/linux/appimage.sh): Ubuntu 22.04, so the result runs on glibc 2.35+.
# Built once per arch (podman build --arch amd64 / arm64). The amd64 image builds everything, the aarch64 AppImage
# cross-compiled; the arm64 image is the cross build's sysroot (the same -dev packages) and freezes the arm64 seed
# generator helper (PyInstaller only builds for the machine it runs on).
FROM docker.io/library/ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
        ca-certificates curl git file xz-utils patchelf make cmake ninja-build pkg-config nasm python3 \
        g++ software-properties-common gpg-agent \
        # SDL3's video / audio / input backends (it loads them at run time; the headers decide what it can use)
        libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxfixes-dev libxtst-dev \
        libxkbcommon-dev libwayland-dev wayland-protocols libdecor-0-dev libegl-dev libgl-dev libdrm-dev libgbm-dev \
        libpulse-dev libasound2-dev libpipewire-0.3-dev libdbus-1-dev libudev-dev libibus-1.0-dev \
        libvulkan-dev \
    && add-apt-repository -y ppa:deadsnakes/ppa \
    # clang 21 from apt.llvm.org: 22.04's clang 15 lacks the __builtin_elementwise_* the lifted FP code uses (simd_fp.h)
    && curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key -o /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
    && echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-21 main" > /etc/apt/sources.list.d/llvm.list \
    && apt-get update \
    && apt-get install -y --no-install-recommends python3.12 python3.12-venv python3.12-dev clang-21 lld-21 llvm-21 \
    && rm -rf /var/lib/apt/lists/* \
    && for t in clang clang++ ld.lld llvm-ar llvm-nm llvm-ranlib llvm-strip; do ln -sf $t-21 /usr/bin/$t; done
