# Linux build image for the parts of the pipeline that need Linux (ADR 003):
# the decomp ELF build (IDO 5.3 recomp, binutils-mips) and its spimdisasm analysis,
# n64sym, and N64Recomp/RSPRecomp (built from the repo's submodule at run time).
FROM ubuntu:24.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
        python3 python3-venv python3-pip python3-xxhash \
        make git ca-certificates \
        binutils-mips-linux-gnu \
        cmake ninja-build g++ \
        clang lld llvm \
        file \
    && rm -rf /var/lib/apt/lists/*

# Native Linux build of the game (tools/build_linux.sh, ADR 005): the libraries CMakeLists.txt's
# Linux branch and its dependencies need (SDL2, Freetype, GTK3 for the file dialog).
RUN apt-get update && apt-get install -y --no-install-recommends \
        libsdl2-dev libfreetype-dev libgtk-3-dev \
    && rm -rf /var/lib/apt/lists/*

# App icon rendering (tools/make_icons.sh): SVG to PNG, PNGs to a multi-size ICO.
RUN apt-get update && apt-get install -y --no-install-recommends \
        librsvg2-bin imagemagick \
    && rm -rf /var/lib/apt/lists/*

# n64sym (shygoo, MIT): signature-based libultra identification. Pinned; see ADR 004.
ARG N64SYM_COMMIT=ccf4600f3389f1a84bde23339225cf372fdf7712
RUN git clone https://github.com/shygoo/n64sym.git /opt/n64sym \
    && git -C /opt/n64sym checkout ${N64SYM_COMMIT} \
    && make -C /opt/n64sym \
    && find /opt/n64sym -maxdepth 2 -type f -name n64sym -perm -u+x -exec ln -s {} /usr/local/bin/n64sym \; \
    && n64sym 2>&1 | head -1

WORKDIR /work
