diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..1079f741 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +# The build image only needs a couple of scripts out of the tree, so keep the +# build context from dragging in a full local build. +.git +objs/ +bins/ +/pcsx-redux +/pcsx-redux-tests +*.AppImage diff --git a/tools/build/Dockerfile b/tools/build/Dockerfile index 4ac6eb1d..ae7b94ab 100644 --- a/tools/build/Dockerfile +++ b/tools/build/Dockerfile @@ -1,4 +1,25 @@ # Dockerfile for ghcr.io/grumpycoders/pcsx-redux-build +# +# This one needs the repository root as its build context, as the first stage +# builds the mips toolchain using tools/linux-mips/spawn-compiler.sh: +# +# docker build -f tools/build/Dockerfile -t ghcr.io/grumpycoders/pcsx-redux-build . + +FROM ubuntu:26.04 AS toolchain + +ENV DEBIAN_FRONTEND noninteractive +ENV TZ Etc/GMT + +RUN apt update +RUN apt dist-upgrade -y +RUN apt install -y make g++ wget bzip2 xz-utils bison flex texinfo +RUN apt install -y libgmp-dev libmpfr-dev libmpc-dev + +ARG JOBS= + +WORKDIR /tmp/toolchain +COPY tools/linux-mips/spawn-compiler.sh . +RUN JOBS=$JOBS sh spawn-compiler.sh FROM ubuntu:26.04 @@ -16,7 +37,6 @@ RUN apt install -y pkg-config # Compilers & base libraries RUN apt install -y g++ -RUN apt install -y g++-mipsel-linux-gnu # Development packages RUN apt install -y libavcodec-dev @@ -33,7 +53,7 @@ RUN apt install -y zlib1g-dev # CI utilities RUN apt install -y curl wget RUN apt install -y xvfb -RUN apt install -y python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace +RUN apt install -y python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf-2.0-dev fakeroot strace RUN apt install -y glibc-tools lcov RUN apt install -y file @@ -42,9 +62,13 @@ RUN apt install -y libfuse2t64 RUN apt install -y fuse # AppImage tools -RUN apt install -y imagemagick-6.q16 gtk-update-icon-cache appstream +RUN apt install -y imagemagick-7.q16 gtk-update-icon-cache appstream RUN apt install -y squashfs-tools zip zsync +# The mips toolchain, built from source in the first stage. Ubuntu dropped the +# mipsel cross compilers, so there's no distribution package to install here. +COPY --from=toolchain /usr/local /usr/local + WORKDIR /tmp RUN wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage && \ chmod +x appimagetool-x86_64.AppImage && \ diff --git a/tools/linux-mips/spawn-compiler.sh b/tools/linux-mips/spawn-compiler.sh index d0d9eeda..9e20479d 100755 --- a/tools/linux-mips/spawn-compiler.sh +++ b/tools/linux-mips/spawn-compiler.sh @@ -1,17 +1,18 @@ #!/bin/sh # # Building gcc from source isn't necessarily an easy task, and it requires -# a lot of various dependency packages to work properly. The easiest way -# to use a mips compiler for Linux is still to use a package from your -# distribution. Nevertheless, here's how to build a working mips compiler -# that can produce code for the R3000A CPU, granted you have the necessary -# dependencies to do so. The script can be run as root, or as a regular user -# when the PREFIX environment variable is provided. +# a lot of various dependency packages to work properly. Here's how to build +# a working mips compiler that can produce code for the R3000A CPU, granted +# you have the necessary dependencies to do so. The script can be run as +# root, or as a regular user when the PREFIX environment variable is +# provided. Set JOBS to override the parallelism, which defaults to the +# number of available cores. # set -ex PREFIX=${PREFIX:-"/usr/local"} +JOBS=${JOBS:-$(nproc 2> /dev/null || echo 1)} for url in https://ftpmirror.gnu.org/gnu/binutils/binutils-2.47.tar.gz https://mirrors.kernel.org/gnu/binutils/binutils-2.47.tar.gz ; do wget --max-redirect=2 --timeout=60 --continue --trust-server-names $url && break @@ -19,7 +20,7 @@ done tar xvfz binutils-2.47.tar.gz cd binutils-2.47 ./configure --target=mipsel-none-elf --disable-multilib --disable-nls --disable-werror --prefix=$PREFIX -make +make -j$JOBS make install-strip cd .. @@ -32,9 +33,9 @@ cd gcc-16.2.0 mkdir build cd build ../configure --target=mipsel-none-elf --without-isl --disable-nls --disable-threads --disable-shared --disable-libssp --disable-libstdcxx-pch --disable-libgomp --disable-werror --without-headers --disable-hosted-libstdcxx --with-as=$PREFIX/bin/mipsel-none-elf-as --with-ld=$PREFIX/bin/mipsel-none-elf-ld --enable-languages=c,c++ --prefix=$PREFIX -make all-gcc +make -j$JOBS all-gcc make install-strip-gcc -make all-target-libgcc +make -j$JOBS all-target-libgcc make install-strip-target-libgcc -make all-target-libstdc++-v3 +make -j$JOBS all-target-libstdc++-v3 make install-strip-target-libstdc++-v3