# Compilation croisée Windows x64 de SmashRecomp avec llvm-mingw (Clang + runtime UCRT), sans émulation
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
	build-essential ninja-build nasm git curl ca-certificates zip unzip tar xz-utils pkg-config file rsync \
	autoconf automake autoconf-archive libtool bison flex python3 python3-pip python3-venv \
	&& rm -rf /var/lib/apt/lists/*
RUN pip3 install --no-cache-dir "cmake==3.31.6"
# architecture de la machine de compilation : aarch64 (Mac Apple Silicon) ou x86_64
ARG HOSTARCH=aarch64
ARG LLVM_MINGW=llvm-mingw-20260922-ucrt-ubuntu-22.04-${HOSTARCH}
RUN curl -sSfL "https://github.com/mstorsjo/llvm-mingw/releases/download/20260922/${LLVM_MINGW}.tar.xz" | tar -xJ -C /opt \
	&& mv /opt/${LLVM_MINGW} /opt/llvm-mingw
ENV PATH=/opt/llvm-mingw/bin:$PATH
# PowerShell : vcpkg l'utilise pour copier les dépendances des outils des cibles Windows
RUN PWSHARCH=$([ "$HOSTARCH" = x86_64 ] && echo x64 || echo arm64) && mkdir -p /opt/pwsh \
	&& curl -sSfL "https://github.com/PowerShell/PowerShell/releases/download/v7.4.6/powershell-7.4.6-linux-${PWSHARCH}.tar.gz" | tar -xz -C /opt/pwsh \
	&& chmod +x /opt/pwsh/pwsh && ln -s /opt/pwsh/pwsh /usr/bin/pwsh
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
# vcpkg sur hôte arm64 : utilise cmake/ninja du système
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
WORKDIR /work
