From 951b55f67e230b9afa0a219af3564d4d4dc2d0f6 Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Sun, 6 Dec 2026 06:48:31 +0300 Subject: [PATCH] ci: parse MinGW's version suffix and try nix when present MinGW's -dumpversion prints e.g. '10-win32', which broke the numeric comparison; keep the leading major. Also try a nix-provided cross toolchain when nix is available, before falling back to the (often older) distribution package. --- .gitea/scripts/install-mingw.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.gitea/scripts/install-mingw.sh b/.gitea/scripts/install-mingw.sh index bc543aa..6859833 100644 --- a/.gitea/scripts/install-mingw.sh +++ b/.gitea/scripts/install-mingw.sh @@ -14,7 +14,9 @@ compiler_major() { echo 0 return } - "${compiler}" -dumpversion 2>/dev/null | cut -d. -f1 || echo 0 + # MinGW prints e.g. "10-win32": keep only the leading major number. + "${compiler}" -dumpversion 2>/dev/null | sed -nE 's/^([0-9]+).*/\1/p' | head -n1 || + echo 0 } compatible() { @@ -49,6 +51,22 @@ if command -v dev >/dev/null 2>&1; then fi fi +# Nix, when the runner has it. +if command -v nix >/dev/null 2>&1; then + echo "trying nix for MinGW-w64 GCC ${minimum}+" + if nix shell --command true nixpkgs#pkgsCross.mingwW64.stdenv.cc >/dev/null 2>&1; then + nix_path="$(nix shell --command sh -c 'printf %s "$PATH"' \ + nixpkgs#pkgsCross.mingwW64.stdenv.cc 2>/dev/null | tail -n1 || true)" + if [ -n "${nix_path:-}" ]; then + export PATH="${nix_path}:${PATH}" + hash -r + fi + fi + if report; then + exit 0 + fi +fi + # Distribution package (may be older than GCC 16). if command -v apt-get >/dev/null 2>&1; then sudo=""