Building with my own toolchain for realsies

This commit is contained in:
Will Toohey 2026-03-05 20:01:12 +10:00
parent 94d4b25ec3
commit 94e205d474
8 changed files with 64 additions and 27 deletions

View File

@ -138,12 +138,18 @@ a lot to be desired. There are many vestigal remains of past AVS experiments.
Prior to version 3.0, it was built with Visual Studio 2017 with the 141_xp
toolchain. However, in VS 2019 16.7, they broke this (it pulls in Vista-only
APIs), so I gave up and moved to mingw-w64. I currently just have that installed
in an Ubuntu install in WSL. If it ever breaks, I'll make a docker or nix image
or something... Feel free to open an issue if you're struggling to build it.
APIs), so I gave up and moved to mingw-w64.
As long as you have Meson and mingw-w64 installed, it should be as simple as
running `build.sh`.
Then, in 3.11, I decided that sticking to mingw gcc-11 (the last version that
easily supported XP) was pain, and made a [custom LLVM toolchain](https://github.com/mon/llvm-mingw-xp)
that supports XP, which lets me use C++23 features going forwards.
If you want to build and have it support XP, the simplest approach is to run
`./build_docker.sh` on a Linux system, which will use my customised toolchain.
However, you can also build with any modern clang/gcc with `build.sh`, as long
as you're OK with it only working on Windows 7 and up (and by the time you read
this, probably Windows 10 and up).
# Contributing

View File

@ -4,13 +4,16 @@ set -euxo pipefail
rm -rf dist/
CROSS_32="${CROSS_32:-cross-clang-mingw-32.ini}"
CROSS_64="${CROSS_64:-cross-clang-mingw-64.ini}"
# x86
meson setup --cross-file cross-i686-w64-mingw32.txt build32
meson setup --cross-file "$CROSS_32" build32
# without `--tags runtime`, the .a files are also installed
meson install -C build32 --destdir ../dist/32bit --tags runtime,doc
# x86_64
meson setup --cross-file cross-x86_64-w64-mingw32.txt build64
meson setup --cross-file "$CROSS_64" build64
meson install -C build64 --destdir ../dist/64bit --tags runtime,doc
# docs

12
build_docker.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# highly recommend using podman-docker instead of docker, no "the build folder is owned by root" issues
set -eu
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
docker build --pull "$SCRIPT_DIR/docker" -t layeredfs/deps --platform linux/x86_64
docker run -it --rm -v "$SCRIPT_DIR:/work" layeredfs/deps ./build.sh "$@"
docker run -it --rm -v "$SCRIPT_DIR:/work" layeredfs/deps ./test.sh "$@"

13
cross-clang-mingw-32.ini Normal file
View File

@ -0,0 +1,13 @@
[binaries]
c = 'i686-w64-mingw32-clang'
cpp = 'i686-w64-mingw32-clang++'
ar = 'i686-w64-mingw32-ar'
windres = 'i686-w64-mingw32-windres'
strip = 'i686-w64-mingw32-strip'
exe_wrapper = 'wine'
[host_machine]
system = 'windows'
cpu_family = 'x86'
cpu = 'x86'
endian = 'little'

View File

@ -1,14 +1,13 @@
[binaries]
c = 'x86_64-w64-mingw32-gcc'
cpp = 'x86_64-w64-mingw32-g++'
c = 'x86_64-w64-mingw32-clang'
cpp = 'x86_64-w64-mingw32-clang++'
ar = 'x86_64-w64-mingw32-ar'
windres = 'x86_64-w64-mingw32-windres'
strip = 'x86_64-w64-mingw32-strip'
exe_wrapper = 'wine'
[host_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
[properties]
needs_exe_wrapper = false

View File

@ -1,14 +0,0 @@
[binaries]
c = 'i686-w64-mingw32-gcc'
cpp = 'i686-w64-mingw32-g++'
ar = 'i686-w64-mingw32-ar'
strip = 'i686-w64-mingw32-strip'
[host_machine]
system = 'windows'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'
[properties]
needs_exe_wrapper = false

18
docker/Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM montymintypie/llvm-mingw-xp:21
RUN set -eux; \
dpkg --add-architecture i386; \
apt-get update -qq; \
DEBIAN_FRONTEND="noninteractive" apt-get install -qqy --no-install-recommends \
meson jq wine wine32; \
apt-get clean -y; \
rm -rf /var/lib/apt/lists/*;
# Run wineboot just to setup the default WINEPREFIX so we don't do it every
# container run
RUN wine wineboot --init
ENV CROSS_32=/opt/llvm-mingw/toolchain-files/meson/i686-mingw32-clang.ini
ENV CROSS_64=/opt/llvm-mingw/toolchain-files/meson/x86_64-mingw32-clang.ini
WORKDIR /work

View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash
meson compile -C build64 playpen && ./build64/playpen.exe --layered-verbose "$@"
meson compile -C build64 playpen && wine ./build64/playpen.exe --layered-verbose "$@"